-
Notifications
You must be signed in to change notification settings - Fork 370
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: Avoid extern global variable #3798
Conversation
Make `omp_locks` a variable in an unnamed namespace instead of an extern global variable. This might potentially fix the Windows symbol issue (AMReX-Codes#3795).
Generally, I am wondering if Clang-Cl's |
Now it has a link error with:
|
New attempt w/ flags: conda-forge/impactx-feedstock#29 ... no change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this does not solve the Windows symbol issue yet, this is clearly cleaner :)
Does the type All the other OpenMP functions are defined as |
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it complains about this, maybe an export here helps:
omp_lock_t* get_lock (int ilock); | |
AMREX_EXPORT omp_lock_t* get_lock (int ilock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still the same issue on Windows:
[48/49] C:\Windows\system32\cmd.exe /C "cd . && %BUILD_PREFIX%\Library\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\app.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- %BUILD_PREFIX%\Library\bin\lld-link.exe CMakeFiles\app.dir\src\main.cpp.obj /out:bin\impactx.NOMPI.OMP.DP.OPMD.exe /implib:lib\impactx.NOMPI.OMP.DP.OPMD.lib /pdb:bin\impactx.NOMPI.OMP.DP.OPMD.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console lib\libimpactx.NOMPI.OMP.DP.OPMD.lib lib\buildInfopyImpactX.lib lib\ablastr_3d.lib %PREFIX%\Library\lib\amrex_3d.lib %PREFIX%\Library\lib\libomp.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && C:\Windows\system32\cmd.exe /C "cd /D %SRC_DIR%\build && %BUILD_PREFIX%\Library\bin\cmake.exe -E create_symlink impactx.NOMPI.OMP.DP.OPMD.exe D:/bld/impactx_1710432645630/work/build/bin/impactx""
FAILED: bin/impactx.NOMPI.OMP.DP.OPMD.exe
C:\Windows\system32\cmd.exe /C "cd . && %BUILD_PREFIX%\Library\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\app.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- %BUILD_PREFIX%\Library\bin\lld-link.exe CMakeFiles\app.dir\src\main.cpp.obj /out:bin\impactx.NOMPI.OMP.DP.OPMD.exe /implib:lib\impactx.NOMPI.OMP.DP.OPMD.lib /pdb:bin\impactx.NOMPI.OMP.DP.OPMD.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console lib\libimpactx.NOMPI.OMP.DP.OPMD.lib lib\buildInfopyImpactX.lib lib\ablastr_3d.lib %PREFIX%\Library\lib\amrex_3d.lib %PREFIX%\Library\lib\libomp.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && C:\Windows\system32\cmd.exe /C "cd /D %SRC_DIR%\build && %BUILD_PREFIX%\Library\bin\cmake.exe -E create_symlink impactx.NOMPI.OMP.DP.OPMD.exe D:/bld/impactx_1710432645630/work/build/bin/impactx""
LINK: command "%BUILD_PREFIX%\Library\bin\lld-link.exe CMakeFiles\app.dir\src\main.cpp.obj /out:bin\impactx.NOMPI.OMP.DP.OPMD.exe /implib:lib\impactx.NOMPI.OMP.DP.OPMD.lib /pdb:bin\impactx.NOMPI.OMP.DP.OPMD.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console lib\libimpactx.NOMPI.OMP.DP.OPMD.lib lib\buildInfopyImpactX.lib lib\ablastr_3d.lib %PREFIX%\Library\lib\amrex_3d.lib %PREFIX%\Library\lib\libomp.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=1" failed (exit code 1) with the following output:
lld-link: error: undefined symbol: __declspec(dllimport) struct omp_lock_t * __cdecl amrex::OpenMP::get_lock(int)
>>> referenced by libimpactx.NOMPI.OMP.DP.OPMD.lib(ChargeDeposition.cpp.obj):(public: class amrex::BaseFab<double> & __cdecl amrex::BaseFab<double>::lockAdd<1>(class amrex::BaseFab<double> const &, class amrex::Box const &, class amrex::Box const &, int, int, int))
[49/49] C:\Windows\system32\cmd.exe /C "cd . && %BUILD_PREFIX%\Library\bin\cmake.exe -E vs_link_dll --intdir=CMakeFiles\pyImpactX.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- %BUILD_PREFIX%\Library\bin\lld-link.exe CMakeFiles\pyImpactX.dir\src\python\pyImpactX.cpp.obj CMakeFiles\pyImpactX.dir\src\python\distribution.cpp.obj CMakeFiles\pyImpactX.dir\src\python\elements.cpp.obj CMakeFiles\pyImpactX.dir\src\python\ImpactX.cpp.obj CMakeFiles\pyImpactX.dir\src\python\ImpactXParticleContainer.cpp.obj CMakeFiles\pyImpactX.dir\src\python\ReferenceParticle.cpp.obj CMakeFiles\pyImpactX.dir\src\python\transformation.cpp.obj /out:lib\site-packages\impactx\impactx_pybind.cp310-win_amd64.pyd /implib:lib\site-packages\impactx\impactx_pybind.lib /pdb:lib\site-packages\impactx\impactx_pybind.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO -flto lib\libimpactx.NOMPI.OMP.DP.OPMD.lib lib\buildInfopyImpactX.lib lib\ablastr_3d.lib %PREFIX%\Library\lib\amrex_3d.lib %PREFIX%\Library\lib\libomp.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib %PREFIX%\libs\python310.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && C:\Windows\system32\cmd.exe /C "cd /D %SRC_DIR%\build && %BUILD_PREFIX%\Library\bin\cmake.exe -E copy_directory D:/bld/impactx_1710432645630/work/src/python/impactx D:/bld/impactx_1710432645630/work/build/lib/site-packages/impactx""
FAILED: lib/site-packages/impactx/impactx_pybind.cp310-win_amd64.pyd
C:\Windows\system32\cmd.exe /C "cd . && %BUILD_PREFIX%\Library\bin\cmake.exe -E vs_link_dll --intdir=CMakeFiles\pyImpactX.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests -- %BUILD_PREFIX%\Library\bin\lld-link.exe CMakeFiles\pyImpactX.dir\src\python\pyImpactX.cpp.obj CMakeFiles\pyImpactX.dir\src\python\distribution.cpp.obj CMakeFiles\pyImpactX.dir\src\python\elements.cpp.obj CMakeFiles\pyImpactX.dir\src\python\ImpactX.cpp.obj CMakeFiles\pyImpactX.dir\src\python\ImpactXParticleContainer.cpp.obj CMakeFiles\pyImpactX.dir\src\python\ReferenceParticle.cpp.obj CMakeFiles\pyImpactX.dir\src\python\transformation.cpp.obj /out:lib\site-packages\impactx\impactx_pybind.cp310-win_amd64.pyd /implib:lib\site-packages\impactx\impactx_pybind.lib /pdb:lib\site-packages\impactx\impactx_pybind.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO -flto lib\libimpactx.NOMPI.OMP.DP.OPMD.lib lib\buildInfopyImpactX.lib lib\ablastr_3d.lib %PREFIX%\Library\lib\amrex_3d.lib %PREFIX%\Library\lib\libomp.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib %PREFIX%\libs\python310.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && C:\Windows\system32\cmd.exe /C "cd /D %SRC_DIR%\build && %BUILD_PREFIX%\Library\bin\cmake.exe -E copy_directory D:/bld/impactx_1710432645630/work/src/python/impactx D:/bld/impactx_1710432645630/work/build/lib/site-packages/impactx""
LINK: command "%BUILD_PREFIX%\Library\bin\lld-link.exe CMakeFiles\pyImpactX.dir\src\python\pyImpactX.cpp.obj CMakeFiles\pyImpactX.dir\src\python\distribution.cpp.obj CMakeFiles\pyImpactX.dir\src\python\elements.cpp.obj CMakeFiles\pyImpactX.dir\src\python\ImpactX.cpp.obj CMakeFiles\pyImpactX.dir\src\python\ImpactXParticleContainer.cpp.obj CMakeFiles\pyImpactX.dir\src\python\ReferenceParticle.cpp.obj CMakeFiles\pyImpactX.dir\src\python\transformation.cpp.obj /out:lib\site-packages\impactx\impactx_pybind.cp310-win_amd64.pyd /implib:lib\site-packages\impactx\impactx_pybind.lib /pdb:lib\site-packages\impactx\impactx_pybind.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO -flto lib\libimpactx.NOMPI.OMP.DP.OPMD.lib lib\buildInfopyImpactX.lib lib\ablastr_3d.lib %PREFIX%\Library\lib\amrex_3d.lib %PREFIX%\Library\lib\libomp.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib %PREFIX%\Library\lib\openPMD.lib %PREFIX%\Library\lib\adios2_cxx11.lib %PREFIX%\libs\python310.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=2" failed (exit code 1) with the following output:
lld-link: warning: ignoring unknown argument '-flto'
lld-link: error: undefined symbol: __declspec(dllimport) struct omp_lock_t * __cdecl amrex::OpenMP::get_lock(int)
>>> referenced by libimpactx.NOMPI.OMP.DP.OPMD.lib(ChargeDeposition.cpp.obj):(public: class amrex::BaseFab<double> & __cdecl amrex::BaseFab<double>::lockAdd<1>(class amrex::BaseFab<double> const &, class amrex::Box const &, class amrex::Box const &, int, int, int))
ninja: build stopped: subcommand failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be missing includes? #3802
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any missing includes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a test that uses lockAdd to amrex/Tests/ to see if conda-forge Windows build work for amrex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any missing includes.
I wondered how <omp.h>
and AMReX_OpenMP.H
come into downstream files such as ImpactX ChargeDeposition.cpp
and AMReX_BaseFab.H
for BaseFab::lockAdd
. AMReX_MultiFab.H
does not seem to include it directly, must be some transitive path. Anyway, #3802 does some cleaning for directly uses classes for future robustness.
## Summary Execute the `install` and `test_install` targets in Windows CI, too. ## Additional background Increase coverage, e.g., for issues such as #3798 #3802 ## Checklist The proposed changes: - [ ] fix a bug or incorrect behavior in AMReX - [x] 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
## Summary Add includes for directly used types. ## Additional background Related to #3798, I was wondering if there might be an missing include to `BaseFab<double>::lockAdd` and `AMReX_OpenMP.H` somewhere... In the end this is just cleaning. ## 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
Make
omp_locks
a variable in an unnamed namespace instead of an extern global variable.This might potentially fix the Windows symbol issue (#3795).