Skip to content

Check if malloc_device return nullptr in matmul code #1493

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion dpctl/tensor/libtensor/include/kernels/linalg_functions/gemm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,9 @@ sycl::event gemm_tree_k_impl(sycl::queue &exec_q,
if (reduction_nelems < wg) {
resTy *tmp = sycl::malloc_device<resTy>(
iter_nelems * reduction_nelems, exec_q);
if (!tmp) {
throw std::runtime_error("Unable to allocate device memory");
}
sycl::event gemm_ev = exec_q.submit([&](sycl::handler &cgh) {
cgh.depends_on(depends);

Expand Down Expand Up @@ -2144,7 +2147,7 @@ sycl::event gemm_tree_k_impl(sycl::queue &exec_q,
resTy *partially_reduced_tmp2 = nullptr;

if (partially_reduced_tmp == nullptr) {
throw std::runtime_error("Unable to allocate device_memory");
throw std::runtime_error("Unable to allocate device memory");
}
else {
partially_reduced_tmp2 =
Expand Down Expand Up @@ -2360,6 +2363,9 @@ sycl::event gemm_tree_nm_impl(sycl::queue &exec_q,
if (reduction_nelems < wg) {
resTy *tmp = sycl::malloc_device<resTy>(
iter_nelems * reduction_nelems, exec_q);
if (!tmp) {
throw std::runtime_error("Unable to allocate device memory");
}
sycl::event gemm_ev = exec_q.submit([&](sycl::handler &cgh) {
cgh.depends_on(depends);

Expand Down Expand Up @@ -2768,6 +2774,9 @@ sycl::event gemm_contig_tree_k_impl(sycl::queue &exec_q,
if (reduction_nelems < wg) {
resTy *tmp = sycl::malloc_device<resTy>(
iter_nelems * reduction_nelems, exec_q);
if (!tmp) {
throw std::runtime_error("Unable to allocate device memory");
}
sycl::event gemm_ev = exec_q.submit([&](sycl::handler &cgh) {
cgh.depends_on(depends);

Expand Down Expand Up @@ -3092,6 +3101,9 @@ sycl::event gemm_contig_tree_nm_impl(sycl::queue &exec_q,
if (reduction_nelems < wg) {
resTy *tmp = sycl::malloc_device<resTy>(
iter_nelems * reduction_nelems, exec_q);
if (!tmp) {
throw std::runtime_error("Unable to allocate device memory");
}
sycl::event gemm_ev = exec_q.submit([&](sycl::handler &cgh) {
cgh.depends_on(depends);

Expand Down Expand Up @@ -5254,6 +5266,9 @@ gemm_batch_tree_k_impl(sycl::queue &exec_q,
if (reduction_nelems < wg) {
resTy *tmp = sycl::malloc_device<resTy>(
iter_nelems * reduction_nelems, exec_q);
if (!tmp) {
throw std::runtime_error("Unable to allocate device memory");
}
sycl::event gemm_ev = exec_q.submit([&](sycl::handler &cgh) {
cgh.depends_on(depends);

Expand Down Expand Up @@ -5647,6 +5662,9 @@ gemm_batch_tree_nm_impl(sycl::queue &exec_q,
if (reduction_nelems < wg) {
resTy *tmp = sycl::malloc_device<resTy>(
iter_nelems * reduction_nelems, exec_q);
if (!tmp) {
throw std::runtime_error("Unable to allocate device memory");
}
sycl::event gemm_ev = exec_q.submit([&](sycl::handler &cgh) {
cgh.depends_on(depends);

Expand Down Expand Up @@ -6124,6 +6142,9 @@ gemm_batch_contig_tree_k_impl(sycl::queue &exec_q,
if (reduction_nelems < wg) {
resTy *tmp = sycl::malloc_device<resTy>(
iter_nelems * reduction_nelems, exec_q);
if (!tmp) {
throw std::runtime_error("Unable to allocate device memory");
}
sycl::event gemm_ev = exec_q.submit([&](sycl::handler &cgh) {
cgh.depends_on(depends);

Expand Down Expand Up @@ -6493,6 +6514,9 @@ gemm_batch_contig_tree_nm_impl(sycl::queue &exec_q,
if (reduction_nelems < wg) {
resTy *tmp = sycl::malloc_device<resTy>(
iter_nelems * reduction_nelems, exec_q);
if (!tmp) {
throw std::runtime_error("Unable to allocate device memory");
}
sycl::event gemm_ev = exec_q.submit([&](sycl::handler &cgh) {
cgh.depends_on(depends);

Expand Down