Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move lapack_info_check inside of onemkl_cusolver_host_task #238

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Next Next commit
Move dev_info check to host_task
aidan.belton committed Aug 16, 2022
commit 92083875adf7be2549c1373a7d72c088728c4f55
37 changes: 19 additions & 18 deletions src/lapack/backends/cusolver/cusolver_helper.hpp
Original file line number Diff line number Diff line change
@@ -261,26 +261,27 @@ struct CudaEquivalentType<std::complex<double>> {

/* devinfo */

inline int get_cusolver_devinfo(sycl::queue &queue, sycl::buffer<int> &devInfo) {
sycl::host_accessor<int, 1, sycl::access::mode::read> dev_info_{ devInfo };
return dev_info_[0];
}

inline int get_cusolver_devinfo(sycl::queue &queue, const int *devInfo) {
int dev_info_;
queue.wait();
queue.memcpy(&dev_info_, devInfo, sizeof(int));
return dev_info_;
// Accepts a int*, copies the memory from device to host,
// checks value does not indicate an error, frees the device memory
inline void lapack_info_check_and_free(int *dev_info_d, const char *func_name,
const char *cufunc_name, int num_elements = 1) {
int *dev_info_h = (int *)malloc(sizeof(int) * num_elements);
cuMemcpyDtoH(dev_info_h, reinterpret_cast<CUdeviceptr>(dev_info_d), sizeof(int) * num_elements);
for (uint32_t i = 0; i < num_elements; ++i) {
if (dev_info_h[i] > 0)
throw oneapi::mkl::lapack::computation_error(
func_name,
std::string(cufunc_name) + " failed with info = " + std::to_string(dev_info_h[i]),
dev_info_h[i]);
}
cuMemFree(reinterpret_cast<CUdeviceptr>(dev_info_d));
}

template <typename DEVINFO_T>
inline void lapack_info_check(sycl::queue &queue, DEVINFO_T devinfo, const char *func_name,
const char *cufunc_name) {
const int devinfo_ = get_cusolver_devinfo(queue, devinfo);
if (devinfo_ > 0)
throw oneapi::mkl::lapack::computation_error(
func_name, std::string(cufunc_name) + " failed with info = " + std::to_string(devinfo_),
devinfo_);
// Allocates and returns a CUDA device pointer for cuSolver dev_info
inline int *create_dev_info(int num_elements = 1) {
CUdeviceptr dev_info_d;
cuMemAlloc(&dev_info_d, sizeof(int) * num_elements);
return reinterpret_cast<int *>(dev_info_d);
}

} // namespace cusolver
Loading