lion03 / thrust

Automatically exported from code.google.com/p/thrust
Apache License 2.0
0 stars 0 forks source link

in-place adjacent_difference fails non-deterministically #308

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
#include <thrust/device_vector.h>
#include <thrust/adjacent_difference.h>
#include <thrust/sequence.h>
#include <cassert>

template<typename Range1, typename Range2>
  void foo(const Range1 &rng1,
           Range2 &rng2)
{
  thrust::adjacent_difference(rng1.begin(), rng1.end(), rng2.begin());
}

int main(void)
{
  thrust::device_vector<short> vec1(511);
  thrust::device_vector<short> vec2(511);

  for(int i = 0; i < 1000; ++i)
  {
    thrust::sequence(vec1.begin(), vec2.end());
    foo(vec1, vec2);

    // in-place
    foo(vec1,vec1);

    std::cerr << "i: " << i << std::endl;
    assert(vec1 == vec2);
  }

  return 0;
}

$ jhoberock@jhoberock-dt:~/dev/hg/thrust-tot$ nvcc -I. test.cu -arch=sm_20 -run
i: 0
i: 1
a.out: test.cu:27: int main(): Assertion `vec1 == vec2' failed.
Aborted

Original issue reported on code.google.com by jaredhoberock on 15 Feb 2011 at 8:13

GoogleCodeExporter commented 8 years ago

Original comment by jaredhoberock on 15 Feb 2011 at 10:54

GoogleCodeExporter commented 8 years ago
This issue was closed by revision f0cecb2cfec0.

Original comment by wnbell on 10 Jul 2011 at 4:12