示例#1
0
cl_context OCLContexts::GetContextByPlatformName(
    const std::string &platName, OCLContextProperties ctx_props) {
    OCLErrorExp clerr;
    cl_context found_ctx = m_contextMap[platName];

    if ( found_ctx != NULL ) {
        return found_ctx;
    }
    cl_platform_id platform = NULL;

    for (size_t i=0; i<get_num_platforms(); i++) {
        if (get_platform_name(i) == platName ) {
            platform = m_platforms[i];
            break;
        }
    }

    ctx_props.AddProperty(CL_CONTEXT_PLATFORM, (cl_context_properties) platform);
    found_ctx = clCreateContextFromType(ctx_props, CL_DEVICE_TYPE_ALL,
                                        NULL, NULL, clerr);
    clerr.CheckError();
    if ( platform != NULL ) {
        m_contextMap[platName] = found_ctx;
    }

    return found_ctx;
}
示例#2
0
void test_platforms()
{
	int i, j;
	char desc[256];
	struct cl_exec exec = { 0, 0, 1 };

	//Initialize the runtime
	cl_runtime rt = new_cl_runtime(false);
	printf("Testing %d platforms\n\n", get_num_platforms());
	for(i = 0; i < get_num_platforms(); i++)
	{
		exec.platform = i;
		clGetPlatformInfo(get_platform(rt, i), CL_PLATFORM_NAME, sizeof(desc), desc, NULL);
		printf("Testing devices for %s platform\n", desc);
		for(j = 0; j < get_num_devices(i); j++)
		{
			exec.device = j;
			test_device(rt, exec, get_device(rt, i, j));
		}
		printf("\n");
	}
	delete_cl_runtime(rt);
}
示例#3
0
int main(int argc, char** argv)
{
	cl_device_id dev;
	int i, j;
	unsigned long res;
	cl_runtime rt = new_cl_runtime(false);

	for(i = 0; i < get_num_platforms(); i++)
	{
		for(j = 0; j < get_num_devices(i); j++)
		{
			dev = get_device(rt, i, j);
			print_device_info(dev, false);
			clGetDeviceInfo(dev, CL_DEVICE_PROFILING_TIMER_RESOLUTION, sizeof(cl_ulong), &res, NULL);
			printf("---\nTimer resolution: %lu\n---\n", res);
		}
	}
	delete_cl_runtime(rt);
	return 0;
}