File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2229,13 +2229,40 @@ cdef class GpuArray:
22292229 def __get__ (self ):
22302230 return self .ga.offset
22312231
2232+ property data :
2233+ """ Return a pointer to the raw OpenCL buffer object.
2234+
2235+ This will fail for arrays that have an offset.
2236+ """
2237+ def __get__ (self ):
2238+ if self .context.kind != b" opencl" :
2239+ raise TypeError (" This is for OpenCL arrays." )
2240+ if self .offset != 0 :
2241+ raise ValueError (" This array has an offset." )
2242+ # This wizadry grabs the actual backend pointer since it's
2243+ # guarenteed to be the first element of the gpudata
2244+ # structure.
2245+ return < size_t> ((< void ** > self .ga.data)[0 ])
2246+
2247+ property base_data :
2248+ " Return a pointer to the backing OpenCL object."
2249+ def __get__ (self ):
2250+ if self .context.kind != b" opencl" :
2251+ raise TypeError (" This is for OpenCL arrays." )
2252+ # This wizadry grabs the actual backend pointer since it's
2253+ # guarenteed to be the first element of the gpudata
2254+ # structure.
2255+ return < size_t> ((< void ** > self .ga.data)[0 ])
2256+
22322257 property gpudata :
22332258 " Return a pointer to the raw backend object."
22342259 def __get__ (self ):
2260+ if self .context.kind != b" cuda" :
2261+ raise TypeError (" This is for CUDA arrays." )
22352262 # This wizadry grabs the actual backend pointer since it's
22362263 # guarenteed to be the first element of the gpudata
22372264 # structure.
2238- return < size_t> ((< void ** > self .ga.data)[0 ])
2265+ return < size_t> ((< void ** > self .ga.data)[0 ]) + self .offset
22392266
22402267 def __str__ (self ):
22412268 return str (numpy.asarray(self ))
You can’t perform that action at this time.
0 commit comments