diff --git a/recipe/3796.patch b/recipe/3796.patch deleted file mode 100644 index 18f635b..0000000 --- a/recipe/3796.patch +++ /dev/null @@ -1,50 +0,0 @@ -From a2d224f28cd76b29a22b0b291c7e07aac2e64ad7 Mon Sep 17 00:00:00 2001 -From: Axel Huebl -Date: Sun, 10 Mar 2024 22:40:16 -0700 -Subject: [PATCH] `omp_locks`: C Array - -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 ---- - Src/Base/AMReX_OpenMP.H | 3 +-- - Src/Base/AMReX_OpenMP.cpp | 2 +- - 2 files changed, 2 insertions(+), 3 deletions(-) - -diff --git a/Src/Base/AMReX_OpenMP.H b/Src/Base/AMReX_OpenMP.H -index 2b53ea8c6e..e31a917145 100644 ---- a/Src/Base/AMReX_OpenMP.H -+++ b/Src/Base/AMReX_OpenMP.H -@@ -5,7 +5,6 @@ - #ifdef AMREX_USE_OMP - #include - #include --#include - - namespace amrex::OpenMP { - -@@ -19,7 +18,7 @@ namespace amrex::OpenMP { - void Finalize (); - - static constexpr int nlocks = 128; -- extern AMREX_EXPORT std::array omp_locks; -+ extern AMREX_EXPORT omp_lock_t omp_locks[nlocks]; - } - - #else // AMREX_USE_OMP -diff --git a/Src/Base/AMReX_OpenMP.cpp b/Src/Base/AMReX_OpenMP.cpp -index 15bb124607..8d7cb13824 100644 ---- a/Src/Base/AMReX_OpenMP.cpp -+++ b/Src/Base/AMReX_OpenMP.cpp -@@ -135,7 +135,7 @@ namespace amrex - #ifdef AMREX_USE_OMP - namespace amrex::OpenMP - { -- std::array omp_locks; -+ omp_lock_t omp_locks[nlocks]; - - namespace { - unsigned int initialized = 0; diff --git a/recipe/3798.patch b/recipe/3798.patch new file mode 100644 index 0000000..64050a2 --- /dev/null +++ b/recipe/3798.patch @@ -0,0 +1,73 @@ +From cdf91b2294b839d0630ec1d5370d1cfd34cb68e9 Mon Sep 17 00:00:00 2001 +From: Weiqun Zhang +Date: Mon, 11 Mar 2024 09:17:34 -0700 +Subject: [PATCH] omp_locks: Avoid extern global variable + +Make `omp_locks` a variable in an unnamed namespace instead of an extern +global variable. + +This might potentially fix the Windows symbol issue (#3795). +--- + Src/Base/AMReX_BaseFab.H | 4 +--- + Src/Base/AMReX_OpenMP.H | 3 +-- + Src/Base/AMReX_OpenMP.cpp | 11 +++++++++-- + 3 files changed, 11 insertions(+), 7 deletions(-) + +diff --git a/Src/Base/AMReX_BaseFab.H b/Src/Base/AMReX_BaseFab.H +index b1224f1400..63bc332f40 100644 +--- a/Src/Base/AMReX_BaseFab.H ++++ b/Src/Base/AMReX_BaseFab.H +@@ -3360,9 +3360,7 @@ BaseFab::lockAdd (const BaseFab& src, const Box& srcbox, const Box& destbo + while (planes_left > 0) { + AMREX_ASSERT(mm < nplanes); + auto const m = mm + plo; +- int ilock = m % OpenMP::nlocks; +- if (ilock < 0) { ilock += OpenMP::nlocks; } +- auto* lock = &(OpenMP::omp_locks[ilock]); ++ auto* lock = OpenMP::get_lock(m); + if (omp_test_lock(lock)) + { + auto lo = dlo; +diff --git a/Src/Base/AMReX_OpenMP.H b/Src/Base/AMReX_OpenMP.H +index e31a917145..15d6854c92 100644 +--- a/Src/Base/AMReX_OpenMP.H ++++ b/Src/Base/AMReX_OpenMP.H +@@ -17,8 +17,7 @@ namespace amrex::OpenMP { + void Initialize (); + void Finalize (); + +- static constexpr int nlocks = 128; +- extern AMREX_EXPORT omp_lock_t omp_locks[nlocks]; ++ omp_lock_t* get_lock (int ilock); + } + + #else // AMREX_USE_OMP +diff --git a/Src/Base/AMReX_OpenMP.cpp b/Src/Base/AMReX_OpenMP.cpp +index 8d7cb13824..03c54b5358 100644 +--- a/Src/Base/AMReX_OpenMP.cpp ++++ b/Src/Base/AMReX_OpenMP.cpp +@@ -135,9 +135,9 @@ namespace amrex + #ifdef AMREX_USE_OMP + namespace amrex::OpenMP + { +- omp_lock_t omp_locks[nlocks]; +- + namespace { ++ constexpr int nlocks = 128; ++ omp_lock_t omp_locks[nlocks]; + unsigned int initialized = 0; + } + +@@ -204,5 +204,12 @@ namespace amrex::OpenMP + } + } + ++ omp_lock_t* get_lock (int ilock) ++ { ++ ilock = ilock % nlocks; ++ if (ilock < 0) { ilock += nlocks; } ++ return omp_locks + ilock; ++ } ++ + } // namespace amrex::OpenMP + #endif // AMREX_USE_OMP diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 19a7949..931269a 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,6 +1,6 @@ {% set name = "amrex" %} {% set version = "24.03" %} -{% set build = 1 %} +{% set build = 2 %} # ensure mpi is defined (needed for conda-smithy recipe-lint) {% set mpi = mpi or 'nompi' %} @@ -19,8 +19,8 @@ source: sha256: 7e87197e8700d52d1ce009faa8df7e1a00027df799a1223c77a84bb5f96830e0 patches: # Linker Error for Windows OpenMP build - # https://github.com/AMReX-Codes/amrex/pull/3796 - - 3796.patch + # https://github.com/AMReX-Codes/amrex/pull/3798 + - 3798.patch build: number: {{ build }}