Libcu++NVIDIA C++ 標(biāo)準(zhǔn)庫
libcu++ 是 NVIDIA 開源的 C++ 標(biāo)準(zhǔn)庫,提供了 C++ 標(biāo)準(zhǔn)庫的異構(gòu)實(shí)現(xiàn),可以在 CPU 和 GPU 代碼之間使用。如果有使用 C++ 標(biāo)準(zhǔn)庫的經(jīng)驗(yàn),相信很快就能上手 libcu++,首先需要在標(biāo)準(zhǔn)庫 includes 的開頭添加cuda/std/,在使用 std::之前添加cuda:::
#include <cuda/std/atomic>
cuda::std::atomic<int> x;
NVIDIA C++ 標(biāo)準(zhǔn)庫包含在 NVIDIA HPC SDK 和 CUDA 工具包中,無需額外的安裝或編譯器標(biāo)志。
libcu++ fork 自 LLVM 的 libc++ 標(biāo)準(zhǔn)庫。作為 CUDA C++ 標(biāo)準(zhǔn)庫,libcu++ 在過去的一年里已經(jīng)初具規(guī)模,并在此后不斷改進(jìn),擁有了更多的功能。
示例代碼
// Standard C++, __host__ only.
#include <atomic>
std::atomic<int> x;
// CUDA C++, __host__ __device__.
// Strictly conforming to the C++ Standard.
#include <cuda/std/atomic>
cuda::std::atomic<int> x;
// CUDA C++, __host__ __device__.
// Conforming extensions to the C++ Standard.
#include <cuda/atomic>
cuda::atomic<int, cuda::thread_scope_block> x;評(píng)論
圖片
表情
