[英]Trying to compile OpenCL 1.2 example
System:系统:
Ryzen 1600, r9 270 (radeon driver), ubuntu 16.04 Ryzen 1600、r9 270(radeon 驱动程序)、ubuntu 16.04
I'm trying to get my compiler (gcc 5.4.1) to compile some C++ with OpenCL but can't get it to find the header files.我试图让我的编译器(gcc 5.4.1)用 OpenCL 编译一些 C++,但无法找到头文件。
test.cpp:测试.cpp:
#include <CL/cl.hpp>
int main(){}
I run g++ test.cpp -lOpenCL but get fatal error: CL/cl.hpp: No such file or directory .我运行g++ test.cpp -lOpenCL但得到致命错误: CL/cl.hpp: No such file or directory 。
For other people with the same issue on StackOverflow, the issue was libOpenCL was not installed.对于在 StackOverflow 上遇到相同问题的其他人,问题是未安装 libOpenCL。 But I have, I installed all these packages:
但是我已经安装了所有这些软件包:
opencl-headers, ocl-icd-opencl-dev, ocl-icd-libopencl1, mesa-opencl-icd, clinfo, libclc-dev, libclc-amdgcn, libclcr600 (searched 'opencl' in synaptic) opencl-headers、ocl-icd-opencl-dev、ocl-icd-libopencl1、mesa-opencl-icd、clinfo、libclc-dev、libclc-amdgcn、libclcr600 (在突触中搜索“opencl”)
And running "locate libOpenCL" gives many entries including "/usr/local/lib/libOpenCL.so" which should be picked up by the -lOpenCL flag??运行“locate libOpenCL”会给出许多条目,包括“/usr/local/lib/libOpenCL.so”,这些条目应该由 -lOpenCL 标志获取?
clinfo gives: clinfo 给出:
Number of platforms 1
Platform Name Clover
Platform Vendor Mesa
Platform Version OpenCL 1.1 Mesa 17.2.8
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_icd
Platform Extensions function suffix MESA
Platform Name Clover
Number of devices 1
Device Name AMD PITCAIRN (DRM 2.50.0 / 4.13.0-37-generic, LLVM 5.0.0)
Device Vendor AMD
Device Vendor ID 0x1002
Device Version OpenCL 1.1 Mesa 17.2.8
Driver Version 17.2.8
Device OpenCL C Version OpenCL C 1.1
Device Type GPU
Device Profile FULL_PROFILE
Max compute units 20
Max clock frequency 955MHz
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 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 No
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 (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
Correctly-rounded divide and sqrt operations No
Address bits 64, Little-Endian
Global memory size 2147483648 (2GiB)
Error Correction support No
Max memory allocation 1503238553 (1.4GiB)
Unified memory for Host and Device No
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Global Memory cache type None
Image support No
Local memory type Local
Local memory size 32768 (32KiB)
Max constant buffer size 1503238553 (1.4GiB)
Max number of constant args 16
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 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_fp64
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 PITCAIRN (DRM 2.50.0 / 4.13.0-37-generic, LLVM 5.0.0)
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 PITCAIRN (DRM 2.50.0 / 4.13.0-37-generic, LLVM 5.0.0)
ICD loader properties
ICD loader Name OpenCL ICD Loader
ICD loader Vendor OCL Icd free software
ICD loader Version 2.2.8
ICD loader Profile OpenCL 1.2
NOTE: your OpenCL library declares to support OpenCL 1.2,
but it seems to support up to OpenCL 2.1 too.
You want to download cl.hpp from here: https://www.khronos.org/registry/OpenCL/api/2.1/cl.hpp .您想从这里下载 cl.hpp: https ://www.khronos.org/registry/OpenCL/api/2.1/cl.hpp。 And make sure you link to OpenCL.
并确保您链接到 OpenCL。
OpenCL is a C-style API, so lots of functions for playing with pointers to ints. OpenCL 是一个 C 风格的 API,所以有很多函数来处理指向 int 的指针。
cl.hpp is a C++ style API, so lots of classes with readable methods for playing with pointers to ints. cl.hpp 是一个 C++ 风格的 API,所以很多类都有可读的方法来处理指向 int 的指针。
They are seperate things.它们是不同的东西。
On Linux, you need a package commonly named opencl-headers
.在 Linux 上,您需要一个通常名为
opencl-headers
的包。 Also note that different OpenCL versions are incompatible, so if your example is 1.2 you need to ensure that the headers are also 1.2另请注意,不同的 OpenCL 版本不兼容,因此如果您的示例是 1.2,则需要确保标头也是 1.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.