From 4a1610d7052ef51c35a00ec06e5496a90a888a18 Mon Sep 17 00:00:00 2001 From: Salvatore Filippone Date: Wed, 30 Apr 2025 11:52:05 +0200 Subject: [PATCH] Add check for allocation in certain OpenMP paths --- base/serial/impl/psb_c_csr_impl.F90 | 8 ++++++-- base/serial/impl/psb_d_csr_impl.F90 | 8 ++++++-- base/serial/impl/psb_s_csr_impl.F90 | 8 ++++++-- base/serial/impl/psb_z_csr_impl.F90 | 8 ++++++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/base/serial/impl/psb_c_csr_impl.F90 b/base/serial/impl/psb_c_csr_impl.F90 index 0e040a7b..9b9090cd 100644 --- a/base/serial/impl/psb_c_csr_impl.F90 +++ b/base/serial/impl/psb_c_csr_impl.F90 @@ -3817,14 +3817,18 @@ contains ! dense accumulator ! https://sc18.supercomputing.org/proceedings/workshops/workshop_files/ws_lasalss115s2-file1.pdf call psb_realloc(nb, acc, info) - !$omp parallel shared(nth,lth) + !$omp parallel shared(nth,lth,offsets,info) !$omp single nth = omp_get_num_threads() lth = min(nth, ma) + allocate(offsets(omp_get_max_threads()),stat=info) !$omp end single !$omp end parallel + if (info /= 0) then + write(0,*)'Offsets allocation failed ',info + return + end if - allocate(offsets(omp_get_max_threads())) !$omp parallel private(vals,col_inds,nnz,rwnz,thread_upperbound,acc,start_idx,end_idx) & !$omp num_threads(lth) shared(a,b,c,offsets) thread_upperbound = 0 diff --git a/base/serial/impl/psb_d_csr_impl.F90 b/base/serial/impl/psb_d_csr_impl.F90 index d6b6e9cb..b689d189 100644 --- a/base/serial/impl/psb_d_csr_impl.F90 +++ b/base/serial/impl/psb_d_csr_impl.F90 @@ -3817,14 +3817,18 @@ contains ! dense accumulator ! https://sc18.supercomputing.org/proceedings/workshops/workshop_files/ws_lasalss115s2-file1.pdf call psb_realloc(nb, acc, info) - !$omp parallel shared(nth,lth) + !$omp parallel shared(nth,lth,offsets,info) !$omp single nth = omp_get_num_threads() lth = min(nth, ma) + allocate(offsets(omp_get_max_threads()),stat=info) !$omp end single !$omp end parallel + if (info /= 0) then + write(0,*)'Offsets allocation failed ',info + return + end if - allocate(offsets(omp_get_max_threads())) !$omp parallel private(vals,col_inds,nnz,rwnz,thread_upperbound,acc,start_idx,end_idx) & !$omp num_threads(lth) shared(a,b,c,offsets) thread_upperbound = 0 diff --git a/base/serial/impl/psb_s_csr_impl.F90 b/base/serial/impl/psb_s_csr_impl.F90 index 49d168bb..460f2cab 100644 --- a/base/serial/impl/psb_s_csr_impl.F90 +++ b/base/serial/impl/psb_s_csr_impl.F90 @@ -3817,14 +3817,18 @@ contains ! dense accumulator ! https://sc18.supercomputing.org/proceedings/workshops/workshop_files/ws_lasalss115s2-file1.pdf call psb_realloc(nb, acc, info) - !$omp parallel shared(nth,lth) + !$omp parallel shared(nth,lth,offsets,info) !$omp single nth = omp_get_num_threads() lth = min(nth, ma) + allocate(offsets(omp_get_max_threads()),stat=info) !$omp end single !$omp end parallel + if (info /= 0) then + write(0,*)'Offsets allocation failed ',info + return + end if - allocate(offsets(omp_get_max_threads())) !$omp parallel private(vals,col_inds,nnz,rwnz,thread_upperbound,acc,start_idx,end_idx) & !$omp num_threads(lth) shared(a,b,c,offsets) thread_upperbound = 0 diff --git a/base/serial/impl/psb_z_csr_impl.F90 b/base/serial/impl/psb_z_csr_impl.F90 index 1fc387d8..8141fb99 100644 --- a/base/serial/impl/psb_z_csr_impl.F90 +++ b/base/serial/impl/psb_z_csr_impl.F90 @@ -3817,14 +3817,18 @@ contains ! dense accumulator ! https://sc18.supercomputing.org/proceedings/workshops/workshop_files/ws_lasalss115s2-file1.pdf call psb_realloc(nb, acc, info) - !$omp parallel shared(nth,lth) + !$omp parallel shared(nth,lth,offsets,info) !$omp single nth = omp_get_num_threads() lth = min(nth, ma) + allocate(offsets(omp_get_max_threads()),stat=info) !$omp end single !$omp end parallel + if (info /= 0) then + write(0,*)'Offsets allocation failed ',info + return + end if - allocate(offsets(omp_get_max_threads())) !$omp parallel private(vals,col_inds,nnz,rwnz,thread_upperbound,acc,start_idx,end_idx) & !$omp num_threads(lth) shared(a,b,c,offsets) thread_upperbound = 0