簡體   English   中英

android 使用帶有 cl2.hpp 的 openCL 2.0 加載內核

[英]android Loading Kernel using openCL 2.0 with cl2.hpp

我想跳到 openCL 200 有我的 ARM G72 支持它。 但是我發現 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,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 年發生了很大變化;))

對於使用 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 目錄有關。 ;))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM