OpenCL TM API C++绑定

OpenCL TM API C++ bindings

OpenCL TM API C++绑定

Doxgen documentation for the bindings is available here:

此处提供了绑定的Doxgen文档:

OpenCL C++ Bindings: OpenCL C++ Bindings

Components:

组件:

  • include/CL/opencl.hpp: The latest, maintained, version of the C++ bindings. It should work with all versions of OpenCL (including 1.x). This is what most users will want.

  • include/CL/opencl.hpp:C++绑定的最新维护版本。它应该适用于所有版本的OpenCL(包括1.x)。这是大多数用户想要的。

  • include/CL/cl2.hpp: Includes opencl.hpp and emits a warning, for backwards compability.

  • include/CL/cl2.hpp:包含opencl.hpp并发出警告,用于向后兼容。

  • docs: Doxygen file used to generate HTML documentation for opencl.hpp.

  • docs:Doxygen文件,用于为opencl.hpp生成HTML文档。

  • examples: A simple example application using the very basic features of the bindings.

  • 示例:一个使用绑定的基本功能的简单示例应用程序。

  • tests: A (very small, incomplete) set of regression tests. Building the tests requires Python, Ruby, and CMock. For the last one we use CMock top-of-tree from Github, as the latest (at the time this was written) released CMock version, v2.5.3, has some issues.

  • ​测试:一组(非常小、不完整的)回归测试。构建测试需要Python、Ruby和CMock。对于最后一个,我们使用Github中的CMock top of tree,因为最新发布的CMock版本v2.5.3存在一些问题。

  • CMakeLists.txt: Build system for the examples and tests and logic for the bindings installation.

  • CMakeLists.txt:为绑定安装的示例、测试和逻辑构建系统。

Build Instructions

构建说明

While the C++ Headers can be built and installed in isolation, it is part of the OpenCL SDK. If looking for streamlined build experience and a complete development package, refer to the SDK build instructions instead of the following guide.


虽然C++头可以单独构建和安装,但它是OpenCLSDK的一部分。如果想要获得精简的构建体验和完整的开发包,请参阅SDK构建说明,而不是以下指南。

Dependencies

依赖

The C++ Headers require:

C++头需要:

  • the OpenCL Headers.
  • OpenCL头。
    • It is recommended to install the headers via CMake, however a convenience shorthand is provided. Providing OPENCL_CLHPP_HEADERS_DIR to CMake, one may specify the location of OpenCL Headers. By default, the C++ Headers will look for OpenCL Headers under ${OPENCL_DIST_DIR}/include.
    • 建议通过CMake安装头,但是提供了一个方便的简写。向CMake提供OPENCL_CLHPP_HEADERS_DIR,可以指定OPENCL头的位置。默认情况下,C++标头将在${OpenCL_DIST_DIR}/include下查找OpenCL头。
  • the OpenCL-ICD-Loader when building the examples
  • ​构建示例时的OpenCL ICD加载器
    • It is recommended to install the ICD loader via CMake, however a convenience shorthand is provided. Providing OPENCL_CLHPP_LOADER_DIR to CMake, one may specify the location of the OpenCL ICD loader. By default, the C++ headers will look for OpenCL ICD loader under ${OPENCL_DIST_DIR}/lib.
    • 建议通过CMake安装ICD加载程序,但提供了一个方便的简写。向CMake提供OPENCL_CLHPP_LOADER_DIR,可以指定OPENCL ICD加载器的位置。默认情况下,C++标头将在${OpenCL_DIST_DIR}/lib下查找OpenCL ICD加载程序。
  • The C++ Headers uses CMake for its build system. If CMake is not provided by your build system or OS package manager, please consult the CMake website.
  • ​C++头使用CMake作为其构建系统。如果构建系统或操作系统包管理器没有提供CMake,请访问CMake网站。
  • The unit tests require CMock. To get this external dependency, use --recursive when cloning the repository, or run git submodule update --init --recursive.
  • ​单元测试需要CMock。要获得这个外部依赖项,请在克隆存储库时使用--recursive,或者运行git submodule update--init--recursive。
  • Generating the mock input requires Ruby.
  • ​生成模拟输入需要Ruby。
  • Generating the docs requires Doxygen. When it is available, you can generate HTML documentation by building the docs target.
  • 生成文档需要Doxygen。当它可用时,您可以通过构建文档目标来生成HTML文档。

Example Build

示例构建

1.Clone this repo, the OpenCL ICD Loader and the OpenCL Headers:

1.克隆此repo、OpenCL ICD Loader和OpenCL Headers:

 git clone --recursive https://github.com/KhronosGroup/OpenCL-CLHPP
 git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
 git clone https://github.com/KhronosGroup/OpenCL-Headers

2.Install OpenCL Headers CMake package

2.安装OpenCL Headers CMake包

 cmake -D CMAKE_INSTALL_PREFIX=./OpenCL-Headers/install -S ./OpenCL-Headers -B ./OpenCL-Headers/build 
 cmake --build ./OpenCL-Headers/build --target install

3.Build and install OpenCL ICD Loader CMake package. (Note that CMAKE_PREFIX_PATH need to be an absolute path. Update as needed.)

3.构建并安装OpenCL ICD Loader CMake包。(请注意,CMAKE_PREFIX_PATH需要是一个绝对路径。根据需要进行更新。)

 cmake -D CMAKE_PREFIX_PATH=/absolute/path/to/OpenCL-Headers/install -D CMAKE_INSTALL_PREFIX=./OpenCL-ICD-Loader/install -S ./OpenCL-ICD-Loader -B ./OpenCL-ICD-Loader/build 
 cmake --build ./OpenCL-ICD-Loader/build --target install

4.Build and install OpenCL C++ Headers CMake package.

4.构建并安装OpenCL C++Headers CMake包。

 cmake -D CMAKE_PREFIX_PATH="/absolute/path/to/OpenCL-Headers/install;/absolute/path/to/OpenCL-ICD-Loader/install" -D CMAKE_INSTALL_PREFIX=./OpenCL-CLHPP/install -S ./OpenCL-CLHPP -B ./OpenCL-CLHPP/build 
 cmake --build ./OpenCL-CLHPP/build --target install

Example Use

示例使用

Example CMake invocation

CMake调用示例

cmake -D CMAKE_PREFIX_PATH="/chosen/install/prefix/of/headers;/chosen/install/prefix/of/loader;/chosen/install/prefix/of/cppheaders" /path/to/opencl/app

and sample CMakeLists.txt

和示例CMakeLists.txt

cmake_minimum_required(VERSION 3.0)
cmake_policy(VERSION 3.0...3.18.4)
project(proj)
add_executable(app main.cpp)
find_package(OpenCLHeaders REQUIRED)
find_package(OpenCLICDLoader REQUIRED)
find_package(OpenCLHeadersCpp REQUIRED)
target_link_libraries(app PRIVATE OpenCL::Headers OpenCL::OpenCL OpenCL::HeadersCpp)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值