0

我们正在尝试使用 CUDA 中的一些协作组功能来编写一个小型应用程序。我们正在使用带有 CUDA 11.0 的 Tesla V100 卡。但是在 thread_block 中使用 is_valid() 方法时,观察到以下错误:

error: class "cooperative_groups::__v1::thread_block" has no member "is_valid"

在CUDA提供的示例simpleCooperativeGroups.cu中,在内核cgkernel()中使用is_valid方法时,可以看到这个错误。修改后的示例中的代码片段如下所示。

__global__ void cgkernel(){


// threadBlockGroup includes all threads in the block
thread_block threadBlockGroup = this_thread_block();
int threadBlockGroupSize=threadBlockGroup.size();

// workspace array in shared memory required for reduction
extern __shared__ int workspace[];

int input, output, expectedOutput;

// input to reduction, for each thread, is its' rank in the group
input=threadBlockGroup.thread_rank();

// expected output from analytical formula (n-1)(n)/2
// (noting that indexing starts at 0 rather than 1)
expectedOutput=(threadBlockGroupSize-1)*threadBlockGroupSize/2;

// perform reduction
output=sumReduction(threadBlockGroup, workspace, input);

bool valid = threadBlockGroup.is_valid();
.
.
.
}

任何解决此问题的建议都会有很大帮助。

4

1 回答 1

1

研究cooperative_groups.h,似乎is_valid()提供方法的唯一 cg 类是grid_groupand multi_grid_group

因此,此时,这些是唯一可用该方法的组,您不应尝试将该方法与其他组类型一起使用;我认为最好的假设是其他组类型总是被认为是有效的。

我怀疑这里的逻辑是网格和多网格组具有适当的启动配置和平台要求;它们可能是无效的。在任何受支持的平台或启动配置上创建其他组类型不能无效(至少在这些方面)。我不打算在任何可能的解释下将其作为防弹声明,而是作为一般指南或推理。

于 2021-01-28T21:52:29.143 回答