I’m attempting to build a snippet of code on Windows 10, with the Visual Studio 2015 compiler and CUDA 9.1. The problematic call occurs within thrust::copy_if, which uses thrust::make_transform_iterator to set up its parameters. This code compiles successfully on Linux, on another machine, using gcc and CUDA 9.0/9.1.
#include <iostream>
#include <thrust/copy.h>
#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/sequence.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/tuple.h>
#define SZ (1024 * 1024)
struct functor {
const int thresh;
functor(const int thresh) : thresh(thresh) {};
__device__ bool operator()(const int i) {
return i > thresh;
};
};
struct transformFunctor {
__device__ double operator()(const double d) {
return d + 1.234;
};
};
int main(void)
{
int threshold;
thrust::device_vector<double> foo(SZ);
thrust::device_vector<int> stencil(SZ);
thrust::device_vector<double> out1(SZ), out2(SZ);
thrust::sequence(stencil.begin(), stencil.end(), 0, 1);
thrust::sequence(foo.begin(), foo.end(), 1.4, 3.11);
threshold = SZ / 2 + 1;
auto len = thrust::copy_if(thrust::device,
thrust::make_transform_iterator<transformFunctor, thrust::device_vector<double>::iterator>(foo.begin(), transformFunctor()),
thrust::make_transform_iterator<transformFunctor, thrust::device_vector<double>::iterator>(foo.end(), transformFunctor()),
stencil.begin(),
out1.begin(),
functor(threshold)) - out1.begin();
return 0;
}
The build command is the following:
nvcc -G -arch=sm_61 copy_if_compile_tests_new.cu
The error list generated on Windows is here: https://pastebin.com/Bh9LK1SU
I’ve attempted to compile this with both Visual Studio 2015 and 2017, using CUDA 9.0 and 9.1 on a fresh install and seem to generate the same errors. Are there known platform differences that would cause this to fail within Windows but not Linux?
Any assistance would be appreciated.