Contents
Introduction
OpenCL is a way to use the GPU in some graphics cards for additional general-purpose processing. Support was committed for OpenCL in FreeBSD Ports in revision r397198
Architecture
OpenCL providers on FreeBSD are installed as "ocl-icd" modules. ocl-icd stands for "OpenCL - Installable Client Driver". This provides a flexible setup, not locking consuming software into using a specific OpenCL implementation, and theoretically allowing more than one provider to be used at the same time. On the other hand, users must choose and install the OpenCL providers they wish to use.
OpenCL Providers
The following OpenCL Providers are available:
Clover: Mesa's OpenCL implementation, targeting all Gallium drivers, only Radeon GPUs in our case.
IntelĀ® Graphics Compute Runtime: For Intel GPU's, Ivy Bridge and later (intel-compute-runtime GitHub Repository)
PortableCL (pocl): A software (CPU) OpenCL implementation.
There is also the information utility, clinfo, which can be compared with glxinfo but for OpenCL. You can benchmark your OpenCL device computational efficiency using clpeak utility.
Notes:
- For either Beignet or Clover to work, a graphics card supported by the kernel KMS drivers is needed.
- Beignet does not support Sandy Bridge class GPUs, only Ivy Bridge and higher.
Related OpenCL Ports
Port |
Notes |
devel/clinfo |
glxinfo-like program for OpenCL |
devel/ocl-icd |
OpenCL - Installable Client Driver library |
benchmarks/clpeak |
Benchmarking tool to measure peak capabilities of opencl devices |
lang/clover |
OpenCL driver for Radeon GPUs |
lang/intel-compute-runtime |
OpenCL driver for Intel GPUs |
lang/pocl |
Another OpenCL driver that uses the CPU for computations |
Examples
Below are Clover and Intel-Compute-Runtime utilities example outputs.
Clover
> uname -a FreeBSD magellan.dumbbell.fr 11.0-CURRENT FreeBSD 11.0-CURRENT #0 67cdc8d(kms-drm-update-38): Thu Feb 5 09:39:28 CET 2015 root@magellan.dumbbell.fr:/usr/obj/home/dumbbell/Projects/freebsd/src/GIT/sys/GENERIC amd64 drmn0: <ATI Mobility Radeon HD 5870> on vgapci0 info: [drm] initializing kernel modesetting (JUNIPER 0x1002:0x68A0 0x1558:0x8687). drmn0: info: VRAM: 1024M 0x0000000000000000 - 0x000000003FFFFFFF (1024M used) drmn0: info: GTT: 512M 0x0000000040000000 - 0x000000005FFFFFFF > clinfo Number of platforms 1 Platform Name Clover Platform Vendor Mesa Platform Version OpenCL 1.1 MESA 10.4.3 Platform Profile FULL_PROFILE Platform Extensions cl_khr_icd Platform Extensions function suffix MESA Platform Name Clover Number of devices 1 Device Name AMD JUNIPER Device Vendor X.Org Device Vendor ID 0x1002 Device Version OpenCL 1.1 MESA 10.4.3 Driver Version 10.4.3 Device OpenCL C Version OpenCL C 1.1 Device Type GPU Device Profile FULL_PROFILE Max compute units 1 Max clock frequency 0MHz Max work item dimensions 3 Max work item sizes 256x256x256 Max work group size 256 Preferred work group size multiple 1 Preferred / native vector sizes char 16 / 16 short 8 / 8 int 4 / 4 long 2 / 2 half 0 / 0 (n/a) float 4 / 4 double 2 / 2 (n/a) Half-precision Floating-point support (n/a) Single-precision Floating-point support (core) Denormals Yes Infinity and NANs Yes Round to nearest Yes Round to zero No Round to infinity No IEEE754-2008 fused multiply-add No Support is emulated in software No Correctly-rounded divide and sqrt operations No Double-precision Floating-point support (n/a) Address bits 32, Little-Endian Global memory size 1073741824 (1024MiB) Error Correction support No Max memory allocation 268435456 (256MiB) Unified memory for Host and Device Yes Minimum alignment for any data type 128 bytes Alignment of base address 128 bits (16 bytes) Global Memory cache type None Image support No Local memory type Local Local memory size 32768 (32KiB) Max constant buffer size 268435456 (256MiB) Max number of constant args 13 Max size of kernel argument 1024 Queue properties Out-of-order execution No Profiling Yes Profiling timer resolution 0ns Execution capabilities Run OpenCL kernels Yes Run native kernels No Device Available Yes Compiler Available Yes Device Extensions NULL platform behavior clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) Clover clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [MESA] clCreateContext(NULL, ...) [default] Success [MESA] clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1) Platform Name Clover Device Name AMD JUNIPER clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (1) Platform Name Clover Device Name AMD JUNIPER ICD loader properties ICD loader Name OpenCL ICD Loader ICD loader Vendor OCL Icd free software ICD loader Version 2.2.3 ICD loader Profile OpenCL 1.2
Intel-Compute-Runtime
# uname -a FreeBSD 12.2-RELEASE-p1 FreeBSD 12.2-RELEASE-p1 GENERIC amd64 # dmesg | grep drm drmn0: <drmn> on vgapci0 vgapci0: child drmn0 requested pci_enable_io vgapci0: child drmn0 requested pci_enable_io [drm] Unable to create a private tmpfs mount, hugepage support will be disabled(-19). [drm] Got stolen memory base 0xde000000, size 0x2000000 [drm] Supports vblank timestamp caching Rev 2 (21.10.2013). [drm] Driver supports precise vblank timestamp query. [drm] Connector eDP-1: get mode from tunables: [drm] - kern.vt.fb.modes.eDP-1 [drm] - kern.vt.fb.default_mode [drm] Connector HDMI-A-1: get mode from tunables: [drm] - kern.vt.fb.modes.HDMI-A-1 [drm] - kern.vt.fb.default_mode [drm] Connector DP-1: get mode from tunables: [drm] - kern.vt.fb.modes.DP-1 [drm] - kern.vt.fb.default_mode [drm] Initialized i915 1.6.0 20171222 for drmn0 on minor 0 name=drmn0 flags=0x0 stride=10240 bpp=32 drmn0: fb0: inteldrmfb frame buffer device # pkg info -x drm drm-fbsd12.0-kmod-4.16.g20201016 drm-kmod-g20190710 drm_info-2.2.0_1 libdrm-2.4.103,1 linux-c7-libdrm-2.4.91 # clinfo Number of platforms 1 Platform Name Intel(R) OpenCL HD Graphics Platform Vendor Intel(R) Corporation Platform Version OpenCL 3.0 Platform Numeric Version 0xc00000 (3.0.0) Platform Profile FULL_PROFILE Platform Extensions cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_intel_subgroups cl_intel_required_subgroup_size cl_intel_subgroups_short cl_khr_spir cl_intel_accelerator cl_intel_driver_diagnostics cl_khr_priority_hints cl_khr_throttle_hints cl_khr_create_command_queue cl_intel_subgroups_char cl_intel_subgroups_long cl_khr_il_program cl_intel_mem_force_host_memory cl_khr_subgroup_extended_types cl_khr_subgroup_non_uniform_vote cl_khr_subgroup_ballot cl_khr_subgroup_non_uniform_arithmetic cl_khr_subgroup_shuffle cl_khr_subgroup_shuffle_relative cl_khr_subgroup_clustered_reduce cl_khr_fp64 cl_khr_subgroups cl_intel_spirv_media_block_io cl_intel_spirv_subgroups cl_khr_spirv_no_integer_wrap_decoration cl_intel_unified_shared_memory_preview cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_intel_planar_yuv cl_intel_packed_yuv cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_3d_image_writes cl_intel_media_block_io cl_intel_va_api_media_sharing Platform Extensions with Version cl_khr_byte_addressable_store 0x400000 (1.0.0) cl_khr_fp16 0x400000 (1.0.0) cl_khr_global_int32_base_atomics 0x400000 (1.0.0) cl_khr_global_int32_extended_atomics 0x400000 (1.0.0) cl_khr_icd 0x400000 (1.0.0) cl_khr_local_int32_base_atomics 0x400000 (1.0.0) cl_khr_local_int32_extended_atomics 0x400000 (1.0.0) cl_intel_subgroups 0x400000 (1.0.0) cl_intel_required_subgroup_size 0x400000 (1.0.0) cl_intel_subgroups_short 0x400000 (1.0.0) cl_khr_spir 0x400000 (1.0.0) cl_intel_accelerator 0x400000 (1.0.0) cl_intel_driver_diagnostics 0x400000 (1.0.0) cl_khr_priority_hints 0x400000 (1.0.0) cl_khr_throttle_hints 0x400000 (1.0.0) cl_khr_create_command_queue 0x400000 (1.0.0) cl_intel_subgroups_char 0x400000 (1.0.0) cl_intel_subgroups_long 0x400000 (1.0.0) cl_khr_il_program 0x400000 (1.0.0) cl_intel_mem_force_host_memory 0x400000 (1.0.0) cl_khr_subgroup_extended_types 0x400000 (1.0.0) cl_khr_subgroup_non_uniform_vote 0x400000 (1.0.0) cl_khr_subgroup_ballot 0x400000 (1.0.0) cl_khr_subgroup_non_uniform_arithmetic 0x400000 (1.0.0) cl_khr_subgroup_shuffle 0x400000 (1.0.0) cl_khr_subgroup_shuffle_relative 0x400000 (1.0.0) cl_khr_subgroup_clustered_reduce 0x400000 (1.0.0) cl_khr_fp64 0x400000 (1.0.0) cl_khr_subgroups 0x400000 (1.0.0) cl_intel_spirv_media_block_io 0x400000 (1.0.0) cl_intel_spirv_subgroups 0x400000 (1.0.0) cl_khr_spirv_no_integer_wrap_decoration 0x400000 (1.0.0) cl_intel_unified_shared_memory_preview 0x400000 (1.0.0) cl_khr_mipmap_image 0x400000 (1.0.0) cl_khr_mipmap_image_writes 0x400000 (1.0.0) cl_intel_planar_yuv 0x400000 (1.0.0) cl_intel_packed_yuv 0x400000 (1.0.0) cl_khr_int64_base_atomics 0x400000 (1.0.0) cl_khr_int64_extended_atomics 0x400000 (1.0.0) cl_khr_image2d_from_buffer 0x400000 (1.0.0) cl_khr_depth_images 0x400000 (1.0.0) cl_khr_3d_image_writes 0x400000 (1.0.0) cl_intel_media_block_io 0x400000 (1.0.0) cl_intel_va_api_media_sharing 0x400000 (1.0.0) Platform Host timer resolution 1ns Platform Extensions function suffix INTEL Platform Name Intel(R) OpenCL HD Graphics Number of devices 1 Device Name Intel(R) Graphics [0x1616] Device Vendor Intel(R) Corporation Device Vendor ID 0x8086 Device Version OpenCL 3.0 NEO Device Numeric Version 0xc00000 (3.0.0) Driver Version 21.02.18820 Device OpenCL C Version OpenCL C 3.0 Device OpenCL C all versions OpenCL C 0x400000 (1.0.0) OpenCL C 0x401000 (1.1.0) OpenCL C 0x402000 (1.2.0) OpenCL C 0x800000 (2.0.0) OpenCL C 0xc00000 (3.0.0) Device OpenCL C features __opencl_c_int64 0xc00000 (3.0.0) __opencl_c_3d_image_writes 0xc00000 (3.0.0) __opencl_c_images 0xc00000 (3.0.0) __opencl_c_read_write_images 0xc00000 (3.0.0) __opencl_c_atomic_order_acq_rel 0xc00000 (3.0.0) __opencl_c_atomic_order_seq_cst 0xc00000 (3.0.0) __opencl_c_atomic_scope_all_devices 0xc00000 (3.0.0) __opencl_c_atomic_scope_device 0xc00000 (3.0.0) __opencl_c_generic_address_space 0xc00000 (3.0.0) __opencl_c_program_scope_global_variables 0xc00000 (3.0.0) __opencl_c_work_group_collective_functions 0xc00000 (3.0.0) __opencl_c_subgroups 0xc00000 (3.0.0) __opencl_c_device_enqueue 0xc00000 (3.0.0) __opencl_c_pipes 0xc00000 (3.0.0) __opencl_c_fp64 0xc00000 (3.0.0) Latest comfornace test passed v2020-11-23-00 Device Type GPU Device Profile FULL_PROFILE Device Available Yes Compiler Available Yes Linker Available Yes Max compute units 24 Max clock frequency 0MHz Device Partition (core) Max number of sub-devices 0 Supported partition types None Supported affinity domains (n/a) Max work item dimensions 3 Max work item sizes 256x256x256 Max work group size 256 Preferred work group size multiple (device) 32 Preferred work group size multiple (kernel) 32 Max sub-groups per work group 32 Sub-group sizes (Intel) 8, 16, 32 Preferred / native vector sizes char 16 / 16 short 8 / 8 int 4 / 4 long 1 / 1 half 8 / 8 (cl_khr_fp16) float 1 / 1 double 1 / 1 (cl_khr_fp64) Half-precision Floating-point support (cl_khr_fp16) Denormals Yes Infinity and NANs Yes Round to nearest Yes Round to zero Yes Round to infinity Yes IEEE754-2008 fused multiply-add Yes Support is emulated in software No Single-precision Floating-point support (core) Denormals Yes Infinity and NANs Yes Round to nearest Yes Round to zero Yes Round to infinity Yes IEEE754-2008 fused multiply-add Yes Support is emulated in software No Correctly-rounded divide and sqrt operations Yes Double-precision Floating-point support (cl_khr_fp64) Denormals Yes Infinity and NANs Yes Round to nearest Yes Round to zero Yes Round to infinity Yes IEEE754-2008 fused multiply-add Yes Support is emulated in software No Address bits 64, Little-Endian Global memory size 6747164672 (6.284GiB) Error Correction support No Max memory allocation 2139095040 (1.992GiB) Unified memory for Host and Device Yes Shared Virtual Memory (SVM) capabilities (core) Coarse-grained buffer sharing Yes Fine-grained buffer sharing No Fine-grained system sharing No Atomics No Minimum alignment for any data type 128 bytes Alignment of base address 1024 bits (128 bytes) Preferred alignment for atomics SVM 64 bytes Global 64 bytes Local 64 bytes Atomic memory capabilities relaxed, acquire/release, sequentially-consistent, work-group scope, device scope, all-devices scope Atomic fence capabilities relaxed, acquire/release, sequentially-consistent, work-item scope, work-group scope, device scope, all-devices scope Max size for global variable 65536 (64KiB) Preferred total size of global vars 2139095040 (1.992GiB) Global Memory cache type Read/Write Global Memory cache size 262144 (256KiB) Global Memory cache line size 64 bytes Image support Yes Max number of samplers per kernel 16 Max size for 1D images from buffer 133693440 pixels Max 1D or 2D image array size 2048 images Base address alignment for 2D image buffers 4 bytes Pitch alignment for 2D image buffers 4 pixels Max 2D image size 16384x16384 pixels Max planar YUV image size 16384x16352 pixels Max 3D image size 2048x2048x2048 pixels Max number of read image args 128 Max number of write image args 128 Max number of read/write image args 128 Pipe support Yes Max number of pipe args 16 Max active pipe reservations 1 Max pipe packet size 1024 Local memory type Local Local memory size 65536 (64KiB) Max number of constant args 8 Max constant buffer size 2139095040 (1.992GiB) Generic address space support Yes Max size of kernel argument 2048 (2KiB) Queue properties (on host) Out-of-order execution Yes Profiling Yes Device enqueue capabilities supported, replaceable default queue Queue properties (on device) Out-of-order execution Yes Profiling Yes Preferred size 131072 (128KiB) Max size 67108864 (64MiB) Max queues on device 1 Max events on device 1024 Prefer user sync for interop Yes Profiling timer resolution 80ns Execution capabilities Run OpenCL kernels Yes Run native kernels No Non-uniform work-groups Yes Work-group collective functions Yes Sub-group independent forward progress Yes IL version SPIR-V_1.2 ILs with version SPIR-V 0x402000 (1.2.0) SPIR versions 1.2 printf() buffer size 4194304 (4MiB) Built-in kernels (n/a) Built-in kernels with version (n/a) Device Extensions cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_intel_subgroups cl_intel_required_subgroup_size cl_intel_subgroups_short cl_khr_spir cl_intel_accelerator cl_intel_driver_diagnostics cl_khr_priority_hints cl_khr_throttle_hints cl_khr_create_command_queue cl_intel_subgroups_char cl_intel_subgroups_long cl_khr_il_program cl_intel_mem_force_host_memory cl_khr_subgroup_extended_types cl_khr_subgroup_non_uniform_vote cl_khr_subgroup_ballot cl_khr_subgroup_non_uniform_arithmetic cl_khr_subgroup_shuffle cl_khr_subgroup_shuffle_relative cl_khr_subgroup_clustered_reduce cl_khr_fp64 cl_khr_subgroups cl_intel_spirv_media_block_io cl_intel_spirv_subgroups cl_khr_spirv_no_integer_wrap_decoration cl_intel_unified_shared_memory_preview cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_intel_planar_yuv cl_intel_packed_yuv cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_3d_image_writes cl_intel_media_block_io cl_intel_va_api_media_sharing Device Extensions with Version cl_khr_byte_addressable_store 0x400000 (1.0.0) cl_khr_fp16 0x400000 (1.0.0) cl_khr_global_int32_base_atomics 0x400000 (1.0.0) cl_khr_global_int32_extended_atomics 0x400000 (1.0.0) cl_khr_icd 0x400000 (1.0.0) cl_khr_local_int32_base_atomics 0x400000 (1.0.0) cl_khr_local_int32_extended_atomics 0x400000 (1.0.0) cl_intel_subgroups 0x400000 (1.0.0) cl_intel_required_subgroup_size 0x400000 (1.0.0) cl_intel_subgroups_short 0x400000 (1.0.0) cl_khr_spir 0x400000 (1.0.0) cl_intel_accelerator 0x400000 (1.0.0) cl_intel_driver_diagnostics 0x400000 (1.0.0) cl_khr_priority_hints 0x400000 (1.0.0) cl_khr_throttle_hints 0x400000 (1.0.0) cl_khr_create_command_queue 0x400000 (1.0.0) cl_intel_subgroups_char 0x400000 (1.0.0) cl_intel_subgroups_long 0x400000 (1.0.0) cl_khr_il_program 0x400000 (1.0.0) cl_intel_mem_force_host_memory 0x400000 (1.0.0) cl_khr_subgroup_extended_types 0x400000 (1.0.0) cl_khr_subgroup_non_uniform_vote 0x400000 (1.0.0) cl_khr_subgroup_ballot 0x400000 (1.0.0) cl_khr_subgroup_non_uniform_arithmetic 0x400000 (1.0.0) cl_khr_subgroup_shuffle 0x400000 (1.0.0) cl_khr_subgroup_shuffle_relative 0x400000 (1.0.0) cl_khr_subgroup_clustered_reduce 0x400000 (1.0.0) cl_khr_fp64 0x400000 (1.0.0) cl_khr_subgroups 0x400000 (1.0.0) cl_intel_spirv_media_block_io 0x400000 (1.0.0) cl_intel_spirv_subgroups 0x400000 (1.0.0) cl_khr_spirv_no_integer_wrap_decoration 0x400000 (1.0.0) cl_intel_unified_shared_memory_preview 0x400000 (1.0.0) cl_khr_mipmap_image 0x400000 (1.0.0) cl_khr_mipmap_image_writes 0x400000 (1.0.0) cl_intel_planar_yuv 0x400000 (1.0.0) cl_intel_packed_yuv 0x400000 (1.0.0) cl_khr_int64_base_atomics 0x400000 (1.0.0) cl_khr_int64_extended_atomics 0x400000 (1.0.0) cl_khr_image2d_from_buffer 0x400000 (1.0.0) cl_khr_depth_images 0x400000 (1.0.0) cl_khr_3d_image_writes 0x400000 (1.0.0) cl_intel_media_block_io 0x400000 (1.0.0) cl_intel_va_api_media_sharing 0x400000 (1.0.0) NULL platform behavior clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) Intel(R) OpenCL HD Graphics clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [INTEL] clCreateContext(NULL, ...) [default] Success [INTEL] clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) Success (1) Platform Name Intel(R) OpenCL HD Graphics Device Name Intel(R) Graphics [0x1616] clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1) Platform Name Intel(R) OpenCL HD Graphics Device Name Intel(R) Graphics [0x1616] clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (1) Platform Name Intel(R) OpenCL HD Graphics Device Name Intel(R) Graphics [0x1616] ICD loader properties ICD loader Name OpenCL ICD Loader ICD loader Vendor OCL Icd free software ICD loader Version 2.2.13 ICD loader Profile OpenCL 3.0 # clpeak Platform: Intel(R) OpenCL HD Graphics Device: Intel(R) Graphics [0x1616] Driver version : 21.02.18820 (FreeBSD) Compute units : 24 Clock frequency : 0 MHz Global memory bandwidth (GBPS) float : 12.23 float2 : 15.00 float4 : 15.58 float8 : 15.34 float16 : 14.01 Single-precision compute (GFLOPS) float : 257.06 float2 : 258.25 float4 : 259.26 float8 : 240.18 float16 : 252.49 Half-precision compute (GFLOPS) half : 259.30 half2 : 251.59 half4 : 257.62 half8 : 239.43 half16 : 251.78 Double-precision compute (GFLOPS) double : 69.22 double2 : 68.70 double4 : 67.88 double8 : 68.08 double16 : 64.21 Integer compute (GIOPS) int : 73.58 int2 : 74.52 int4 : 80.22 int8 : 78.41 int16 : 81.11 Transfer bandwidth (GBPS) enqueueWriteBuffer : 4.24 enqueueReadBuffer : 5.36 enqueueMapBuffer(for read) : 21738.77 memcpy from mapped ptr : 4.70 enqueueUnmap(after write) : 1069547.50 memcpy to mapped ptr : 5.41 Kernel launch latency : 73.42 us