Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

omp_locks: C Array #3796

Merged
merged 1 commit into from Mar 11, 2024
Merged

omp_locks: C Array #3796

merged 1 commit into from Mar 11, 2024

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Mar 11, 2024

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:

  • 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

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
@ax3l ax3l added the bug label Mar 11, 2024
@ax3l ax3l requested a review from WeiqunZhang March 11, 2024 05:42
ax3l added a commit to ax3l/amrex-feedstock that referenced this pull request Mar 11, 2024
Patch in
  AMReX-Codes/amrex#3796
for `omp_locks` on Windows builds.
@ax3l
Copy link
Member Author

ax3l commented Mar 11, 2024

The error now is:

lld-link: error: undefined symbol: __declspec(dllimport) struct omp_lock_t *amrex::OpenMP::omp_locks

@WeiqunZhang
Copy link
Member

The types in OMP are likely simple C types. So it should not be an issue for std::array. Even if it is so, it should have failed before the link stage.

In llvm, omp_lock_t is a simple struct with a void*.

https://github.com/llvm/llvm-project/blob/ad8c8281363261929b53b0a519cd20e9e2445343/openmp/runtime/src/include/omp.h.var#L83

Anyway, we can merge this and try to fix it in another way.

@WeiqunZhang WeiqunZhang merged commit d4dcb01 into AMReX-Codes:development Mar 11, 2024
69 checks passed
@ax3l ax3l deleted the fix-omp_locks branch March 11, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants