From c7df61d536c74effb3e4466b011f67f24e85f314 Mon Sep 17 00:00:00 2001 From: Carl Pearson Date: Thu, 10 Oct 2024 09:05:18 -0600 Subject: [PATCH] OpenMPSmartStatic_SPMV.hpp: throw if posix_memalign fails (#2368) --- perf_test/sparse/spmv/OpenMPSmartStatic_SPMV.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/perf_test/sparse/spmv/OpenMPSmartStatic_SPMV.hpp b/perf_test/sparse/spmv/OpenMPSmartStatic_SPMV.hpp index 1967d0d392..37a1fd05ed 100644 --- a/perf_test/sparse/spmv/OpenMPSmartStatic_SPMV.hpp +++ b/perf_test/sparse/spmv/OpenMPSmartStatic_SPMV.hpp @@ -20,6 +20,8 @@ #ifdef KOKKOS_ENABLE_OPENMP #include +#include +#include #define OMP_BENCH_RESTRICT __restrict__ @@ -33,8 +35,16 @@ void establishSmartSchedule(AType A) { // Generate a schedule Ordinal* rowSizes = NULL; - posix_memalign((void**)&rowSizes, 64, sizeof(int) * A.numRows()); - posix_memalign((void**)&threadStarts, 128, sizeof(int) * (omp_get_max_threads() + 1)); + if (posix_memalign((void**)&rowSizes, 64, sizeof(int) * A.numRows())) { + std::stringstream ss; + ss << __FILE__ << ":" << __LINE__ << " posix_memalign failed"; + throw std::runtime_error(ss.str()); + } + if (posix_memalign((void**)&threadStarts, 128, sizeof(int) * (omp_get_max_threads() + 1))) { + std::stringstream ss; + ss << __FILE__ << ":" << __LINE__ << " posix_memalign failed"; + throw std::runtime_error(ss.str()); + } for (int i = 0; i < omp_get_max_threads(); ++i) { threadStarts[i] = A.numRows();