正在加载...
正在搜索...
无匹配项
cuda_utils.hpp
1/*
2 * 版权所有 (c) 2022-2024, NVIDIA CORPORATION。
3 *
4 * 获得 Apache License, Version 2.0 (“许可证”) 的许可;
5 * 除非符合许可证,否则您不得使用此文件。
6 * 您可以在以下网址获取许可证副本:
7 *
8 * https://apache.ac.cn/licenses/LICENSE-2.0
9 *
10 * 除非适用法律要求或书面同意,否则软件
11 * 在许可证下分发,按“原样”基础提供,
12 * 不提供任何明示或暗示的担保或条件。
13 * 有关管理许可和
14 * 限制的特定语言,请参见许可证。
15 */
16
17#pragma once
18#include <utility>
19
20#ifdef __CUDACC__
21#define CUSPATIAL_HOST_DEVICE __host__ __device__
22#define CUSPATIAL_KERNEL __global__ static
23#else
24#define CUSPATIAL_HOST_DEVICE
25#define CUSPATIAL_KERNEL
26#endif
27
35template <std::size_t threads_per_block = 256>
36std::pair<std::size_t, std::size_t> constexpr grid_1d(std::size_t const n)
37{
38 return {threads_per_block, (n + threads_per_block - 1) / threads_per_block};
39}