提交 85c63450 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Make PyGpuArray_DEV_DATA() handle offsets.

Should fix bugs in current uses and makes porting easier too.
上级 2092e832
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include <string.h> #include <string.h>
#include <gpuarray_api.h> #include <gpuarray_api.h>
#include <numpy_compat.h> #include <numpy_compat.h>
#include <gpuarray/util.h>
static int theano_size_check(PyGpuArrayObject *a, unsigned int nd, static int theano_size_check(PyGpuArrayObject *a, unsigned int nd,
const size_t *dims, int typecode) { const size_t *dims, int typecode) {
...@@ -45,6 +47,12 @@ static PyGpuArrayObject *theano_try_copy(PyGpuArrayObject *out, ...@@ -45,6 +47,12 @@ static PyGpuArrayObject *theano_try_copy(PyGpuArrayObject *out,
/* This is guaranteed to work and return the raw CUDA/OpenCL object on /* This is guaranteed to work and return the raw CUDA/OpenCL object on
* all recent (as of June 2015) version of libgpuarray. This is also * all recent (as of June 2015) version of libgpuarray. This is also
* promised to keep working in future versions. */ * promised to keep working in future versions. */
#define PyGpuArray_DEV_DATA(ary) (*(void **)((ary)->ga.data)) static inline void *PyGpuArray_DEV_DATA(PyGpuArrayObject *a) {
char * p = *((char **)a->ga.data);
assert((a->ga.offset % gpuarray_get_elsize(a->ga.typecode)) == 0);
/* This only works on cuda */
return (void *)(p + a->ga.offset);
}
#endif #endif
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论