unsigned long = 32bits in cuda. You probably want unsigned long long = 64bits, which aligns with np.uint64.
On 13 June 2017 at 09:02, Rana, Sanjay <sanjay.r...@rpa.gsi.gov.uk> wrote: > Hi Everyone, > > > > I am sure it’s something quite trivial that I am doing incorrectly but I > can’t seem to be able to find it. > > > > The following simple pycuda code is printing some random values from the > kernel for the long integer array. > > > > Please ignore the arbitrary initialisations in places as this is just for > the test. > > > > --code-- > > import numpy as np > > import pycuda.driver as drv > > import pycuda.autoinit > > from pycuda.compiler import SourceModule > > > > _stats_kernel_source = """ > > #include <stdio.h> > > > > __global__ void stats_kernel(unsigned long *CROMEID, int numCROMECELLS) > > { > > // calculate pixel idx > > int x = blockIdx.x * blockDim.x + threadIdx.x; > > if (x < numCROMECELLS) > > { > > if (x < 1) > > { > > unsigned long cid = CROMEID[x]; > > printf("Value in Kernel at %d is %lu\\n",x,cid); > > } > > } > > } > > """ > > > > zonal_stats_cuda = SourceModule(_stats_kernel_source) > > zonal_stats_cuda_func = zonal_stats_cuda.get_function("stats_kernel") > > > > numCROMECELLS = np.uint32(91480) > > cromeCELLS = np.zeros((numCROMECELLS,), dtype=np.uint64) > > long_cromeid = np.uint64(1091194009352) > > cromeCELLS[0] = long_cromeid > > long_cromeid = np.uint64(1088314008174) > > cromeCELLS[1] = long_cromeid > > long_cromeid = np.uint64(1091194011015) > > cromeCELLS[2] = long_cromeid > > print "Num Cells:%d"%(numCROMECELLS) > > print "Pre-Kernel Value at 0 in long array is %d"%(cromeCELLS[0]) > > zonal_stats_cuda_func(drv.In(cromeCELLS), numCROMECELLS, block=(32,1,1)) > > > > ---output— > > Num Cells:91480 > > Pre-Kernel Value at 0 in long array is 1091194009352 > > Value in Kernel at 0 is 272316168 > > > > > > Sanjay Rana | Design Directorate > > Rural Payments Agency | Room 200 | North Gate House | Reading | RG1 1AF > > Jabber: 02077642065 | ext. 42065 | Email: sanjay.r...@rpa.gsi.gov.uk > > Follow us on Twitter @Ruralpay > > ************************************************************ > ************************ > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > > This footnote also confirms that this email message has been swept by > Cisco ESA for the presence of computer viruses. > ************************************************************ > ************************ > > _______________________________________________ > PyCUDA mailing list > PyCUDA@tiker.net > https://lists.tiker.net/listinfo/pycuda > >
_______________________________________________ PyCUDA mailing list PyCUDA@tiker.net https://lists.tiker.net/listinfo/pycuda