| 例子 | doxygen文档(todo) |
|---|
cuCollections ( cuco )是一个开源的,仅GPU加速的同时数据结构的库。
类似于推力和幼崽提供类似STL的GPU加速算法和原语的方式, cuCollections提供了类似STL的并发数据结构。 cuCollections不是std::unordered_map等STL数据结构的一对一的替换。取而代之的是,它提供了适合与GPU有效使用的功能相似的数据结构。
cuCollections仍处于繁重的发展状态。用户应该期望破裂的变化和重构是普遍的。
11/01/2024将术语window简化为bucket
01/08/2024弃用了experimental名称空间
01/02/2024将传统static_map移至cuco::legacy名称空间
cuCollections仅是标头,可以通过下载标题并将其放入源树来手动合并到您的项目中。
cuCollections cuCollections旨在使在另一个CMAKE项目中易于包含。 CMakeLists.txt导出一个可以将1链接到设置目标的cuco目标,包括目录,依赖项和编译在项目中使用cuCollections所需的标志。
我们建议使用CMAKE软件包管理器(CPM)将cuCollections获取到您的项目中。使用CPM,获得cuCollections很容易:
cmake_minimum_required ( VERSION 3.23.1 FATAL_ERROR)
include ( path /to/CPM.cmake)
CPMAddPackage(
NAME cuco
GITHUB_REPOSITORY NVIDIA/cuCollections
GIT_TAG dev
OPTIONS
"BUILD_TESTS OFF"
"BUILD_BENCHMARKS OFF"
"BUILD_EXAMPLES OFF"
)
target_link_libraries (my_library cuco)这将负责从GitHub下载cuCollections ,并在Cmake可以找到的位置中提供标头。链接到cuco目标将提供my_library目标使用的cuco所需的一切。
1: cuCollections仅是标头,因此没有二进制组件可以“链接”。链接术语来自CMAKE的target_link_libraries即使是仅用于仅标头库目标的,它仍然使用。
nvcc 11.5+cuCollections取决于以下库:
用户不需要采取任何措施来满足这些依赖性。 cuCollections的CMake脚本配置为首先搜索这些库的系统,如果找不到这些库,则可以自动从Github获取它们。
由于cuCollections仅是标头,因此没有什么可构建的。
建立测试,基准和示例:
cd $CUCO_ROOT
mkdir -p build
cd build
cmake .. # configure
make # build
ctest --test-dir tests # run tests二进制文件将内置为:
build/tests/build/benchmarks/build/examples/另外,您可以使用位于ci/build.sh构建脚本。没有参数的脚本将触发一个完整的构建,该构建将位于build/local 。
cd $CUCO_ROOT
ci/build.sh # configure and build
ctest --test-dir build/local/tests # run tests有关所有可用选项的综合列表以及描述和示例,您可以使用选项ci/build.sh -h 。
默认情况下, cuCollections使用pre-commit.ci和mirrors-clang-format使用拉动请求中的C ++/CUDA文件自动格式化。用户应Allow edits by maintainers ,以使自动形成工作。
可选地,您可能希望设置一个pre-commit挂钩,以自动运行git commit时自动运行clang-format 。这可以通过通过conda或pip安装pre-commit来完成:
conda install -c conda-forge pre_commitpip install pre-commit然后运行:
pre-commit install从cuCollections存储库的根部。现在,每次提交更改时,都将运行代码格式。
您也可能希望手动格式化代码:
pre-commit run clang-format --all-filesmirrors-clang-format保证了正确版本的clang-format ,并避免版本不匹配。用户不应直接在命令行上使用clang-format来格式化代码。
Doxygen用于从源代码中的C ++/CUDA注释中生成HTML页面。
以下示例涵盖了用于记录cuCollections中C ++/CUDA代码的大多数Doxygen块注释和标签样式。
/* *
* @file source_file.cpp
* @brief Description of source file contents
*
* Longer description of the source file contents.
*/
/* *
* @brief Short, one sentence description of the class.
*
* Longer, more detailed description of the class.
*
* A detailed description must start after a blank line.
*
* @tparam T Short description of each template parameter
* @tparam U Short description of each template parameter
*/
template < typename T, typename U>
class example_class {
void get_my_int (); // /< Simple members can be documented like this
void set_my_int ( int value ); // /< Try to use descriptive member names
/* *
* @brief Short, one sentence description of the member function.
*
* A more detailed description of what this function does and what
* its logic does.
*
* @param[in] first This parameter is an input parameter to the function
* @param[in,out] second This parameter is used both as an input and output
* @param[out] third This parameter is an output of the function
*
* @return The result of the complex function
*/
T complicated_function ( int first, double * second, float * third)
{
// Do not use doxygen-style block comments
// for code logic documentation.
}
private:
int my_int; // /< An example private member variable
};cuCollections还将doxygen用作文档衬里。要在本地检查Doxygen样式,请运行
./ci/pre-commit/doxygen.sh我们计划将许多GPU加速的并发数据结构添加到cuCollections 。截至目前,这两个旗舰是哈希表的变体。
static_set cuco::static_set是一个固定尺寸的容器,它以无特定顺序存储唯一的元素。有关更多详细信息,请参见static_set.cuh中的doxygen文档。
static_map cuco::static_map是使用线性探测的打开地址的固定尺寸哈希表。有关更多详细信息,请参见static_map.cuh中的doxygen文档。
static_multimap cuco::static_multimap是一个固定大小的哈希表,支持存储等效键。默认情况下,它使用Double哈希,并支持切换到线性探测。有关更多详细信息,请参见static_multimap.cuh中的doxygen文档。
static_multiset cuco::static_multiset是一个固定大小的容器,支持存储等效键。默认情况下,它使用Double哈希,并支持切换到线性探测。有关更多详细信息,请参见static_multiset.cuh中的doxygen文档。
dynamic_map cuco::dynamic_map将多个cuco::static_map s链接在一起,以提供可以在插入键值对时生长的哈希表。目前,它仅提供主机构成API。有关更多详细信息,请参见dynamic_map.cuh中的doxygen文档。
hyperloglog cuco::hyperloglog实现了已建立的超置型++算法,以近似多种/流中不同项目的计数。
bloom_filter cuco::bloom_filter实现了一个阻塞的绽放过滤器,以进行大约设置的会员资格查询。