Skip to content

Instantly share code, notes, and snippets.

@cosmo0920
Created August 8, 2012 13:01
Show Gist options
  • Save cosmo0920/3294909 to your computer and use it in GitHub Desktop.
Save cosmo0920/3294909 to your computer and use it in GitHub Desktop.
Control.Parallel.OpenCLでOpenCLの情報を取得
import Control.Parallel.OpenCL
import Distribution.System (buildOS, OS(..))
-- clDeviceCheck
clDeviceCheck :: IO ()
clDeviceCheck = do
platforms <- clGetPlatformIDs
clDevices platforms
clDevices platforms = do
(platform:_) <- clGetPlatformIDs
devs <- clGetDeviceIDs platform CL_DEVICE_TYPE_ALL
mapM_ clDeviceCheck' devs
(_:platform) <- clGetPlatformIDs
devs <- clGetDeviceIDs (head platform) CL_DEVICE_TYPE_ALL
mapM_ clDeviceCheck' devs
clDeviceCheck' :: CLDeviceID -> IO ()
clDeviceCheck' dev = do
cl_e <- clGetDeviceExtensions dev
cl_t <- clGetDeviceType dev
cl_ven <- clGetDeviceVendor dev
cl_venid <- clGetDeviceVendorID dev
cl_driver <- clGetDeviceDriverVersion dev
cl_name <- clGetDeviceName dev
cl_v <- clGetDeviceVersion dev
cl_p <- clGetDeviceProfile dev
cl_maxunit <- clGetDeviceMaxComputeUnits dev
cl_freq <- clGetDeviceMaxClockFrequency dev
cl_gmem_t <- clGetDeviceGlobalMemCacheType dev
cl_gmem_s <- clGetDeviceGlobalMemSize dev
cl_mem_cache <- clGetDeviceGlobalMemCachelineSize dev
cl_dim <- clGetDeviceMaxWorkItemDimensions dev
cl_work <- clGetDeviceMaxWorkGroupSize dev
cl_item <- clGetDeviceMaxWorkItemSizes dev
cl_res <- clGetDeviceProfilingTimerResolution dev
cl_maxmem <- clGetDeviceMaxMemAllocSize dev
cl_const_buffer <- clGetDeviceMaxConstantBufferSize dev
cl_img <- clGetDeviceImageSupport dev
cl_double <- clGetDeviceDoubleFPConfig dev
cl_single <- clGetDeviceSingleFPConfig dev
cl_capable <- clGetDeviceExecutionCapabilities dev
putStrLn $ unlines $
[ "Device Id: " ++ show dev
, "Device Info: " ++ cl_e
, "Device Type: " ++ show cl_t
, "Device Vendor: " ++ cl_ven
, "Vendor ID: " ++ show cl_venid
, "Device Driver Version: " ++ cl_driver
, "Device Name: " ++ cl_name
, "Device Version: " ++ cl_v
, "Device Profile: " ++ cl_p
, "Max unit: " ++ show cl_maxunit
, "Max clock frequency: " ++ show cl_freq
, "Global Memory Cache Type : " ++ show cl_gmem_t
, "Global Memory Size: " ++ show cl_gmem_s
, "Global Memory Cacheline Size: " ++ show cl_mem_cache
, "Max dimension: " ++ show cl_dim
, "Max work group size: " ++ show cl_work
, "Max Work Item: " ++ show cl_item
, "CL timer resolution: " ++ show cl_res
, "Max alloc Memory size: " ++ show cl_maxmem
, "Max constant buffer size: " ++ show cl_const_buffer
, "Device image Support: " ++ show cl_img
, "Double precision floating point: " ++ show cl_double
, "Single precision floating point: " ++ show cl_single
, "Device capability: " ++ show cl_capable]
main :: IO ()
main = clDeviceCheck
% ./getCLDeviceInfo
Device Id: 0x0000000001459170
Device Info: cl_khr_fp64 cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_intel_printf cl_ext_device_fission cl_intel_exec_by_local_thread
Device Type: [CL_DEVICE_TYPE_CPU]
Device Vendor: Intel(R) Corporation
Vendor ID: 32902
Device Driver Version: 1.1
Device Name: Intel(R) Core(TM) i3 CPU 560 @ 3.33GHz
Device Version: OpenCL 1.1 (Build 31360.31426)
Device Profile: FULL_PROFILE
Max unit: 4
Max clock frequency: 3330
Global Memory Cache Type : CL_READ_WRITE_CACHE
Global Memory Size: 8365244416
Global Memory Cacheline Size: 64
Max dimension: 3
Max work group size: 1024
Max Work Item: [1024,1024,1024]
CL timer resolution: 1
Max alloc Memory size: 2091311104
Max constant buffer size: 131072
Device image Support: True
Double precision floating point: [CL_FP_DENORM,CL_FP_INF_NAN,CL_FP_ROUND_TO_NEAREST,CL_FP_ROUND_TO_ZERO,CL_FP_ROUND_TO_INF,CL_FP_FMA]
Single precision floating point: [CL_FP_DENORM,CL_FP_INF_NAN,CL_FP_ROUND_TO_NEAREST]
Device capability: [CL_EXEC_KERNEL,CL_EXEC_NATIVE_KERNEL]
Device Id: 0x0000000001465790
Device Info: cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64
Device Type: [CL_DEVICE_TYPE_GPU]
Device Vendor: NVIDIA Corporation
Vendor ID: 4318
Device Driver Version: 304.37
Device Name: GeForce GTX 550 Ti
Device Version: OpenCL 1.1 CUDA
Device Profile: FULL_PROFILE
Max unit: 4
Max clock frequency: 1800
Global Memory Cache Type : CL_READ_WRITE_CACHE
Global Memory Size: 1073610752
Global Memory Cacheline Size: 128
Max dimension: 3
Max work group size: 1024
Max Work Item: [1024,1024,64]
CL timer resolution: 1000
Max alloc Memory size: 268402688
Max constant buffer size: 65536
Device image Support: True
Double precision floating point: [CL_FP_DENORM,CL_FP_INF_NAN,CL_FP_ROUND_TO_NEAREST,CL_FP_ROUND_TO_ZERO,CL_FP_ROUND_TO_INF,CL_FP_FMA]
Single precision floating point: [CL_FP_DENORM,CL_FP_INF_NAN,CL_FP_ROUND_TO_NEAREST,CL_FP_ROUND_TO_ZERO,CL_FP_ROUND_TO_INF,CL_FP_FMA]
Device capability: [CL_EXEC_KERNEL]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment