asherliu / thrust

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

cuda doesn't correctly respect its argument's tag #461

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
this program crashes:

#include <thrust/system/cuda/memory.h>
#include <thrust/fill.h>
#include <cuda.h>

int main(void)
{
    size_t N = 10;

    // obtain raw pointer to device memory
    int * raw_ptr;
    cudaMalloc((void **) &raw_ptr, N * sizeof(int));

    // reinterpret the raw_ptr's tag to cuda::tag
    thrust::fill(thrust::reinterpret_tag<thrust::cuda::tag>(raw_ptr),
                 thrust::reinterpret_tag<thrust::cuda::tag>(raw_ptr + N),
                 (int) 0);

    // free memory
    cudaFree(raw_ptr);

    return 0;
}

Original issue reported on code.google.com by jaredhoberock on 8 Feb 2012 at 10:31

GoogleCodeExporter commented 8 years ago
Problem seems to be that tagged_iterator's pointer and reference are no 
different from its base. cuda::detail::fill_n passes a raw pointer to 
cuda::detail::wide_fill_n, which causes a crash later.

Original comment by jaredhoberock on 8 Feb 2012 at 10:35

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

Original comment by jaredhoberock on 9 Feb 2012 at 1:10