1

Thrust treats long long int as if it were long int. Here's a demo program:

#include <thrust/reduce.h>
#include <thrust/iterator/constant_iterator.h>
void tryit(long long int n) {
  // with long long
  long long int s = 
thrust::reduce(thrust::constant_iterator<long long int>(1LL),
           thrust::constant_iterator<long long int>(1LL)+n);
  std::cout << "long long: " << n << ' ' << s << std::endl;
  // now with long
  long int n1 = n;
  long int s1 = 
thrust::reduce(thrust::constant_iterator<int>(1),
           thrust::constant_iterator<int>(1)+n1);
  std::cout << "long: " << n1 << ' ' << s1 << std::endl;
}
int main() {
  tryit(1000000);
  tryit(1000000000);
  tryit(10000000000);
}

The output is:

long long: 1000000 1000000
long: 1000000 1000000
long long: 1000000000 1000000000
long: 1000000000 1000000000
long long: 10000000000 1410065408
long: 10000000000 1410065408

The first 1410065408 should be 10000000000.

I compiled it thus:

nvcc -arch=compute_30 -std=c++11 longlongb.cu -o longlongb

WRF
  • 127
  • 10
  • I can reproduce this issue here, this might be a bug. You should open an issue here: https://github.com/thrust/thrust/issues – m.s. Apr 07 '15 at 07:02
  • Done, thanks for the suggestion. https://github.com/thrust/thrust/issues/655 – WRF Apr 08 '15 at 08:02

0 Answers0