Skip to content

Commit 5b4ca7e

Browse files
authored
Merge pull request #424 from lamblin/help_debug
Small things to help debug
2 parents 92f9977 + 83d1868 commit 5b4ca7e

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

src/gpuarray_array_blas.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include "gpuarray/buffer_blas.h"
44
#include "gpuarray/types.h"
55
#include "gpuarray/util.h"
6-
#include "gpuarray/error.h"
6+
7+
#include "private.h"
8+
#include "util/error.h"
79

810
int GpuArray_rdot(GpuArray *X, GpuArray *Y,
911
GpuArray *Z, int nocopy) {
@@ -13,24 +15,28 @@ int GpuArray_rdot(GpuArray *X, GpuArray *Y,
1315
GpuArray copyY;
1416
GpuArray *Zp = Z;
1517
size_t n;
16-
void *ctx;
18+
gpucontext *ctx = gpudata_context(Xp->data);
1719
size_t elsize;
1820
int err;
1921

2022
if (X->typecode != GA_HALF &&
2123
X->typecode != GA_FLOAT &&
2224
X->typecode != GA_DOUBLE)
23-
return GA_INVALID_ERROR;
25+
return error_set(ctx->err, GA_INVALID_ERROR, "Data type not supported");
2426

2527
if (X->nd != 1 || Y->nd != 1 || Z->nd != 0 ||
2628
X->typecode != Y->typecode || X->typecode != Z->typecode)
27-
return GA_VALUE_ERROR;
29+
return error_fmt(ctx->err, GA_VALUE_ERROR,
30+
"Wrong number of dimensions: X->nd = %d (expected 1), Y->nd = %d (expected 1), Z->nd = %d (expected 0)",
31+
X->nd, Y->nd, Z->nd);
2832
n = X->dimensions[0];
2933
if (!(X->flags & GA_ALIGNED) || !(Y->flags & GA_ALIGNED) ||
3034
!(Z->flags & GA_ALIGNED))
3135
return GA_UNALIGNED_ERROR;
3236
if (X->dimensions[0] != Y->dimensions[0])
33-
return GA_VALUE_ERROR;
37+
return error_fmt(ctx->err, GA_VALUE_ERROR,
38+
"Shape mismatch: X->dimensions[0] = %d != Y->dimensions[0] = %d",
39+
X->dimensions[0], Y->dimensions[0]);
3440

3541
elsize = gpuarray_get_elsize(X->typecode);
3642
if (X->strides[0] < 0) {
@@ -49,12 +55,11 @@ int GpuArray_rdot(GpuArray *X, GpuArray *Y,
4955
else {
5056
err = GpuArray_copy(&copyY, Y, GA_ANY_ORDER);
5157
if (err != GA_NO_ERROR)
52-
goto cleanup;
58+
goto cleanup;
5359
Yp = &copyY;
5460
}
5561
}
5662

57-
ctx = gpudata_context(Xp->data);
5863
err = gpublas_setup(ctx);
5964
if (err != GA_NO_ERROR)
6065
goto cleanup;
@@ -138,7 +143,7 @@ int GpuArray_rgemv(cb_transpose transA, double alpha, GpuArray *A,
138143
else {
139144
err = GpuArray_copy(&copyA, A, GA_F_ORDER);
140145
if (err != GA_NO_ERROR)
141-
goto cleanup;
146+
goto cleanup;
142147
Ap = &copyA;
143148
}
144149
}
@@ -148,7 +153,7 @@ int GpuArray_rgemv(cb_transpose transA, double alpha, GpuArray *A,
148153
else {
149154
err = GpuArray_copy(&copyX, X, GA_ANY_ORDER);
150155
if (err != GA_NO_ERROR)
151-
goto cleanup;
156+
goto cleanup;
152157
Xp = &copyX;
153158
}
154159
}

src/gpuarray_buffer_cuda.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,10 @@ static int call_compiler(cuda_context *ctx, strb *src, strb *ptx, strb *log) {
11031103

11041104
if (err != NVRTC_SUCCESS) {
11051105
nvrtcDestroyProgram(&prog);
1106+
#ifdef DEBUG
1107+
strb_dump(src, stderr);
1108+
strb_dump(log, stderr);
1109+
#endif
11061110
return error_nvrtc(ctx->err, "nvrtcCompileProgram", err);
11071111
}
11081112

0 commit comments

Comments
 (0)