Skip to content

Commit

Permalink
omp_locks: C Array
Browse files Browse the repository at this point in the history
Use a plain C array over a `std::array` for `omp_locks`.
Primarily because this causes linker issues on MSVC, secondarily
because `omp_locks` might violate on some implementations the
type requirements of `std::array` (MoveConstructible and
MoveAssignable type `T`).
https://en.cppreference.com/w/cpp/container/array
  • Loading branch information
ax3l committed Mar 11, 2024
1 parent ba95d4c commit a2d224f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Src/Base/AMReX_OpenMP.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifdef AMREX_USE_OMP
#include <AMReX_Extension.H>
#include <omp.h>
#include <array>

namespace amrex::OpenMP {

Expand All @@ -19,7 +18,7 @@ namespace amrex::OpenMP {
void Finalize ();

static constexpr int nlocks = 128;
extern AMREX_EXPORT std::array<omp_lock_t,nlocks> omp_locks;
extern AMREX_EXPORT omp_lock_t omp_locks[nlocks];
}

#else // AMREX_USE_OMP
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace amrex
#ifdef AMREX_USE_OMP
namespace amrex::OpenMP
{
std::array<omp_lock_t,nlocks> omp_locks;
omp_lock_t omp_locks[nlocks];

namespace {
unsigned int initialized = 0;
Expand Down

0 comments on commit a2d224f

Please sign in to comment.