ddemidov / vexcl

VexCL is a C++ vector expression template library for OpenCL/CUDA/OpenMP
http://vexcl.readthedocs.org
MIT License
702 stars 82 forks source link

Include CL/opencl.hpp or CL/cl2.hpp, whatever available #291

Closed ddemidov closed 3 years ago

ddemidov commented 3 years ago

CL/cl.hpp is no longer available from Khronos. The recommended header to include is CL/opencl.hpp, but some systems may only provide the deprecated CL/cl2.hpp. See discussion in #286.

ddemidov commented 3 years ago

CC @blattms

blattms commented 3 years ago

:+1:

Ok, I have tested this and it works for. From inspecting the code it should also work on not so recent distributions.

I also tested it with the examples of amgcl (Now I know why compiling it is off by default. :wink: Takes up to 600 MB per process and very long. Needed to reduce the parallel build processes to 4 as my system only has 2.6 GB in the /tmp directory). You might want to specify CL_TARGET_OPENCL_VERSION similar to the HPP ones as currently we might mix OpenCL Standards:

[ 75%] Building CXX object tutorial/2.Serena/CMakeFiles/serena_vexcl_jit.dir/serena_vexcl.cpp.o
cd /home/mblatt/src/3rdparty/amgcl/build/tutorial/2.Serena && /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_T
HREAD_DYN_LINK -DVEXCL_BACKEND_JIT -DVEXCL_JIT_COMPILER_FLAGS="" -DVEXCL_OMP_FLAGS=-fopenmp -I/home/mblatt/src/3rdparty/amgcl -isystem /home/mblatt/opt/vexcl/include -O2 -g -DNDEB
UG -fopenmp -Wno-missing-braces -Wno-deprecated-declarations -Wno-ignored-attributes -Wno-unused-local-typedefs -Wno-variadic-macros -Wno-catch-value -Wall -Wextra -Wpedantic -o C
MakeFiles/serena_vexcl_jit.dir/serena_vexcl.cpp.o -c /home/mblatt/src/3rdparty/amgcl/tutorial/2.Serena/serena_vexcl.cpp
In file included from /usr/include/CL/cl_platform.h:20,
                 from /home/mblatt/opt/vexcl/include/vexcl/types.hpp:47,
                 from /home/mblatt/opt/vexcl/include/vexcl/backend/jit/source.hpp:42,
                 from /home/mblatt/opt/vexcl/include/vexcl/backend/jit.hpp:41,
                 from /home/mblatt/opt/vexcl/include/vexcl/backend.hpp:74,
                 from /home/mblatt/opt/vexcl/include/vexcl/vector.hpp:49,
                 from /home/mblatt/src/3rdparty/amgcl/amgcl/backend/vexcl.hpp:40,
                 from /home/mblatt/src/3rdparty/amgcl/tutorial/2.Serena/serena_vexcl.cpp:4:
/usr/include/CL/cl_version.h:22:104: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)'
   22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
      |                                                                                                        ^
[ 76%] Linking CXX executable poisson3Db_mpi_vexcl_comp
ddemidov commented 3 years ago

You might want to specify CL_TARGET_OPENCL_VERSION similar to the HPP ones as currently we might mix OpenCL Standards:

Done, and merged. Thanks!

blattms commented 3 years ago

I have thank you. Thanks a lot for the fix.

keryell commented 3 years ago

If you are focusing on C++17 or higher you could perhaps simplify the approach by just using __has_include() https://en.cppreference.com/w/cpp/preprocessor/include

ddemidov commented 3 years ago

Thank you Ronan! Unfortunately, vexcl code is currently fixed at the c++11 standard. Although even just the return type deduction from c++14 would make the code much cleaner.

keryell commented 3 years ago

Isn't it a good opportunity to move forward by 6 years? ;-)