...
auto set_true = [mask] __device__ (size_t index) {
*(mask + index) = true;
};
thrust::for_each_n(thrustPtr_Vix, numOfVoxels, set_true);
...
lambda表达式在host中定义,因此必须使用__device__或者__device__ __host__进行修饰才能在thrust的global函数中使用。此外,还必须修改项目的编译命令,以包含 --extended-lambda
选项。修改的方式是
- 打开你的项目。
- 在解决方案资源管理器中,右键单击项目,然后选择“属性”。
- 在属性页中,选择“CUDA C/C++”。
- 在“命令行”字段中,找到“其他选项”一栏。
- 在“其他选项”一栏中,添加
--extended-lambda
。