CL2.hpp got plenty of compilation error using gnu++20/23 on android

hi,

I found a lot of error on CL2.hpp using gnu++20 et 23. Do i need to get new cl2.hpp version ?
or CL3 version with the mali immortalis 715 ?

I am running on xiaomi 13t pro 64bit kernel, i thinks. I am developper not really working on compiler.

new information:
If i use android NDK r12b and GNU++11(no error) GNU++14(error)

If i use android NDK r27c and GNU++11( no error) GNU++14( no error) GNU++17( no error) GNU++20(error)

So i do not know if it is from android or GNU.

Is some ome got an idéa it would be great.

thanks for any help.

PS: if you need the part of the log just ask, it is quite big. But the error lock all the same. depending on the tested configuration. i little bit messy for me. I am developper for long time but on linux it is changing too quickly for me.

The official Khronos headers:

are linked to the OpenCL Registry page:

This might be useful to you. Looks like you might want to just ditch CL2.hpp and use the latest version of opencl.hpp:



So what’s the error? That’s probably important.

Here is kind of error using android NDK r12b and GNU++14(error)
for cl2.hpp “Copyright (c) 2008-2016 The Khronos Group Inc.” quite old :slightly_smiling_face:

C:/Users/user/Documents/AndroidStudioProjects/androidcl-master-xiaomi/app/src/main/jni/CL3/cl2.hpp:2029:92:   required from here
C:/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/libcxx/include/tuple:290:102: error: invalid initialization of reference of type 'void (*&)(const cl::Device&)' from expression of type 'void (* const)(const cl::Device&)'
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return value;}
                                                                                                      ^
C:/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/libcxx/include/tuple:290:108: error: body of constexpr function 'constexpr _Hp& std::__ndk1::__tuple_leaf<_Ip, _Hp, <anonymous> >::get() const [with long unsigned int _Ip = 0ul; _Hp = void (*)(const cl::Device&); bool <anonymous> = false]' not a return-statement
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return value;}
                                                                                                            ^
C:/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/libcxx/include/tuple: In instantiation of 'constexpr _Hp& std::__ndk1::__tuple_leaf<_Ip, _Hp, <anonymous> >::get() const [with long unsigned int _Ip = 0ul; _Hp = void (*)(const cl::Platform&); bool <anonymous> = false]':
C:/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/libcxx/include/tuple:714:65:   required from 'constexpr typename std::__ndk1::tuple_element<_Ip, std::__ndk1::tuple<_Tp ...> >::type& std::__ndk1::get(std::__ndk1::tuple<_Tp ...>&) [with long unsigned int _Ip = 0ul; _Tp = {void (*)(const cl::Platform&), std::__ndk1::reference_wrapper<const cl::Platform>}; typename std::__ndk1::tuple_element<_Ip, std::__ndk1::tuple<_Tp ...> >::type = void (*)(const cl::Platform&)]'
C:/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/libcxx/include/mutex:498:48:   required from 'void std::__ndk1::__call_once_param<_Fp>::__execute(std::__ndk1::__tuple_indices<_Uf ...>) [with long unsigned int ..._Indices = {1ul}; _Fp = std::__ndk1::tuple<void (*)(const cl::Platform&), std::__ndk1::reference_wrapper<const cl::Platform> >]'
C:/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/libcxx/include/mutex:490:27:   required from 'void std::__ndk1::__call_once_param<_Fp>::operator()() [with _Fp = std::__ndk1::tuple<void (*)(const cl::Platform&), std::__ndk1::reference_wrapper<const cl::Platform> >]'
C:/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/libcxx/include/mutex:531:12:   required from 'void std::__ndk1::__call_once_proxy(void*) [with _Fp = std::__ndk1::tuple<void (*)(const cl::Platform&), std::__ndk1::reference_wrapper<const cl::Platform> >]'
C:/android-ndk-r12b/build//../sources/cxx-stl/llvm-libc++/libcxx/include/mutex:548:67:   required from 'void std::__ndk1::call_once(std::__ndk1::once_flag&, _Callable&&, _Args&& ...) [with _Callable = void (&)(const cl::Platform&); _Args = {std::__ndk1::reference_wrapper<const cl::Platform>}]'

The 4 other error are the same for “const cl::Device&” “const cl::Platform&” “const cl::Context&” “const cl::CommandQueue&”

but from NDK r16b until NDK r21d and gnu++17 no more error.

use android NDK r27c and GNU++20/23 got 5 time the same error ?

> C:/Users/user/Documents/AndroidStudioProjects/androidcl-master-xiaomi/app/src/main/jni/CL3/cl2.hpp:1887:96: note: in instantiation of member function 'std::vector<std::pair<cl::Device, std::string>>::vector' requested here
>  1887 |     BuildError(cl_int err, const char * errStr, const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
>       |                                                                                                ^
> C:/Users/user/Documents/AndroidStudioProjects/androidcl-master-xiaomi/app/src/main/jni/CL3/cl2.hpp:695:11: note: forward declaration of 'cl::Device'
>   695 |     class Device;
>       |           ^
> In file included from C:/Users/user/Documents/AndroidStudioProjects/androidcl-master-xiaomi/app/src/main/jni/processor.cpp:20:
> In file included from C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/string:571:
> In file included from C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__algorithm/max.h:14:
> In file included from C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__algorithm/max_element.h:15:
> In file included from C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__iterator/iterator_traits.h:14:
> In file included from C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__concepts/constructible.h:15:
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_constructible.h:22:79: error: incomplete type 'cl::Device' used in type trait expression
>    22 | struct _LIBCPP_TEMPLATE_VIS is_constructible : public integral_constant<bool, __is_constructible(_Tp, _Args...)> {};
>       |                                                                               ^
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__utility/pair.h:135:14: note: in instantiation of template class 'std::is_constructible<cl::Device, const cl::Device &>' requested here
>   135 |       return is_constructible<first_type, _U1>::value && is_constructible<second_type, _U2>::value;
>       |              ^
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__utility/pair.h:145:14: note: in instantiation of function template specialization 'std::pair<cl::Device, std::string>::_CheckArgs::__is_pair_constructible<const cl::Device &, const std::string &>' requested here
>   145 |       return __is_pair_constructible<_U1, _U2>() && !__is_implicit<_U1, _U2>();
>       |              ^
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__utility/pair.h:222:48: note: in instantiation of function template specialization 'std::pair<cl::Device, std::string>::_CheckArgs::__enable_explicit<const cl::Device &, const std::string &>' requested here
>   222 |             __enable_if_t<_CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>(), int> = 0>
>       |                                                ^
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__utility/pair.h:223:64: note: while substituting prior template arguments into non-type template parameter [with _U1 = cl::Device, _U2 = std::string]
>   223 |   _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(pair<_U1, _U2> const& __p)
>       |                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   224 |       _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
>       |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   225 |                   is_nothrow_constructible<second_type, _U2 const&>::value))
>       |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   226 |       : first(__p.first), second(__p.second) {}
>       |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__type_traits/is_trivially_copy_constructible.h:24:38: note: while substituting deduced template arguments into function template 'pair' [with _U1 = cl::Device, _U2 = std::string, $2 = (no value)]
>    24 |     : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
>       |                                      ^
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__memory/uninitialized_algorithms.h:567:15: note: (skipping 2 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
>   567 |               is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value &&
>       |               ^
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__memory/uninitialized_algorithms.h:589:28: note: while substituting deduced template arguments into function template '__uninitialized_allocator_copy_impl' [with _Alloc = std::allocator<std::pair<cl::Device, std::string>>, _In = std::pair<cl::Device, std::string>, _RawTypeIn = (no value), _Out = std::pair<cl::Device, std::string>, $4 = (no value)]
>   589 |   auto __result          = std::__uninitialized_allocator_copy_impl(
>       |                            ^
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/vector:1082:22: note: in instantiation of function template specialization 'std::__uninitialized_allocator_copy<std::allocator<std::pair<cl::Device, std::string>>, std::pair<cl::Device, std::string> *, std::pair<cl::Device, std::string> *, std::pair<cl::Device, std::string> *>' requested here
>  1082 |   __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_);
>       |                      ^
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/vector:760:7: note: in instantiation of function template specialization 'std::vector<std::pair<cl::Device, std::string>>::__construct_at_end<std::pair<cl::Device, std::string> *, std::pair<cl::Device, std::string> *>' requested here
>   760 |       __construct_at_end(__first, __last, __n);
>       |       ^
> C:/android-ndk-r27c/build/../toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/vector:1195:3: note: in instantiation of function template specialization 'std::vector<std::pair<cl::Device, std::string>>::__init_with_size<std::pair<cl::Device, std::string> *, std::pair<cl::Device, std::string> *>' requested here
>  1195 |   __init_with_size(__x.__begin_, __x.__end_, __x.size());
>       |   ^
````Preformatted text`

`> Blockquote`

I am trying a way around I let you know. Using OpenCL became less and less easy ?  :upside_down_face:

May be with vulkan. But i never loock at vulkan OpenCL yet.

I know that there where change on compiler version those last years. But it look like it is big change. It is the mess for me :smirk:

hi,

Just 2 warning from NDK 16 and GNU++14. But no more error. With the last CL headers.

> C:/Users/user/Documents/AndroidStudioProjects/androidcl-master-xiaomi/app/src/main/jni\CL/cl_platform.h:70:9: warning: 'CL_API_SUFFIX__VERSION_2_0' macro redefined [-Wmacro-redefined]
> #define CL_API_SUFFIX__VERSION_2_0 CL_API_SUFFIX_COMMON
>         ^
> C:/Users/user/Documents/AndroidStudioProjects/androidcl-master-xiaomi/app/src/main/jni/processor.cpp:11:9: note: previous definition is here
> #define CL_API_SUFFIX__VERSION_2_0

Right! And if you look at the:

// Copyright (c) 2020 The Khronos Group Inc.
#pragma message("cl2.hpp has been renamed to opencl.hpp to make it clear that it supports all versions of OpenCL. Please include opencl.hpp directly.")

at the bottom of the latest version of this file, it’s pretty clear that cl2.hpp is the old, obsolete header and folks should be using opencl.hpp now.

That’s good. So more reasonable results with the newer Android NDK 16 (vs. 12b).

it work must better ;))

I still got problem with library using the 64bit OpenCL library.
Got special sections .rel.dyn. error using clang compiler. No idea. may be you heard about it.

No way to run OpenCL on arm64-v8a using android, i do not know for other platform. Only armeabi-v7a is running with no problem with any NDK and GNU from 11. tested on hauwei honnor play(7 years old) and xiaomi 13T pro (1 year old). So no way to install AKP via google play using OpenCL librairy. Even OpenCL-Z APK cannot be installed on xiaomi 13T pro. By the way mali immortalis 715 work fine but multithread on mediateck 9200+ are very very slow. There is no multithreading. I will see.

i improve a little bit but i think that it is a compilator problem for 64bit libraries.

i got this :

>   77 warnings generated.
>   [2/2] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\arm64-v8a\libJNIProcessor2.0-client.so
>   FAILED: ../../../../build/intermediates/cmake/debug/obj/arm64-v8a/libJNIProcessor2.0-client.so 
>   cmd.exe /C "cd . && C:\android-ndk-r21d\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android30 --gcc-toolchain=C:/android-ndk-r21d/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/android-ndk-r21d/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  -O3 -std=gnu++17 -fexceptions -frtti -Wno-logical-op-parentheses -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -Wl,--build-id -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libJNIProcessor2.0-client.so -o ..\..\..\..\build\intermediates\cmake\debug\obj\arm64-v8a\libJNIProcessor2.0-client.so CMakeFiles/JNIProcessor2.0-client.dir/src/main/jni/processor.cpp.o  ../../../../src/main/cppxiaomi/lib/arm64-v8a/libOpenCL.so -landroid -lEGL -lGLESv2 -lGLESv3 -llog -ljnigraphics -lmediandk -latomic -lm && cd ."
>   C:/android-ndk-r21d/toolchains/llvm/prebuilt/windows-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin\ld: ../../../../src/main/cppxiaomi/lib/arm64-v8a/libOpenCL.so: don't know how to handle section `.relr.dyn' [0x      13]
>   ../../../../src/main/cppxiaomi/lib/arm64-v8a/libOpenCL.so: error adding symbols: File in wrong format
>   clang++: error: linker command failed with exit code 1 (use -v to see invocation)
>   ninja: build stopped: subcommand failed.

and a lot of warning concerning

> ISO C++11 does not allow conversion from string literal to 'char *'

> ../../../../src/main/jni/clOpenclDeviceQuery.h:61:55: warning: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
>   LOGI("  CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%u\n", workitem_dims);
>                                                ~~     ^~~~~~~~~~~~~
>                                                %zu
> ../../../../src/main/jni/processor.cpp:399:60: warning: format specifies type 'int' but the argument has type 'EGLDisplay' (aka 'void *') [-Wformat]
>         LOGE("Succes: eglGetDisplay() returned succes %d ",eglDisplay);
> ../../../../src/main/jni/processor.cpp:696:36: warning: format specifies type 'char *' but the argument has type 'cl_int' (aka 'int') [-Wformat]
>     LOGI(" 00 built_program() %s", err);
>                               ~~   ^~~
>                               %d

it is allowed for 32bit but not for 64bit

if some one get idea, would be nice :slightly_smiling_face:

Still error on

>   arm64-v8a/libOpenCL.so: don't know how to handle section `.relr.dyn' [0x      13]
>   arm64-v8a/libOpenCL.so: error adding symbols: File in wrong format
>   clang++: error: linker command failed with exit code 1 (use -v to see invocation)
>   ninja: build stopped: subcommand failed.

So that is the last compilation error. So i need to what clang option i need to add to make it link. It only append on 64lib.

What it is use for and why the linker stop ?