-
-
Save tserj/ed03e874d288be2a485089feed5ac08f to your computer and use it in GitHub Desktop.
Query OpenCL devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Show the device supporting OpenCL | |
| # https://stackoverflow.com/questions/7542808/how-to-compile-opencl-on-ubuntu | |
| linux: | |
| CUDA SDK (sudo apt-get install nvidia-cuda-toolkit nvidia-opencl-icd-384 ocl-icd-libopencl1 ocl-icd-opencl-dev opencl-headers) | |
| for win build under linux: | |
| apt install mingw-w64 mingw-w64-tools | |
| update OpenCL Headers in /usr/include/CL from (https://github.com/KhronosGroup/OpenCL-Headers) | |
| prepare libOpenCL.a: | |
| git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader.git | |
| cd OpenCL-ICD-Loader | |
| git checkout 6849f617e991e8a46eebf746df43032175f263b3 (as trunk has #include <Devpkey.h> that's hard to find in mingw current dist package) | |
| add patch to CMakeLists.txt: | |
| add_library (OpenCL STATIC ${OPENCL_ICD_LOADER_SOURCES}) | |
| set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") | |
| set_target_properties (OpenCL PROPERTIES PREFIX "") | |
| if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") | |
| set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-pthread -Wl,--version-script -Wl,${CMAKE_SOURCE_DIR}/icd_exports.map") | |
| mkdir inc/CL | |
| cp /usr/include/CL/* inc/CL/ | |
| cmake –G”Unix Makefiles” . -DENABLE_STATIC_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=x86_64-w64-mingw32-ranlib -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres -DCMAKE_INSTALL_PREFIX=/usr/x86_64-w64-mingw32 -DBUILD_SHARED_LIBS=OFF -DCMAKE_FIND_ROOT_PATH=/usr/x86_64-w64-mingw32 | |
| make clean | |
| make -j 2 | |
| cd bin | |
| sudo cp libOpenCL.dll /usr/x86_64-w64-mingw32/lib/ | |
| gendef libOpenCL.dll | |
| x86_64-w64-mingw32-dlltool -l libOpenCL.a -d libOpenCL.def -k -A | |
| sudo cp libOpenCL.a /usr/x86_64-w64-mingw32/lib/ | |
| $ g++ -o clDeviceQuery -I/usr/include clDeviceQuery.cpp -lOpenCL | |
| $(for windows)$ x86_64-w64-mingw32-g++ -o clDeviceQuery.exe -I/usr/share/mingw-w64/include -I/usr/include clDeviceQuery.cpp -lOpenCL -static | |
| windows: | |
| mingw-w64 | |
| CUDA SDK | |
| $ g++ -o clDeviceQuery -I"c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\include" clDeviceQuery.cpp -L"c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\lib\x64" -lOpenCL -static | |
| ------------------------------------------------------ | |
| binaries: https://github.com/tserj/clDeviceQuery | |
| ------------------------------------------------------ | |
| clDeviceQuery Starting... | |
| 2 OpenCL Platforms found | |
| CL_PLATFORM_NAME: NVIDIA CUDA | |
| CL_PLATFORM_VERSION: OpenCL 1.1 CUDA 6.5.51 | |
| OpenCL Device Info: | |
| 1 devices found supporting OpenCL on: NVIDIA CUDA | |
| ---------------------------------- | |
| Device GeForce GT 240 | |
| --------------------------------- | |
| CL_DEVICE_NAME: GeForce GT 240 | |
| CL_DEVICE_VENDOR: NVIDIA Corporation | |
| CL_DRIVER_VERSION: 342.01 | |
| CL_DEVICE_TYPE: CL_DEVICE_TYPE_GPU | |
| CL_DEVICE_MAX_COMPUTE_UNITS: 12 | |
| CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3 | |
| CL_DEVICE_MAX_WORK_ITEM_SIZES: 512 / 512 / 64 | |
| CL_DEVICE_MAX_WORK_GROUP_SIZE: 512 | |
| CL_DEVICE_MAX_CLOCK_FREQUENCY: 1340 MHz | |
| CL_DEVICE_ADDRESS_BITS: 32 | |
| CL_DEVICE_MAX_MEM_ALLOC_SIZE: 256 MByte | |
| CL_DEVICE_GLOBAL_MEM_SIZE: 1024 MByte | |
| CL_DEVICE_ERROR_CORRECTION_SUPPORT: no | |
| CL_DEVICE_LOCAL_MEM_TYPE: local | |
| CL_DEVICE_LOCAL_MEM_SIZE: 16 KByte | |
| CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 64 KByte | |
| CL_DEVICE_QUEUE_PROPERTIES: CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | |
| CL_DEVICE_QUEUE_PROPERTIES: CL_QUEUE_PROFILING_ENABLE | |
| CL_DEVICE_IMAGE_SUPPORT: 1 | |
| CL_DEVICE_MAX_READ_IMAGE_ARGS: 128 | |
| CL_DEVICE_MAX_WRITE_IMAGE_ARGS: 8 | |
| CL_DEVICE_IMAGE <dim> 2D_MAX_WIDTH 4096 | |
| 2D_MAX_HEIGHT 16383 | |
| 3D_MAX_WIDTH 2048 | |
| 3D_MAX_HEIGHT 2048 | |
| 3D_MAX_DEPTH 2048 | |
| CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t> CHAR 1, SHORT 1, INT 1, FLOAT 1, DOUBLE 1 | |
| clDeviceQuery, Platform Name = NVIDIA CUDA, Platform Version = OpenCL 1.1 CUDA 6.5.51, NumDevs = 1, Device = GeForce GT 240 | |
| CL_PLATFORM_NAME: Intel(R) OpenCL | |
| CL_PLATFORM_VERSION: OpenCL 1.2 | |
| OpenCL Device Info: | |
| 1 devices found supporting OpenCL on: Intel(R) OpenCL | |
| ---------------------------------- | |
| Device Intel(R) Core(TM) i5 CPU 760 @ 2.80GHz | |
| --------------------------------- | |
| CL_DEVICE_NAME: Intel(R) Core(TM) i5 CPU 760 @ 2.80GHz | |
| CL_DEVICE_VENDOR: Intel(R) Corporation | |
| CL_DRIVER_VERSION: 6.4.0.37 | |
| CL_DEVICE_TYPE: CL_DEVICE_TYPE_CPU | |
| CL_DEVICE_MAX_COMPUTE_UNITS: 4 | |
| CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: 3 | |
| CL_DEVICE_MAX_WORK_ITEM_SIZES: 8192 / 8192 / 8192 | |
| CL_DEVICE_MAX_WORK_GROUP_SIZE: 8192 | |
| CL_DEVICE_MAX_CLOCK_FREQUENCY: 2800 MHz | |
| CL_DEVICE_ADDRESS_BITS: 64 | |
| CL_DEVICE_MAX_MEM_ALLOC_SIZE: 2047 MByte | |
| CL_DEVICE_GLOBAL_MEM_SIZE: 8190 MByte | |
| CL_DEVICE_ERROR_CORRECTION_SUPPORT: no | |
| CL_DEVICE_LOCAL_MEM_TYPE: global | |
| CL_DEVICE_LOCAL_MEM_SIZE: 32 KByte | |
| CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 128 KByte | |
| CL_DEVICE_QUEUE_PROPERTIES: CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | |
| CL_DEVICE_QUEUE_PROPERTIES: CL_QUEUE_PROFILING_ENABLE | |
| CL_DEVICE_IMAGE_SUPPORT: 1 | |
| CL_DEVICE_MAX_READ_IMAGE_ARGS: 480 | |
| CL_DEVICE_MAX_WRITE_IMAGE_ARGS: 480 | |
| CL_DEVICE_IMAGE <dim> 2D_MAX_WIDTH 16384 | |
| 2D_MAX_HEIGHT 16384 | |
| 3D_MAX_WIDTH 2048 | |
| 3D_MAX_HEIGHT 2048 | |
| 3D_MAX_DEPTH 2048 | |
| CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t> CHAR 1, SHORT 1, INT 1, FLOAT 1, DOUBLE 1 | |
| clDeviceQuery, Platform Name = NVIDIA CUDA, Platform Version = OpenCL 1.1 CUDA 6.5.51, NumDevs = 1, Device = GeForce GT 240 | |
| Intel(R) OpenCL, Platform Version = OpenCL 1.2 , NumDevs = 1, Device = Intel(R) Core(TM) i5 CPU 760 @ 2.80GHz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Copyright 1993-2009 NVIDIA Corporation. All rights reserved. | |
| Modified by Mark Zwolinski, December 2009 | |
| Modified by Robert McGibbon, August 2013 | |
| */ | |
| #define CL_TARGET_OPENCL_VERSION 220 | |
| #ifdef __APPLE__ | |
| #include <OpenCL/opencl.h> | |
| #else | |
| #include <CL/cl.h> | |
| #endif | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <sstream> | |
| #include <fstream> | |
| void clPrintDevInfo(cl_device_id device) { | |
| char device_string[1024]; | |
| // CL_DEVICE_NAME | |
| clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(device_string), &device_string, NULL); | |
| printf(" CL_DEVICE_NAME: \t\t\t%s\n", device_string); | |
| // CL_DEVICE_VENDOR | |
| clGetDeviceInfo(device, CL_DEVICE_VENDOR, sizeof(device_string), &device_string, NULL); | |
| printf(" CL_DEVICE_VENDOR: \t\t\t%s\n", device_string); | |
| // CL_DRIVER_VERSION | |
| clGetDeviceInfo(device, CL_DRIVER_VERSION, sizeof(device_string), &device_string, NULL); | |
| printf(" CL_DRIVER_VERSION: \t\t\t%s\n", device_string); | |
| // CL_DEVICE_INFO | |
| cl_device_type type; | |
| clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL); | |
| if( type & CL_DEVICE_TYPE_CPU ) | |
| printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_CPU"); | |
| if( type & CL_DEVICE_TYPE_GPU ) | |
| printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_GPU"); | |
| if( type & CL_DEVICE_TYPE_ACCELERATOR ) | |
| printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_ACCELERATOR"); | |
| if( type & CL_DEVICE_TYPE_DEFAULT ) | |
| printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_DEFAULT"); | |
| // CL_DEVICE_MAX_COMPUTE_UNITS | |
| cl_uint compute_units; | |
| clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(compute_units), &compute_units, NULL); | |
| printf(" CL_DEVICE_MAX_COMPUTE_UNITS:\t\t%u\n", compute_units); | |
| // CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS | |
| size_t workitem_dims; | |
| clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(workitem_dims), &workitem_dims, NULL); | |
| printf(" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%u\n", workitem_dims); | |
| // CL_DEVICE_MAX_WORK_ITEM_SIZES | |
| size_t workitem_size[3]; | |
| clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(workitem_size), &workitem_size, NULL); | |
| printf(" CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%u / %u / %u \n", workitem_size[0], workitem_size[1], workitem_size[2]); | |
| // CL_DEVICE_MAX_WORK_GROUP_SIZE | |
| size_t workgroup_size; | |
| clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(workgroup_size), &workgroup_size, NULL); | |
| printf(" CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%u\n", workgroup_size); | |
| // CL_DEVICE_MAX_CLOCK_FREQUENCY | |
| cl_uint clock_frequency; | |
| clGetDeviceInfo(device, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(clock_frequency), &clock_frequency, NULL); | |
| printf(" CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%u MHz\n", clock_frequency); | |
| // CL_DEVICE_ADDRESS_BITS | |
| cl_uint addr_bits; | |
| clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS, sizeof(addr_bits), &addr_bits, NULL); | |
| printf(" CL_DEVICE_ADDRESS_BITS:\t\t%u\n", addr_bits); | |
| // CL_DEVICE_MAX_MEM_ALLOC_SIZE | |
| cl_ulong max_mem_alloc_size; | |
| clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(max_mem_alloc_size), &max_mem_alloc_size, NULL); | |
| printf(" CL_DEVICE_MAX_MEM_ALLOC_SIZE:\t\t%u MByte\n", (unsigned int)(max_mem_alloc_size / (1024 * 1024))); | |
| // CL_DEVICE_GLOBAL_MEM_SIZE | |
| cl_ulong mem_size; | |
| clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(mem_size), &mem_size, NULL); | |
| printf(" CL_DEVICE_GLOBAL_MEM_SIZE:\t\t%u MByte\n", (unsigned int)(mem_size / (1024 * 1024))); | |
| // CL_DEVICE_ERROR_CORRECTION_SUPPORT | |
| cl_bool error_correction_support; | |
| clGetDeviceInfo(device, CL_DEVICE_ERROR_CORRECTION_SUPPORT, sizeof(error_correction_support), &error_correction_support, NULL); | |
| printf(" CL_DEVICE_ERROR_CORRECTION_SUPPORT:\t%s\n", error_correction_support == CL_TRUE ? "yes" : "no"); | |
| // CL_DEVICE_LOCAL_MEM_TYPE | |
| cl_device_local_mem_type local_mem_type; | |
| clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_TYPE, sizeof(local_mem_type), &local_mem_type, NULL); | |
| printf(" CL_DEVICE_LOCAL_MEM_TYPE:\t\t%s\n", local_mem_type == 1 ? "local" : "global"); | |
| // CL_DEVICE_LOCAL_MEM_SIZE | |
| clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(mem_size), &mem_size, NULL); | |
| printf(" CL_DEVICE_LOCAL_MEM_SIZE:\t\t%u KByte\n", (unsigned int)(mem_size / 1024)); | |
| // CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE | |
| clGetDeviceInfo(device, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, sizeof(mem_size), &mem_size, NULL); | |
| printf(" CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t%u KByte\n", (unsigned int)(mem_size / 1024)); | |
| // CL_DEVICE_QUEUE_PROPERTIES | |
| cl_command_queue_properties queue_properties; | |
| clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES, sizeof(queue_properties), &queue_properties, NULL); | |
| if( queue_properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ) | |
| printf(" CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE"); | |
| if( queue_properties & CL_QUEUE_PROFILING_ENABLE ) | |
| printf(" CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_PROFILING_ENABLE"); | |
| // CL_DEVICE_IMAGE_SUPPORT | |
| cl_bool image_support; | |
| clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, sizeof(image_support), &image_support, NULL); | |
| printf(" CL_DEVICE_IMAGE_SUPPORT:\t\t%u\n", image_support); | |
| // CL_DEVICE_MAX_READ_IMAGE_ARGS | |
| cl_uint max_read_image_args; | |
| clGetDeviceInfo(device, CL_DEVICE_MAX_READ_IMAGE_ARGS, sizeof(max_read_image_args), &max_read_image_args, NULL); | |
| printf(" CL_DEVICE_MAX_READ_IMAGE_ARGS:\t%u\n", max_read_image_args); | |
| // CL_DEVICE_MAX_WRITE_IMAGE_ARGS | |
| cl_uint max_write_image_args; | |
| clGetDeviceInfo(device, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, sizeof(max_write_image_args), &max_write_image_args, NULL); | |
| printf(" CL_DEVICE_MAX_WRITE_IMAGE_ARGS:\t%u\n", max_write_image_args); | |
| // CL_DEVICE_IMAGE2D_MAX_WIDTH, CL_DEVICE_IMAGE2D_MAX_HEIGHT, CL_DEVICE_IMAGE3D_MAX_WIDTH, CL_DEVICE_IMAGE3D_MAX_HEIGHT, CL_DEVICE_IMAGE3D_MAX_DEPTH | |
| size_t szMaxDims[5]; | |
| printf("\n CL_DEVICE_IMAGE <dim>"); | |
| clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof(size_t), &szMaxDims[0], NULL); | |
| printf("\t\t\t2D_MAX_WIDTH\t %u\n", szMaxDims[0]); | |
| clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof(size_t), &szMaxDims[1], NULL); | |
| printf("\t\t\t\t\t2D_MAX_HEIGHT\t %u\n", szMaxDims[1]); | |
| clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof(size_t), &szMaxDims[2], NULL); | |
| printf("\t\t\t\t\t3D_MAX_WIDTH\t %u\n", szMaxDims[2]); | |
| clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof(size_t), &szMaxDims[3], NULL); | |
| printf("\t\t\t\t\t3D_MAX_HEIGHT\t %u\n", szMaxDims[3]); | |
| clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof(size_t), &szMaxDims[4], NULL); | |
| printf("\t\t\t\t\t3D_MAX_DEPTH\t %u\n", szMaxDims[4]); | |
| // CL_DEVICE_PREFERRED_VECTOR_WIDTH_<type> | |
| printf(" CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t>\t"); | |
| cl_uint vec_width [6]; | |
| clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, sizeof(cl_uint), &vec_width[0], NULL); | |
| clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, sizeof(cl_uint), &vec_width[1], NULL); | |
| clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, sizeof(cl_uint), &vec_width[2], NULL); | |
| clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, sizeof(cl_uint), &vec_width[3], NULL); | |
| clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, sizeof(cl_uint), &vec_width[4], NULL); | |
| clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, sizeof(cl_uint), &vec_width[5], NULL); | |
| printf("CHAR %u, SHORT %u, INT %u, FLOAT %u, DOUBLE %u\n\n\n", | |
| vec_width[0], vec_width[1], vec_width[2], vec_width[3], vec_width[4]); | |
| } | |
| int main(int argc, const char** argv) { | |
| // start logs | |
| printf("clDeviceQuery Starting...\n\n"); | |
| bool bPassed = true; | |
| std::string sProfileString = "clDeviceQuery, Platform Name = "; | |
| // Get OpenCL platform ID for NVIDIA if avaiable, otherwise default | |
| char cBuffer[1024]; | |
| cl_platform_id clSelectedPlatformID = NULL; | |
| cl_platform_id* clPlatformIDs; | |
| cl_uint num_platforms; | |
| cl_int ciErrNum = clGetPlatformIDs(0, NULL, &num_platforms); | |
| if (ciErrNum != CL_SUCCESS) { | |
| printf(" Error %i in clGetPlatformIDs Call!\n\n", ciErrNum); | |
| bPassed = false; | |
| } else { | |
| if (num_platforms == 0) { | |
| printf("No OpenCL platform found!\n\n"); | |
| bPassed = false; | |
| } else { | |
| // if there's one platform or more, make space for ID's | |
| if ((clPlatformIDs = (cl_platform_id*)malloc(num_platforms * sizeof(cl_platform_id))) == NULL) { | |
| printf("Failed to allocate memory for cl_platform ID's!\n\n"); | |
| bPassed = false; | |
| } | |
| printf("%d OpenCL Platforms found\n\n", num_platforms); | |
| // get platform info for each platform | |
| ciErrNum = clGetPlatformIDs (num_platforms, clPlatformIDs, NULL); | |
| for(cl_uint i = 0; i < num_platforms; ++i) { | |
| ciErrNum = clGetPlatformInfo (clPlatformIDs[i], CL_PLATFORM_NAME, 1024, &cBuffer, NULL); | |
| if(ciErrNum == CL_SUCCESS) { | |
| clSelectedPlatformID = clPlatformIDs[i]; | |
| // Get OpenCL platform name and version | |
| ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL); | |
| if (ciErrNum == CL_SUCCESS) { | |
| printf(" CL_PLATFORM_NAME: \t%s\n", cBuffer); | |
| sProfileString += cBuffer; | |
| } else { | |
| printf(" Error %i in clGetPlatformInfo Call !!!\n\n", ciErrNum); | |
| bPassed = false; | |
| } | |
| sProfileString += ", Platform Version = "; | |
| ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_VERSION, sizeof(cBuffer), cBuffer, NULL); | |
| if (ciErrNum == CL_SUCCESS) { | |
| printf(" CL_PLATFORM_VERSION: \t%s\n", cBuffer); | |
| sProfileString += cBuffer; | |
| } else { | |
| printf(" Error %i in clGetPlatformInfo Call !!!\n\n", ciErrNum); | |
| bPassed = false; | |
| } | |
| // Log OpenCL SDK Version # (for convenience: not specific to OpenCL) | |
| sProfileString += ", NumDevs = "; | |
| // Get and log OpenCL device info | |
| cl_uint ciDeviceCount; | |
| cl_device_id *devices; | |
| printf("OpenCL Device Info:\n\n"); | |
| ciErrNum = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL, 0, NULL, &ciDeviceCount); | |
| // check for 0 devices found or errors... | |
| if (ciDeviceCount == 0) { | |
| printf(" No devices found supporting OpenCL (return code %i)\n\n", ciErrNum); | |
| bPassed = false; | |
| sProfileString += "0"; | |
| } else if (ciErrNum != CL_SUCCESS) { | |
| printf(" Error %i in clGetDeviceIDs call !!!\n\n", ciErrNum); | |
| bPassed = false; | |
| } else { | |
| // Get and log the OpenCL device ID's | |
| ciErrNum = clGetPlatformInfo (clSelectedPlatformID, CL_PLATFORM_NAME, sizeof(cBuffer), cBuffer, NULL); | |
| printf(" %u devices found supporting OpenCL on: %s\n\n", ciDeviceCount, cBuffer); | |
| char cTemp[2]; | |
| sprintf(cTemp, "%u", ciDeviceCount); | |
| sProfileString += cTemp; | |
| if ((devices = (cl_device_id*)malloc(sizeof(cl_device_id) * ciDeviceCount)) == NULL) { | |
| printf(" Failed to allocate memory for devices !!!\n\n"); | |
| bPassed = false; | |
| } | |
| ciErrNum = clGetDeviceIDs (clSelectedPlatformID, CL_DEVICE_TYPE_ALL, ciDeviceCount, devices, &ciDeviceCount); | |
| if (ciErrNum == CL_SUCCESS) { | |
| for(unsigned int i = 0; i < ciDeviceCount; ++i ) { | |
| printf(" ----------------------------------\n"); | |
| clGetDeviceInfo(devices[i], CL_DEVICE_NAME, sizeof(cBuffer), &cBuffer, NULL); | |
| printf(" Device %s\n", cBuffer); | |
| printf(" ---------------------------------\n"); | |
| clPrintDevInfo(devices[i]); | |
| sProfileString += ", Device = "; | |
| sProfileString += cBuffer; | |
| } | |
| } else { | |
| printf(" Error %i in clGetDeviceIDs call !!!\n\n", ciErrNum); | |
| bPassed = false; | |
| } | |
| } | |
| // masterlog info | |
| sProfileString += "\n"; | |
| printf("%s", sProfileString.c_str()); | |
| } | |
| //free(clPlatformIDs); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment