我们正在尝试使用 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();
.
.
.
}
任何解决此问题的建议都会有很大帮助。