如何解决使用带有cl2.hpp的openCL 2.0的android加载内核
我想跳到我的ARM G72支持的openCL 200。 但是我发现cl.hpp(旧的openCL;)))和cl2.hpp之间有很大的区别。
在我以前加载内核之前:
int src_length = 0;
const char* src = file_contents("/data/data/com.example/app_execdir/kernels.cl",&src_length);
cl::Program::Sources sources(1,std::make_pair(src,src_length) );
program = cl::Program(gContext,sources);
program.build(devices,NULL,cb);
while(program.getBuildInfo<CL_PROGRAM_BUILD_STATUS>(devices[0]) != CL_BUILD_SUCCESS);
gCompression = cl::Kernel(program,"compression",&err);
但是当我使用cl2.hpp和所有新的#define编译我的cpp时。使用CL_HPP_TARGET_OPENCL_VERSION 200时出现很多错误消息
error: 'CL_DEVICE_QUEUE_ON_HOST_PROPERTIES' was not declared
note: in definition of macro 'CL_HPP_DECLARE_PARAM_TRAITS_'
note: in expansion of macro 'CL_HPP_PARAM_NAME_INFO_2_0_'
当我使用CL_HPP_TARGET_OPENCL_VERSION 120时,我仅收到1个编译错误;)),但这与内核编译有关。 cl :: Program :: Sources来源(1,std :: make_pair(src,src_length));这是我的日志:
C:/Users/user/Documents/AndroidStudioProjects/androidcl-master/app/src/main/jni/processor.cpp:564:72: error: no matching function for call to 'std::vector<std::basic_string<char>,std::allocator<std::basic_string<char> > >::vector(int,std::pair<const char*,int>)'
cl::Program::Sources sources(1,src_length) );
^
C:/Users/user/Documents/AndroidStudioProjects/androidcl-master/app/src/main/jni/processor.cpp:564:72: note: candidates are:
In file included from C:/android-ndk-r12b/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/vector:64:0,from C:/android-ndk-r12b/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/bits/random.h:34,from C:/android-ndk-r12b/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/random:49,from C:/android-ndk-r12b/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_algo.h:66,from C:/android-ndk-r12b/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/algorithm:62,from C:/Users/user/Documents/AndroidStudioProjects/androidcl-master/app/src/main/jni/processor.cpp:23:
C:/android-ndk-r12b/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_vector.h:445:9: note: template<class _InputIterator,class> std::vector<_Tp,_Alloc>::vector(_InputIterator,_InputIterator,const allocator_type&)
vector(_InputIterator __first,_InputIterator __last,^
C:/android-ndk-r12b/build//../sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_vector.h:445:9: note: template argument deduction/substitution failed:
C:/Users/user/Documents/AndroidStudioProjects/androidcl-master/app/src/main/jni/processor.cpp:564:72: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::pair<const char*,int>')
cl::Program::Sources sources(1,src_length) );
我真的不理解问题是什么。我在C和C ++方面不再那么出色。过去25年的变化很大;))
解决方法
对于使用CL_HPP_TARGET_OPENCL_VERSION 120的错误,我们必须添加
#define CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY
使用CL_HPP_TARGET_OPENCL_VERSION 200的错误
#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
#define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED
#define CL_API_SUFFIX__VERSION_2_0
#define CL_HPP_MINIMUM_OPENCL_VERSION 110
#define CL_HPP_TARGET_OPENCL_VERSION 200
#define CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY
#define CL_TARGET_OPENCL_VERSION 200
如果您有很多版本的include / CL,也要注意一个错误,如果不要忘记该文件必须位于CL目录中,而不是CLx CLy中。因为所有内容都与CL目录有关。 ;))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。