asherliu / thrust

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

initializing double2 array crashes #408

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
<GPU GTX285, CUDA 4.0, Windows 7 64, x64 code generation>

Can't allocate-initialize an array of double2, while float, float2, double, 
double3, double4 seem to work.. Perhaps double2 is misaligned somewhere...
try {
  thrust::device_vector<double2> a(2);
} catch(thrust::system_error e) {
  cerr << e.what() << endl;
} catch(std::bad_alloc) {
  cerr << "Ran out of memory" << endl;
}
compiled with
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe" 
-gencode=arch=compute_13,code=\"sm_13,compute_13\" --use-local-env --cl-version 
2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 
10.0\VC\bin\x86_amd64"  -I"C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v4.0\include"  -G0  --keep-dir "x64\Debug" -maxrregcount=0  
--machine 64 --compile -DTHRUST_DEBUG  -D_NEXUS_DEBUG -g    -Xcompiler "/EHsc 
/nologo /Od /Zi  /MDd " -o "x64\Debug\pcCUDA.cu.obj"

crashes inside thrust in c:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v4.0\include\thrust\detail\device\cuda\detail\launch_closure.inl at
template<typename NullaryFunction, typename Size>
  void launch_closure(NullaryFunction f, Size n)
{
  closure_launcher<NullaryFunction>::launch(f,n);
} // end launch_closure()

Output:
First-chance exception at 0x000007fef16f0a34 (pcCUDA.dll) in pctoolsrun.exe: 
0xC0000005: Access violation reading location 0x0000000000000000.
Unhandled exception at 0x000007fef16f0a34 (pcCUDA.dll) in pctoolsrun.exe: 
0xC0000005: Access violation reading location 0x0000000000000000.

Call stack:
pcCUDA.dll!thrust::detail::device::cuda::for_each_n_closure<thrust::detail::norm
al_iterator<thrust::device_ptr<double2> >,unsigned 
int,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > 
>::for_each_n_closure<thrust::detail::normal_iterator<thrust::device_ptr<double2
> >,unsigned 
int,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > 
>(const 
thrust::detail::device::cuda::for_each_n_closure<thrust::detail::normal_iterator
<thrust::device_ptr<double2> >,unsigned 
int,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > > 
& __that={...})  + 0x34 bytes   C++
>   pcCUDA.dll!thrust::detail::device::cuda::detail::launch_closure<thrust::detail
::device::cuda::for_each_n_closure<thrust::detail::normal_iterator<thrust::devic
e_ptr<double2> >,unsigned 
int,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > 
>,unsigned 
int>(thrust::detail::device::cuda::for_each_n_closure<thrust::detail::normal_ite
rator<thrust::device_ptr<double2> >,unsigned 
int,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > > 
* f=0x00000000002ef028, unsigned int n=4000)  Line 172 + 0x19 bytes C++
    pcCUDA.dll!thrust::detail::device::cuda::for_each_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > >(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef0c8, __int64 n=4000, thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > f={...})  Line 110 + 0x31 bytes C++
    pcCUDA.dll!thrust::detail::device::dispatch::for_each_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > >(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef150, __int64 n=4000, thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > f={...}, thrust::detail::cuda_device_space_tag __formal={...})  Line 54 + 0x64 bytes    C++
    pcCUDA.dll!thrust::detail::device::for_each_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > >(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef1b8, __int64 n=4000, thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > f={...})  Line 40 + 0x73 bytes    C++
    pcCUDA.dll!thrust::detail::dispatch::for_each_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > >(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef240, __int64 n=4000, thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > f={...}, thrust::device_space_tag __formal={...})  Line 83 + 0x64 bytes C++
    pcCUDA.dll!thrust::detail::for_each_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > >(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef2c0, __int64 n=4000, thrust::detail::generate_functor<thrust::detail::fill_functor<double2> > f={...})  Line 38 + 0x73 bytes    C++
    pcCUDA.dll!thrust::generate_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,thrust::detail::fill_functor<double2> >(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef360, __int64 n=4000, thrust::detail::fill_functor<double2> gen={...})  Line 46 + 0x9d bytes    C++
    pcCUDA.dll!thrust::detail::device::cuda::detail::fill_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,double2>(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef3d8, __int64 n=4000, const double2 & value={...}, thrust::detail::integral_constant<bool,0> __formal={...})  Line 86 + 0x56 bytes   C++
    pcCUDA.dll!thrust::detail::device::cuda::fill_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,double2>(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef420, __int64 n=4000, const double2 & value={...})  Line 138 + 0x4a bytes    C++
    pcCUDA.dll!thrust::detail::device::dispatch::fill_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,double2>(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef478, __int64 n=4000, const double2 & value={...}, thrust::detail::cuda_device_space_tag __formal={...})  Line 57 + 0x30 bytes   C++
    pcCUDA.dll!thrust::detail::device::fill_n<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,__int64,double2>(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef4e0, __int64 n=4000, const double2 & value={...})  Line 44 + 0x51 bytes   C++
    pcCUDA.dll!thrust::detail::device::fill<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,double2>(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef550, thrust::detail::normal_iterator<thrust::device_ptr<double2> > * last=0x00000000002ef540, const double2 & value={...})  Line 38 + 0x86 bytes    C++
    pcCUDA.dll!thrust::detail::dispatch::fill<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,double2>(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef5b8, thrust::detail::normal_iterator<thrust::device_ptr<double2> > * last=0x00000000002ef5a8, const double2 & value={...}, thrust::device_space_tag __formal={...})  Line 68 + 0x47 bytes C++
    pcCUDA.dll!thrust::fill<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,double2>(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef610, thrust::detail::normal_iterator<thrust::device_ptr<double2> > * last=0x00000000002ef600, const double2 & exemplar={...})  Line 37 + 0x4d bytes C++
    pcCUDA.dll!thrust::detail::dispatch::uninitialized_fill<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,double2>(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef678, thrust::detail::normal_iterator<thrust::device_ptr<double2> > * last=0x00000000002ef668, const double2 & x={...}, thrust::detail::integral_constant<bool,1> __formal={...})  Line 48 + 0x47 bytes  C++
    pcCUDA.dll!thrust::uninitialized_fill<thrust::detail::normal_iterator<thrust::device_ptr<double2> >,double2>(thrust::detail::normal_iterator<thrust::device_ptr<double2> > * first=0x00000000002ef6d0, thrust::detail::normal_iterator<thrust::device_ptr<double2> > * last=0x00000000002ef6c0, const double2 & x={...})  Line 42 + 0x4d bytes  C++
    pcCUDA.dll!thrust::detail::vector_base<double2,thrust::device_malloc_allocator<double2> >::fill_init(unsigned __int64 n=4000, const double2 & x={...})  Line 156 + 0x29 bytes   C++
    pcCUDA.dll!thrust::detail::vector_base<double2,thrust::device_malloc_allocator<double2> >::vector_base<double2,thrust::device_malloc_allocator<double2> >(unsigned __int64 n=4000, const double2 & value={...})  Line 62 + 0x14 bytes   C++
    pcCUDA.dll!thrust::device_vector<double2,thrust::device_malloc_allocator<double2> >::device_vector<double2,thrust::device_malloc_allocator<double2> >(unsigned __int64 n=4000, const double2 & value={...})  Line 77 + 0x27 bytes   C++
    pcCUDA.dll!thrust_test(double & res=2.2250738585072014e-308, unsigned short min_grid_size=64)  Line 173 C++

Original issue reported on code.google.com by rych...@gmail.com on 31 Oct 2011 at 11:42

GoogleCodeExporter commented 8 years ago
Does my_double2 work, i.e.:

struct my_double3
{
  float x, y;
};

Original comment by jaredhoberock on 1 Nov 2011 at 6:41

GoogleCodeExporter commented 8 years ago
Yes, it worked, thanks!
struct my_double2 {
    double x, y;
};

Shall I use my_double2 everywhere from now on instead of "built-in" double2?

double2 is defined in C:\Program Files\NVIDIA GPU Computing 
Toolkit\CUDA\v4.0\include\vector_types.h as
/*DEVICE_BUILTIN*/
struct __builtin_align__(16) double2
{
  double x, y;
};

Original comment by rych...@gmail.com on 2 Nov 2011 at 1:59

GoogleCodeExporter commented 8 years ago
Yes, this is a known incompatibility between nvcc and msvc with no other 
solution AFAIK.

Original comment by wnbell on 2 Nov 2011 at 4:12