Skip to content

Commit e0be74d

Browse files
committed
Fix compile.
1 parent c769bcb commit e0be74d

5 files changed

Lines changed: 23 additions & 14 deletions

File tree

src/gpuarray_array_blas.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ int GpuArray_rgemv(cb_transpose transA, double alpha, GpuArray *A,
102102
GpuArray *Xp = X;
103103
GpuArray copyX;
104104
GpuArray *Yp = Y;
105+
gpucontext *ctx = gpudata_context(Ap->data);
105106
size_t elsize;
106107
size_t m, n, lda;
107108
cb_order o;
108109
int err;
109-
void *ctx = gpudata_context(Ap->data);
110110

111111
if (A->typecode != GA_HALF &&
112112
A->typecode != GA_FLOAT &&
@@ -205,7 +205,7 @@ int GpuArray_rgemm(cb_transpose transA, cb_transpose transB, double alpha,
205205
GpuArray *Bp = B;
206206
GpuArray copyB;
207207
GpuArray *Cp = C;
208-
void *ctx = gpudata_context(Ap->data);
208+
gpucontext *ctx = gpudata_context(Ap->data);
209209
size_t elsize;
210210
size_t m, n, k, lda, ldb, ldc;
211211
cb_order o;
@@ -355,7 +355,7 @@ int GpuArray_rger(double alpha, GpuArray *X, GpuArray *Y, GpuArray *A,
355355
GpuArray *Yp = Y;
356356
GpuArray copyY;
357357
GpuArray *Ap = A;
358-
void *ctx = gpudata_context(Xp->data);
358+
gpucontext *ctx = gpudata_context(Xp->data);
359359
size_t elsize;
360360
size_t m, n, lda;
361361
cb_order o;
@@ -372,12 +372,12 @@ int GpuArray_rger(double alpha, GpuArray *X, GpuArray *Y, GpuArray *A,
372372

373373
if (!(X->flags & GA_ALIGNED) || !(Y->flags & GA_ALIGNED) ||
374374
!(A->flags & GA_ALIGNED))
375-
return error_set(ctx->err, GA_UNALIGNED_ERROR, "Unaligned inputs";
375+
return error_set(ctx->err, GA_UNALIGNED_ERROR, "Unaligned inputs");
376376

377377
m = X->dimensions[0];
378378
n = Y->dimensions[0];
379379
if (A->dimensions[0] != m || A->dimensions[1] != n)
380-
return error_set(ctx->err, GA_VALUE_ERROR, "Incompatible shapes";
380+
return error_set(ctx->err, GA_VALUE_ERROR, "Incompatible shapes");
381381

382382
elsize = gpuarray_get_elsize(X->typecode);
383383

@@ -468,7 +468,7 @@ int GpuArray_rgemmBatch_3d(cb_transpose transA, cb_transpose transB, double alph
468468
GpuArray *Bp = B;
469469
GpuArray copyB;
470470
GpuArray *Cp = C;
471-
void *ctx = gpudata_context(A->data);
471+
gpucontext *ctx = gpudata_context(A->data);
472472
size_t elsize;
473473
size_t batchCount, m, n, k, lda, ldb, ldc;
474474
cb_order o;

src/gpuarray_array_collectives.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static inline int check_gpuarrays(int times_src, const GpuArray* src,
4949

5050
int GpuArray_reduce_from(const GpuArray* src, int opcode, int root,
5151
gpucomm* comm) {
52+
gpucontext *ctx = gpudata_context(src->data);
5253
size_t total_elems;
5354
if (!GpuArray_ISALIGNED(src))
5455
return error_set(ctx->err, GA_UNALIGNED_ERROR, "Unaligned input");
@@ -90,9 +91,11 @@ int GpuArray_reduce_scatter(const GpuArray* src, GpuArray* dest, int opcode,
9091
comm);
9192
}
9293

93-
int GpuArray_broadcast(GpuArray* array, int root, gpucomm* comm) {
94-
int rank = 0;
94+
int GpuArray_broadcast(GpuArray *array, int root, gpucomm *comm) {
95+
gpucontext *ctx = gpudata_context(array->data);
9596
size_t total_elems;
97+
int rank = 0;
98+
9699
GA_CHECK(gpucomm_get_rank(comm, &rank));
97100
if (rank == root) {
98101
if (!GpuArray_CHKFLAGS(array, GA_BEHAVED))

src/gpuarray_buffer.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const gpuarray_buffer_ops *gpuarray_get_ops(const char *name) {
2323
int gpu_get_platform_count(const char* name, unsigned int* platcount) {
2424
const gpuarray_buffer_ops* ops = gpuarray_get_ops(name);
2525
if (ops == NULL) {
26-
return error_set(&global_err, GA_INVALID_ERROR, "Invalid platform");
26+
return error_set(global_err, GA_INVALID_ERROR, "Invalid platform");
2727
}
2828
return ops->get_platform_count(platcount);
2929
}
@@ -32,7 +32,7 @@ int gpu_get_device_count(const char* name, unsigned int platform,
3232
unsigned int* devcount) {
3333
const gpuarray_buffer_ops* ops = gpuarray_get_ops(name);
3434
if (ops == NULL) {
35-
return error_set(&global_err, GA_INVALID_ERROR, "Invalid platform");
35+
return error_set(global_err, GA_INVALID_ERROR, "Invalid platform");
3636
}
3737
return ops->get_device_count(platform, devcount);
3838
}
@@ -121,8 +121,10 @@ int gpudata_transfer(gpudata *dst, size_t dstoff, gpudata *src, size_t srcoff,
121121

122122
/* Fallback to host copy */
123123
tmp = malloc(sz);
124-
if (tmp == NULL)
125-
return error_sys(ctx->err, "malloc");
124+
if (tmp == NULL) {
125+
error_sys(src_ctx->err, "malloc");
126+
return error_sys(dst_ctx->err, "malloc");
127+
}
126128
res = src_ctx->ops->buffer_read(tmp, src, srcoff, sz);
127129
if (res != GA_NO_ERROR) {
128130
free(tmp);

src/gpuarray_elemwise.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ static int check_basic(GpuElemwise *ge, void **args, int flags,
272272
size_t *_n, unsigned int *_nd, size_t **_dims,
273273
ssize_t ***_strides, int *_call32) {
274274
size_t n;
275+
gpucontext *ctx = GpuKernel_context(&ge->k_contig);
275276
GpuArray *a = NULL, *v;
276277
unsigned int i, j, p, num_arrays = 0, nd = 0, nnd;
277278
int call32 = 1;
@@ -443,7 +444,7 @@ static int gen_elemwise_contig_kernel(GpuKernel *k,
443444

444445
ktypes = calloc(p, sizeof(int));
445446
if (ktypes == NULL) {
446-
res = error_fmt(ctx->err, "calloc");
447+
res = error_sys(ctx->err, "calloc");
447448
goto bail;
448449
}
449450

@@ -511,7 +512,7 @@ static int gen_elemwise_contig_kernel(GpuKernel *k,
511512
strb_appends(&sb, "}\n}\n");
512513

513514
if (strb_error(&sb)) {
514-
error_set(ctx->err, GA_MISC_ERROR, "Formatting error creating kernel source");
515+
res = error_set(ctx->err, GA_MISC_ERROR, "Formatting error creating kernel source");
515516
goto bail;
516517
}
517518

src/gpuarray_kernel.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include "gpuarray/error.h"
33
#include "gpuarray/types.h"
44

5+
#include "util/error.h"
6+
#include "private.h"
7+
58
#include <stdlib.h>
69

710
int GpuKernel_init(GpuKernel *k, gpucontext *ctx, unsigned int count,

0 commit comments

Comments
 (0)