Skip to content

Commit

Permalink
OpenMPSmartStatic_SPMV.hpp: throw if posix_memalign fails (#2368)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwpearson authored Oct 10, 2024
1 parent adc025b commit c7df61d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions perf_test/sparse/spmv/OpenMPSmartStatic_SPMV.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifdef KOKKOS_ENABLE_OPENMP

#include <omp.h>
#include <sstream>
#include <stdexcept>

#define OMP_BENCH_RESTRICT __restrict__

Expand All @@ -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();
Expand Down

0 comments on commit c7df61d

Please sign in to comment.