コード例 #1
0
ファイル: filter.c プロジェクト: alvivi/im-onlm
/*
 * Muestra por pantalla información sobre todas las plataformas y dispositivos
 * compatibles con OpenCL en el sistema.
 */
void showClInfo () {
	cl_platform_id *ps;
	cl_device_id *ds = NULL;
	cl_uint ps_size, ds_size, i, j;
	char name[STR_BUFFER_SIZE], vendor[STR_BUFFER_SIZE];

	getAllPlatforms(&ps, &ps_size);
	for (i = 0; i < ps_size; i++) {
		clGetPlatformInfo(ps[i], CL_PLATFORM_NAME, STR_BUFFER_SIZE,
			(void*)name, NULL);
		clGetPlatformInfo(ps[i], CL_PLATFORM_VENDOR, STR_BUFFER_SIZE,
			(void*)vendor, NULL);
		printf("Platform #%d - %s (%s)\n", i, name, vendor);
		getAllDevices(ps[i], &ds, &ds_size);
		for (j = 0; j < ds_size; j++) {
			clGetDeviceInfo(ds[j], CL_DEVICE_NAME, STR_BUFFER_SIZE,
				(void*)name, NULL);
			clGetDeviceInfo(ds[j], CL_DEVICE_VENDOR, STR_BUFFER_SIZE,
				(void*)vendor, NULL);
			printf("\tDevice #%d - %s (%s)\n", j, name, vendor);
		}
		free(ds);
	}
	free(ps);
}
コード例 #2
0
ファイル: filter.c プロジェクト: alvivi/im-onlm
/*
 * Obtiene un contexto a partir de los parámetros introducidos por la línea de
 * comandos.
 * < arg : Cadena que contiene el parámetro que selecciona los dispositvos. Debe
 *         ser de forma: List = p_id-d_id[[;, ]List].
 * > sel_ds : Array con los dispitivos seleccionados.
 */
cl_context createContextFromArgs (char *arg, cl_device_id *sel_ds,
								  cl_uint *sel_ds_size) {
	cl_uint is[BUFFER_SIZE], is_size = 0, ps_size, ds_sizes[BUFFER_SIZE], i,
			props_size = 0;
	char *str, tmp[STR_BUFFER_SIZE];
	cl_platform_id *ps, p;
	cl_device_id *ds[BUFFER_SIZE], d;
	cl_context_properties props[BUFFER_SIZE];

	*sel_ds_size = 0;
	if (arg == NULL || arg[0] == '\0')
		return NULL;

	/* Obtenemos todos indices a partir de la cadena de entrada */
	str = strtok(strcpy(tmp, arg), ",; ");
	do {
		if (sscanf(str, "%u-%u", &is[is_size], &is[is_size + 1]) >= 2)
			is_size += 2;
	} while ((str = strtok(NULL, ",; ")) != NULL);
	if (is_size == 0)
		return NULL;

	/* Obtenemos todas las plataformas y dispositivos del sistema */
	getAllPlatforms(&ps, &ps_size);
	for (i = 0; i < ps_size; i++) {
		getAllDevices(ps[i], &ds[i], &ds_sizes[i]);
	}

	/* Obtenemos los dispositivos seleccionados a partir de los indices */
	for (i = 0; i < is_size; i += 2) {
		if (is[i] >= ps_size || is[i + 1] >= ds_sizes[is[i]]) {
			fprintf(stderr, "ERROR: Device %d-%d does not exist\n",
					is[i], is[i + 1]);
			return NULL;
		}
		else {
			p = ps[is[i]];
			d = ds[is[i]][is[i + 1]];
			props[props_size++] = CL_CONTEXT_PLATFORM;
			props[props_size++] = (cl_context_properties)p;
			sel_ds[(*sel_ds_size)++] = d;
		}
	}
	props[props_size] = (cl_context_properties)NULL;

	/* Liberamos recursos */
	free(ps);
	for (i = 0; i < ps_size; i++)
		free(ds[i]);
	
	/* Creamos y devolvemos el contexto */
	return clCreateContext(props, *sel_ds_size, sel_ds, NULL, NULL, NULL);
}
コード例 #3
0
ファイル: frame.cpp プロジェクト: Doralitze/CREP
Frame::Frame(Dimension &size, RGBAPixel* initColor){
    this->width = size.GetWidth();
    this->height = size.GetHeight();
    if(getAllPlatforms().size() == 0){
        std::cout << " No platforms found. Check OpenCL installation!" << std::endl;
        return;
    }
#ifdef FK_USE_VECTOR_IMP
    //this->data = new std::vector<std::vector<HSVPixel>>();
    data.resize(width);
    for(unsigned int x = 0; x < this->width; x++){
        //std::vector<HSVPixel*>* nvector = new std::vector<HSVPixel*>;
        data[x].resize(height);
        //this->data->push_back(nvector);
        for(unsigned int y = 0; y < this->height; y++){
            //HSVPixel* pixel = new HSVPixel();
            //nvector->push_back(pixel);
            if(initColor != nullptr){
                data[x][y].setRed(initColor->getRed());
                data[x][y].setGreen(initColor->getGreen());
                data[x][y].setBlue(initColor->getBlue());
                data[x][y].setAlpha(initColor->getAlpha());
            } else {
                data[x][y].setRed(255);
                data[x][y].setGreen(255);
                data[x][y].setBlue(255);
                data[x][y].setAlpha(255);
            }
        }
    }
#else
    data = new double[width][height][4];
    if(initColor != nullptr)
        for(unsigned int x = 0; x < this->width; x++)
            for(unsigned int y = 0; y < this->height; y++){
                data[x][y][0] = initColor->getRed();
                data[x][y][1] = initColor->getGreen();
                data[x][y][2] = initColor->getBlue();
                data[x][y][3] = initColor->getAlpha();
            }
#endif
    valid = true;
}
コード例 #4
0
ファイル: frame.cpp プロジェクト: Doralitze/CREP
std::vector<cl::Context>& getAllContextes(void){
    if(!initialised)
        getAllPlatforms();
    return all_contextes;
}
コード例 #5
0
ファイル: frame.cpp プロジェクト: Doralitze/CREP
std::vector<cl::Device>& getAllDevices(void){
    if(!initialised)
        getAllPlatforms();
    return all_devices;
}
コード例 #6
0
ファイル: frame.cpp プロジェクト: Doralitze/CREP
std::vector<ExecutionTask*>& getAllExecutors(void){
    if(!initialised)
        getAllPlatforms();
    return all_execkernels;
}