Skip to content

Commit 73f3822

Browse files
committed
Add offset to arrays in DEBUG to help catch errors.
1 parent 27e0aff commit 73f3822

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/gpuarray_array.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,20 @@ int GpuArray_empty(GpuArray *a, gpucontext *ctx, int typecode,
119119
size *= d;
120120
}
121121

122+
/* We add a offset of 64 to all arrays in DEBUG to help catch errors. */
123+
#ifdef DEBUG
124+
assert(SIZE_MAX - size > 64);
125+
size += 64;
126+
#endif
127+
122128
a->data = gpudata_alloc(ctx, size, NULL, 0, &res);
123129
if (a->data == NULL) return res;
124130
a->nd = nd;
131+
#ifdef DEBUG
132+
a->offset = 64;
133+
#else
125134
a->offset = 0;
135+
#endif
126136
a->typecode = typecode;
127137
a->dimensions = calloc(nd, sizeof(size_t));
128138
a->strides = calloc(nd, sizeof(ssize_t));

0 commit comments

Comments
 (0)