【问题标题】:android Loading Kernel using openCL 2.0 with cl2.hppandroid 使用带有 cl2.hpp 的 openCL 2.0 加载内核
【发布时间】:2020-11-05 17:33:34
【问题描述】:

我想跳转到 openCL 200,我的 ARM G72 支持它。 但是我发现 cl.hpp (old 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,std::make_pair(src, 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,std::make_pair(src, src_length) );

我真的不明白是什么问题。我不再擅长 C 和 C++。在过去的 25 年里发生了很大的变化;))

【问题讨论】:

    标签: android c++ opencl


    【解决方案1】:

    对于使用 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 目录有关。 ;))

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-06
      • 2022-11-22
      相关资源
      最近更新 更多