#include <stdio.h>
#include <cuda_runtime.h>
__global__ void broadcast(){
int lane_id = threadIdx.x & 0x1f;
int value = 31 - lane_id;
//let all lanes within the warp be broadcasted the value
//whose laneID is 2 less than that of current lane
int broadcasted_value = __shfl_up_sync(0xffffffff, value, 2)
value = n;
printf("thread %d final value = %d\n", threadIdx.x, value);
}
int main() {
broadcast<<<1,32>>>();
cudaDeviceSynchronize();
return 0;
}
实际上,此问题与this page相同。无论我修改了遮罩(例如0x00000000
,0x00000001
等),改组的结果都没有改变。那么,如何正确理解口罩的作用呢?
这里是广播变量的测试代码:#include
#include
对于已经收敛并处于活动状态的经线,它没有任何作用。
如果mask参数设置为零,它不会阻止泳道参与随机播放操作。