Skip to content

Commit

Permalink
omp_locks: C Array (#3796)
Browse files Browse the repository at this point in the history
## Summary

Use a plain C array over a `std::array` for `omp_locks`. Primarily
because this causes linker issues on MSVC/Clang-Cl, secondarily because
`omp_locks` might violate in some implementations the type requirements
of `std::array` (MoveConstructible and MoveAssignable type `T`).
https://en.cppreference.com/w/cpp/container/array

## Additional background

Potentially a fix for #3795

Testing in conda-forge/impactx-feedstock#28

## Checklist

The proposed changes:
- [x] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
ax3l committed Mar 11, 2024
1 parent ba95d4c commit d4dcb01
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
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
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 d4dcb01

Please sign in to comment.