Macos Mac上的-lOpenCL是什么?
我试图Macos Mac上的-lOpenCL是什么?,macos,gcc,makefile,opencl,Macos,Gcc,Makefile,Opencl,我试图制作一个OpenCL演示程序,它使用的是gcc。-lOpenCL适用于Ubuntu,但不适用于Mac。Mac上的对应物是什么 ld: library not found for -lOpenCL 我的iMac上有以下代码: #include <stdio.h> #include <stdlib.h> #include <OpenCL/opencl.h> int main(int argc, char* const argv[]) { cl_u
制作一个OpenCL演示程序,它使用的是gcc
。-lOpenCL
适用于Ubuntu,但不适用于Mac。Mac上的对应物是什么
ld: library not found for -lOpenCL
我的iMac上有以下代码:
#include <stdio.h>
#include <stdlib.h>
#include <OpenCL/opencl.h>
int main(int argc, char* const argv[]) {
cl_uint num_devices, i;
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices);
cl_device_id* devices = calloc(sizeof(cl_device_id), num_devices);
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, num_devices, devices, NULL);
char buf[128];
for (i = 0; i < num_devices; i++) {
clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 128, buf, NULL);
fprintf(stdout, "Device %s supports ", buf);
clGetDeviceInfo(devices[i], CL_DEVICE_VERSION, 128, buf, NULL);
fprintf(stdout, "%s\n", buf);
}
free(devices);
}
运行时,给出:
Device Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz supports OpenCL 1.2
Device AMD Radeon R9 M395 Compute Engine supports OpenCL 1.2
如果您正在试验OpenCL,我还使用了自制来安装clinfo
,即
brew install clinfo
当运行时,会给出:
Number of platforms 1
Platform Name Apple
Platform Vendor Apple
Platform Version OpenCL 1.2 (Mar 15 2018 21:59:37)
Platform Profile FULL_PROFILE
Platform Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event
Platform Name Apple
Number of devices 2
Device Name Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
Device Vendor Intel
Device Vendor ID 0xffffffff
Device Version OpenCL 1.2
Driver Version 1.1
Device OpenCL C Version OpenCL C 1.2
Device Type CPU
Device Profile FULL_PROFILE
Device Available Yes
Compiler Available Yes
Linker Available Yes
Max compute units 8
Max clock frequency 4000MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Max work item dimensions 3
Max work item sizes 1024x1x1
Max work group size 1024
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 (cl_khr_fp64)
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 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 34359738368 (32GiB)
Error Correction support No
Max memory allocation 8589934592 (8GiB)
Unified memory for Host and Device Yes
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Global Memory cache type Read/Write
Global Memory cache size 64
Global Memory cache line size 8388608 bytes
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 65536 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 1 bytes
Pitch alignment for 2D image buffers 1 pixels
Max 2D image size 8192x8192 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 128
Max number of write image args 8
Local memory type Global
Local memory size 32768 (32KiB)
Max number of constant args 8
Max constant buffer size 65536 (64KiB)
Max size of kernel argument 4096 (4KiB)
Queue properties
Out-of-order execution No
Profiling Yes
Prefer user sync for interop Yes
Profiling timer resolution 1ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels Yes
printf() buffer size 1048576 (1024KiB)
Built-in kernels
Device Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event cl_khr_fp64 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_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_APPLE_fp64_basic_ops cl_APPLE_fixed_alpha_channel_orders cl_APPLE_biased_fixed_point_image_formats cl_APPLE_command_queue_priority
Device Name AMD Radeon R9 M395 Compute Engine
Device Vendor AMD
Device Vendor ID 0x1021c00
Device Version OpenCL 1.2
Driver Version 1.2 (Mar 15 2018 21:59:57)
Device OpenCL C Version OpenCL C 1.2
Device Type GPU
Device Profile FULL_PROFILE
Device Available Yes
Compiler Available Yes
Linker Available Yes
Max compute units 28
Max clock frequency 834MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Max work item dimensions 3
Max work item sizes 256x256x256
Max work group size 256
Preferred work group size multiple 64
Preferred / native vector sizes
char 4 / 4
short 2 / 2
int 1 / 1
long 1 / 1
half 0 / 0 (n/a)
float 1 / 1
double 1 / 1 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals No
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add No
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 32, Little-Endian
Global memory size 2147483648 (2GiB)
Error Correction support No
Max memory allocation 536870912 (512MiB)
Unified memory for Host and Device No
Minimum alignment for any data type 128 bytes
Alignment of base address 32768 bits (4096 bytes)
Global Memory cache type None
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 65536 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 256 bytes
Pitch alignment for 2D image buffers 256 pixels
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 128
Max number of write image args 8
Local memory type Local
Local memory size 32768 (32KiB)
Max number of constant args 8
Max constant buffer size 65536 (64KiB)
Max size of kernel argument 1024
Queue properties
Out-of-order execution No
Profiling Yes
Prefer user sync for interop Yes
Profiling timer resolution 37ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels No
printf() buffer size 134217728 (128MiB)
Built-in kernels
Device Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event 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_khr_image2d_from_buffer cl_khr_depth_images cl_APPLE_command_queue_priority cl_APPLE_command_queue_select_compute_units cl_khr_fp64
NULL platform behavior
clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) Apple
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [P0]
clCreateContext(NULL, ...) [default] Success [P0]
clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) Success (1)
Platform Name Apple
Device Name AMD Radeon R9 M395 Compute Engine
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) Success (1)
Platform Name Apple
Device Name Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1)
Platform Name Apple
Device Name AMD Radeon R9 M395 Compute Engine
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) <checkNullCtxFromType:2580: create context from type CL_DEVICE_TYPE_CUSTOM : error -30>
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (2)
Platform Name Apple
Device Name AMD Radeon R9 M395 Compute Engine
Device Name Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
NOTE: your OpenCL library only supports OpenCL 1.0,
but some installed platforms support OpenCL 1.2.
Programs using 1.2 features may crash
or behave unexepectedly
平台数量1
平台名苹果
平台供应商苹果
平台版本OpenCL 1.2(2018年3月15日21:59:37)
平台配置文件完整配置文件
平台扩展cl_APPLE_SetMemoObject析构函数cl_APPLE_ContextLogging函数cl_APPLE_clut cl_APPLE_查询cl_内核cl_名称cl_APPLE_gl_共享cl_khr_gl_事件
平台名苹果
设备数量2
设备名称英特尔(R)核心(TM)i7-6700K CPU@4.00GHz
设备供应商英特尔
设备供应商ID 0xFFFFFF
设备版本OpenCL 1.2
驱动程序版本1.1
设备OpenCL C版本OpenCL C 1.2
设备型CPU
设备配置文件完整配置文件
设备可用是
编译器可用是
链接器可用是
最大计算单位8
最大时钟频率4000MHz
设备分区(核心)
子设备的最大数量0
支持的分区类型无
最大工作项维度3
最大工作项大小1024x1x1
最大工作组大小1024
首选工作组大小倍数1
首选/本机向量大小
字符16/16
短8/8
int 4/4
长2/2
半个0/0(不适用)
浮动4/4
双2/2(cl_khr_fp64)
半精度浮点支持(不适用)
单精度浮点支持(核心)
非规范是的
无限和南斯是的
四舍五入到最近的“是”
四舍五入到零是的
四舍五入到无穷大是的
IEEE754-2008融合乘法加法是
支持是在软件中模拟的
正确四舍五入除法和sqrt操作是
双精度浮点支持(cl_khr_fp64)
非规范是的
无限和南斯是的
四舍五入到最近的“是”
四舍五入到零是的
四舍五入到无穷大是的
IEEE754-2008融合乘法加法是
支持是在软件中模拟的
地址位64,小端
全局内存大小34359738368(32GiB)
纠错支持号
最大内存分配8589934592(8GiB)
主机和设备的统一内存是
任何数据类型128字节的最小对齐方式
基址1024位(128字节)的对齐
全局内存缓存类型读/写
全局内存缓存大小64
全局内存缓存线大小8388608字节
图像支持是的
每个内核的最大采样器数16
缓冲区中1D图像的最大大小65536像素
最大1D或2D图像阵列大小2048个图像
2D映像缓冲区的基址对齐1字节
2D图像缓冲区1像素的间距对齐
最大二维图像大小8192x8192像素
最大三维图像大小2048x2048x2048像素
最大读取图像参数数128
最大写入映像参数数8
本地存储器类型全局
本地内存大小32768(32KiB)
常量参数的最大数目8
最大恒定缓冲区大小65536(64KiB)
内核参数4096的最大大小(4KB)
队列属性
故障执行编号
是的
希望用户同步进行互操作是
分析计时器分辨率1ns
执行能力
运行OpenCL内核是的
运行本机内核是的
printf()缓冲区大小1048576(1024KB)
内置内核
设备扩展cl_APPLE_SetMemoObject析构函数cl_APPLE_上下文记录函数cl_APPLE_clut cl_APPLE_查询_
Number of platforms 1
Platform Name Apple
Platform Vendor Apple
Platform Version OpenCL 1.2 (Mar 15 2018 21:59:37)
Platform Profile FULL_PROFILE
Platform Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event
Platform Name Apple
Number of devices 2
Device Name Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
Device Vendor Intel
Device Vendor ID 0xffffffff
Device Version OpenCL 1.2
Driver Version 1.1
Device OpenCL C Version OpenCL C 1.2
Device Type CPU
Device Profile FULL_PROFILE
Device Available Yes
Compiler Available Yes
Linker Available Yes
Max compute units 8
Max clock frequency 4000MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Max work item dimensions 3
Max work item sizes 1024x1x1
Max work group size 1024
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 (cl_khr_fp64)
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 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 34359738368 (32GiB)
Error Correction support No
Max memory allocation 8589934592 (8GiB)
Unified memory for Host and Device Yes
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Global Memory cache type Read/Write
Global Memory cache size 64
Global Memory cache line size 8388608 bytes
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 65536 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 1 bytes
Pitch alignment for 2D image buffers 1 pixels
Max 2D image size 8192x8192 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 128
Max number of write image args 8
Local memory type Global
Local memory size 32768 (32KiB)
Max number of constant args 8
Max constant buffer size 65536 (64KiB)
Max size of kernel argument 4096 (4KiB)
Queue properties
Out-of-order execution No
Profiling Yes
Prefer user sync for interop Yes
Profiling timer resolution 1ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels Yes
printf() buffer size 1048576 (1024KiB)
Built-in kernels
Device Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event cl_khr_fp64 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_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_APPLE_fp64_basic_ops cl_APPLE_fixed_alpha_channel_orders cl_APPLE_biased_fixed_point_image_formats cl_APPLE_command_queue_priority
Device Name AMD Radeon R9 M395 Compute Engine
Device Vendor AMD
Device Vendor ID 0x1021c00
Device Version OpenCL 1.2
Driver Version 1.2 (Mar 15 2018 21:59:57)
Device OpenCL C Version OpenCL C 1.2
Device Type GPU
Device Profile FULL_PROFILE
Device Available Yes
Compiler Available Yes
Linker Available Yes
Max compute units 28
Max clock frequency 834MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Max work item dimensions 3
Max work item sizes 256x256x256
Max work group size 256
Preferred work group size multiple 64
Preferred / native vector sizes
char 4 / 4
short 2 / 2
int 1 / 1
long 1 / 1
half 0 / 0 (n/a)
float 1 / 1
double 1 / 1 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals No
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add No
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 32, Little-Endian
Global memory size 2147483648 (2GiB)
Error Correction support No
Max memory allocation 536870912 (512MiB)
Unified memory for Host and Device No
Minimum alignment for any data type 128 bytes
Alignment of base address 32768 bits (4096 bytes)
Global Memory cache type None
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 65536 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 256 bytes
Pitch alignment for 2D image buffers 256 pixels
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 128
Max number of write image args 8
Local memory type Local
Local memory size 32768 (32KiB)
Max number of constant args 8
Max constant buffer size 65536 (64KiB)
Max size of kernel argument 1024
Queue properties
Out-of-order execution No
Profiling Yes
Prefer user sync for interop Yes
Profiling timer resolution 37ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels No
printf() buffer size 134217728 (128MiB)
Built-in kernels
Device Extensions cl_APPLE_SetMemObjectDestructor cl_APPLE_ContextLoggingFunctions cl_APPLE_clut cl_APPLE_query_kernel_names cl_APPLE_gl_sharing cl_khr_gl_event 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_khr_image2d_from_buffer cl_khr_depth_images cl_APPLE_command_queue_priority cl_APPLE_command_queue_select_compute_units cl_khr_fp64
NULL platform behavior
clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) Apple
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [P0]
clCreateContext(NULL, ...) [default] Success [P0]
clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) Success (1)
Platform Name Apple
Device Name AMD Radeon R9 M395 Compute Engine
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) Success (1)
Platform Name Apple
Device Name Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1)
Platform Name Apple
Device Name AMD Radeon R9 M395 Compute Engine
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) <checkNullCtxFromType:2580: create context from type CL_DEVICE_TYPE_CUSTOM : error -30>
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (2)
Platform Name Apple
Device Name AMD Radeon R9 M395 Compute Engine
Device Name Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
NOTE: your OpenCL library only supports OpenCL 1.0,
but some installed platforms support OpenCL 1.2.
Programs using 1.2 features may crash
or behave unexepectedly