diff options
| author | Wilson Fung <[email protected]> | 2012-11-07 05:40:42 -0800 |
|---|---|---|
| committer | Andrew Boktor <[email protected]> | 2014-08-14 13:49:21 -0700 |
| commit | 7b6c2f6dad0bc4c892788e495c75f169c6917bd5 (patch) | |
| tree | c2503d81bb2ea122fe225bbeeebf5f851e994480 /libopencl/nvopencl_wrapper.cc | |
| parent | 0b5efbc556621998ac42e96024163fae05beaf85 (diff) | |
nvopencl_wrapper now works on machine with both AMD and NVIDIA GPUs. It will automatically compile the OpenCL kernels on the NVIDIA platform.
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 14558]
Diffstat (limited to 'libopencl/nvopencl_wrapper.cc')
| -rw-r--r-- | libopencl/nvopencl_wrapper.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libopencl/nvopencl_wrapper.cc b/libopencl/nvopencl_wrapper.cc index 73e60bb..09d83c6 100644 --- a/libopencl/nvopencl_wrapper.cc +++ b/libopencl/nvopencl_wrapper.cc @@ -130,16 +130,29 @@ int main(int argc, const char **argv) platforms = (cl_platform_id*)malloc(num_platforms * sizeof(cl_platform_id)); errcode = clGetPlatformIDs(num_platforms, platforms, NULL); if ( errcode != CL_SUCCESS ) myexit(3,"clGetPlatformIDs returned %d",errcode); - errcode = clGetPlatformInfo(platforms[0], CL_PLATFORM_NAME, 1024, &buffer, NULL); + unsigned use_platform = 0; + if (num_platforms > 1) { + char platformName[1024]; + printf("%s: Multiple OpenCL platforms found. Searching for compatible platform...\n",PREAMBLE); + for (unsigned p = 0; p < num_platforms; p++) { + errcode = clGetPlatformInfo(platforms[p], CL_PLATFORM_NAME, 1024, &platformName, NULL); + if ( errcode != CL_SUCCESS ) myexit(3,"clGetPlatformInfo returned %d",errcode); + printf("%s: OpenCL platform \'%s\'\n",PREAMBLE, platformName); + if (strstr(platformName, "NVIDIA") != NULL) { + use_platform = p; + } + } + } + errcode = clGetPlatformInfo(platforms[use_platform], CL_PLATFORM_NAME, 1024, &buffer, NULL); if ( errcode != CL_SUCCESS ) myexit(3,"clGetPlatformInfo returned %d",errcode); printf("%s: Generating PTX using OpenCL platform \'%s\'\n",PREAMBLE,buffer); - errcode = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); + errcode = clGetDeviceIDs(platforms[use_platform], CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); if ( errcode != CL_SUCCESS ) myexit(4,"clGetDeviceIDs returned %d",errcode); printf("%s: found %u native OpenCL devices\n",PREAMBLE,num_devices); cl_device_id *devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id) ); - errcode = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_GPU, num_devices, devices, NULL); + errcode = clGetDeviceIDs(platforms[use_platform], CL_DEVICE_TYPE_GPU, num_devices, devices, NULL); if ( errcode != CL_SUCCESS ) myexit(5,"clGetDeviceIDs returned %d",errcode); context = clCreateContext(0, num_devices, devices, NULL, NULL, &errcode); if ( errcode != CL_SUCCESS ) myexit(6,"clCreateContext returned %d",errcode); |
