@@ -56,6 +56,10 @@ inline void asum(Func func, cl::sycl::queue &queue, int64_t n, cl::sycl::buffer<
56
56
cublasStatus_t err;
57
57
// ASUM does not support negative index
58
58
CUBLAS_ERROR_FUNC (func, err, handle, n, x_, std::abs (incx), res_);
59
+ // Higher level BLAS functions expect CUBLAS_POINTER_MODE_HOST
60
+ // to be set, therfore we need to reset this to the default value
61
+ // in order to avoid CUDA_ERROR_ILLEGAL_ADRESS errors
62
+ cublasSetPointerMode (handle, CUBLAS_POINTER_MODE_HOST);
59
63
});
60
64
});
61
65
}
@@ -160,6 +164,10 @@ inline void rotg(Func func, cl::sycl::queue &queue, cl::sycl::buffer<T1, 1> &a,
160
164
auto s_ = sc.get_mem <cuDataType1 *>(ih, s_acc);
161
165
cublasStatus_t err;
162
166
CUBLAS_ERROR_FUNC (func, err, handle, a_, b_, c_, s_);
167
+ // Higher level BLAS functions expect CUBLAS_POINTER_MODE_HOST
168
+ // to be set, therfore we need to reset this to the default value
169
+ // in order to avoid CUDA_ERROR_ILLEGAL_ADRESS errors
170
+ cublasSetPointerMode (handle, CUBLAS_POINTER_MODE_HOST);
163
171
});
164
172
});
165
173
}
@@ -201,6 +209,10 @@ inline void rotm(Func func, cl::sycl::queue &queue, int64_t n, cl::sycl::buffer<
201
209
auto param_ = sc.get_mem <cuDataType *>(ih, param_acc);
202
210
cublasStatus_t err;
203
211
CUBLAS_ERROR_FUNC (func, err, handle, n, x_, incx, y_, incy, param_);
212
+ // Higher level BLAS functions expect CUBLAS_POINTER_MODE_HOST
213
+ // to be set, therfore we need to reset this to the default value
214
+ // in order to avoid CUDA_ERROR_ILLEGAL_ADRESS errors
215
+ cublasSetPointerMode (handle, CUBLAS_POINTER_MODE_HOST);
204
216
});
205
217
});
206
218
}
@@ -270,6 +282,10 @@ inline void dot(Func func, cl::sycl::queue &queue, int64_t n, cl::sycl::buffer<T
270
282
auto res_ = sc.get_mem <cuDataType *>(ih, res_acc);
271
283
cublasStatus_t err;
272
284
CUBLAS_ERROR_FUNC (func, err, handle, n, x_, incx, y_, incy, res_);
285
+ // Higher level BLAS functions expect CUBLAS_POINTER_MODE_HOST
286
+ // to be set, therfore we need to reset this to the default value
287
+ // in order to avoid CUDA_ERROR_ILLEGAL_ADRESS errors
288
+ cublasSetPointerMode (handle, CUBLAS_POINTER_MODE_HOST);
273
289
});
274
290
});
275
291
}
@@ -301,12 +317,6 @@ inline void rot(Func func, cl::sycl::queue &queue, int64_t n, cl::sycl::buffer<T
301
317
cgh.interop_task ([=](cl::sycl::interop_handler ih) {
302
318
auto sc = CublasScopedContextHandler (queue);
303
319
auto handle = sc.get_handle (queue);
304
- // By default the pointer mode is the CUBLAS_POINTER_MODE_HOST
305
- // when the data is on buffer, it must be set to
306
- // CUBLAS_POINTER_MODE_DEVICE mode otherwise it causes the segmentation
307
- // fault. When it is set to device it is users responsibility to
308
- // synchronise as the function is completely asynchronous.
309
- // cublasSetPointerMode(handle, CUBLAS_POINTER_MODE_DEVICE);
310
320
auto x_ = sc.get_mem <cuDataType1 *>(ih, x_acc);
311
321
auto y_ = sc.get_mem <cuDataType1 *>(ih, y_acc);
312
322
cublasStatus_t err;
@@ -351,6 +361,10 @@ void sdsdot(cl::sycl::queue &queue, int64_t n, float sb, cl::sycl::buffer<float,
351
361
auto res_ = sc.get_mem <float *>(ih, res_acc);
352
362
cublasStatus_t err;
353
363
CUBLAS_ERROR_FUNC (cublasSdot, err, handle, n, x_, incx, y_, incy, res_);
364
+ // Higher level BLAS functions expect CUBLAS_POINTER_MODE_HOST
365
+ // to be set, therfore we need to reset this to the default value
366
+ // in order to avoid CUDA_ERROR_ILLEGAL_ADRESS errors
367
+ cublasSetPointerMode (handle, CUBLAS_POINTER_MODE_HOST);
354
368
});
355
369
});
356
370
// Since SB is a host pointer we need to bring the result back to the host and
@@ -391,6 +405,10 @@ inline void rotmg(Func func, cl::sycl::queue &queue, cl::sycl::buffer<T, 1> &d1,
391
405
auto param_ = sc.get_mem <cuDataType *>(ih, param_acc);
392
406
cublasStatus_t err;
393
407
CUBLAS_ERROR_FUNC (func, err, handle, d1_, d2_, x1_, y1_, param_);
408
+ // Higher level BLAS functions expect CUBLAS_POINTER_MODE_HOST
409
+ // to be set, therfore we need to reset this to the default value
410
+ // in order to avoid CUDA_ERROR_ILLEGAL_ADRESS errors
411
+ cublasSetPointerMode (handle, CUBLAS_POINTER_MODE_HOST);
394
412
});
395
413
});
396
414
}
@@ -437,6 +455,10 @@ inline void iamax(Func func, cl::sycl::queue &queue, int64_t n, cl::sycl::buffer
437
455
// For negative incx, iamax returns 0. This behaviour is similar to that of
438
456
// reference netlib BLAS.
439
457
CUBLAS_ERROR_FUNC (func, err, handle, n, x_, incx, int_res_);
458
+ // Higher level BLAS functions expect CUBLAS_POINTER_MODE_HOST
459
+ // to be set, therfore we need to reset this to the default value
460
+ // in order to avoid CUDA_ERROR_ILLEGAL_ADRESS errors
461
+ cublasSetPointerMode (handle, CUBLAS_POINTER_MODE_HOST);
440
462
});
441
463
});
442
464
// This requires to bring the data to host, copy it, and return it back to
@@ -519,6 +541,10 @@ inline void iamin(Func func, cl::sycl::queue &queue, int64_t n, cl::sycl::buffer
519
541
// For negative incx, iamin returns 0. This behaviour is similar to that of
520
542
// implemented as a reference IAMIN.
521
543
CUBLAS_ERROR_FUNC (func, err, handle, n, x_, incx, int_res_);
544
+ // Higher level BLAS functions expect CUBLAS_POINTER_MODE_HOST
545
+ // to be set, therfore we need to reset this to the default value
546
+ // in order to avoid CUDA_ERROR_ILLEGAL_ADRESS errors
547
+ cublasSetPointerMode (handle, CUBLAS_POINTER_MODE_HOST);
522
548
});
523
549
});
524
550
result.template get_access <cl::sycl::access::mode::write>()[0 ] =
@@ -561,6 +587,10 @@ inline void nrm2(Func func, cl::sycl::queue &queue, int64_t n, cl::sycl::buffer<
561
587
cublasStatus_t err;
562
588
// NRM2 does not support negative index
563
589
CUBLAS_ERROR_FUNC (func, err, handle, n, x_, std::abs (incx), res_);
590
+ // Higher level BLAS functions expect CUBLAS_POINTER_MODE_HOST
591
+ // to be set, therfore we need to reset this to the default value
592
+ // in order to avoid CUDA_ERROR_ILLEGAL_ADRESS errors
593
+ cublasSetPointerMode (handle, CUBLAS_POINTER_MODE_HOST);
564
594
});
565
595
});
566
596
}
0 commit comments