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

[WIP] Fix OpenMP on Windows #23

Closed
wants to merge 2 commits into from
Closed

[WIP] Fix OpenMP on Windows #23

wants to merge 2 commits into from

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Apr 29, 2024

Working on AMReX-Codes/amrex#3795

Checklist

  • Used a personal fork of the feedstock to propose changes
  • Bumped the build number (if the version is unchanged)
  • Reset the build number to 0 (if the version changed)
  • Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
  • Ensured the license file is being packaged.

@ax3l ax3l added the bug Something isn't working label Apr 29, 2024
@conda-forge-webservices
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@ax3l ax3l changed the title [WIP] Fix OpenMP [WIP] Fix OpenMP on Windows Apr 29, 2024
@ax3l ax3l requested a review from isuruf April 29, 2024 05:32
@ax3l
Copy link
Member Author

ax3l commented Apr 29, 2024

So strange that the OpenMP tests pass here:

...
    llvm-openmp:     18.1.3-h91493d7_0         conda-forge
...
-- Found OpenMP_CXX: -Xclang -fopenmp (found version "5.1")
-- Found OpenMP: TRUE (found version "5.1") found components: CXX
...
--    C++ compiler             = D:/bld/amrex_1714368890030/_build_env/Library/bin/clang-cl.exe
--    C++ flags                = /O2 /Ob2 /DNDEBUG /DWIN32 /D_WINDOWS /GR /EHsc -Xclang -fopenmp
--    Link line                = D:/bld/amrex_1714368890030/_h_env/Library/lib/libomp.lib
...
[599/601] C:\Windows\system32\cmd.exe /C "cd . && %BUILD_PREFIX%\Library\bin\cmake.exe -E vs_link_exe --intdir=Tests\OpenMP\atomicAdd\CMakeFiles\Test_OpenMP_atomicAdd_1d.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  Tests\OpenMP\atomicAdd\CMakeFiles\Test_OpenMP_atomicAdd_1d.dir\main.cpp.obj  /out:Tests\OpenMP\atomicAdd\1d\Test_OpenMP_atomicAdd_1d.exe /implib:Tests\OpenMP\atomicAdd\Test_OpenMP_atomicAdd_1d.lib /pdb:Tests\OpenMP\atomicAdd\1d\Test_OpenMP_atomicAdd_1d.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console  Src\amrex_1d.lib  %PREFIX%\Library\lib\libomp.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
...
(%BUILD_PREFIX%) %SRC_DIR%>ctest --test-dir build --build-config Release --output-on-failure -R OpenMP 
Internal ctest changing into directory: D:/bld/amrex_1714368890030/work/build
Test project D:/bld/amrex_1714368890030/work/build
    Start 105: OpenMP_atomicAdd_1d
1/3 Test #105: OpenMP_atomicAdd_1d ..............   Passed    0.06 sec
    Start 106: OpenMP_atomicAdd_2d
2/3 Test #106: OpenMP_atomicAdd_2d ..............   Passed    0.03 sec
    Start 107: OpenMP_atomicAdd_3d
3/3 Test #107: OpenMP_atomicAdd_3d ..............   Passed    0.08 sec

100% tests passed, 0 tests failed out of 3

Total Test time (real) =   0.23 sec
...
   INFO (amrex,Library/bin/amrex_3d.dll): Needed DSO Library/bin/libomp.dll found in conda-forge/win-64::llvm-openmp==18.1.3=h91493d7_0
   INFO (amrex,Library/bin/amrex_1d.dll): Needed DSO Library/bin/libomp.dll found in conda-forge/win-64::llvm-openmp==18.1.3=h91493d7_0
   INFO (amrex,Library/bin/amrex_2d.dll): Needed DSO Library/bin/libomp.dll found in conda-forge/win-64::llvm-openmp==18.1.3=h91493d7_0
...

but not in a dependent repo (WarpX/ImpactX) anymore.

@ax3l
Copy link
Member Author

ax3l commented Apr 29, 2024

@isuruf I am installing the AMReX import libs amrex_*.lib into lib/ while installing the dynamic symbols amrex_*.dll into bin/ ... is that a problem? (I think it has not caused issues in the past and should not have changed a few months ago...)

2024-04-29T06:01:10.1934787Z -- Installing: D:/bld/amrex_1714368890030/_h_env/Library/lib/amrex_3d.lib
2024-04-29T06:01:10.2011064Z -- Installing: D:/bld/amrex_1714368890030/_h_env/Library/bin/amrex_3d.dll

https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#why-does-find_library-not-find-dll-libraries-under-win32

The downstream link line is currently:

2024-04-29T06:28:05.2920628Z 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:
2024-04-29T06:28:05.2922201Z lld-link: error: undefined symbol: struct omp_lock_t * __cdecl amrex::OpenMP::get_lock(int)
2024-04-29T06:28:06.3576700Z >>> 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))

@isuruf
Copy link
Member

isuruf commented Apr 29, 2024

I am installing the AMReX import libs amrex_.lib into lib/ while installing the dynamic symbols amrex_.dll into bin/ ... is that a problem?

Nope

@ax3l
Copy link
Member Author

ax3l commented Apr 29, 2024

I noticed that I cannot find a symbol for omp_lock_t in neither libiomp5md.dll nor libomp.dll of the conda-forge llvm-openmp package... (using radare2's rabin2 -s ...) But somehow, I generally only see function symbols...

@isuruf
Copy link
Member

isuruf commented Apr 29, 2024

Types don't have symbols in dynamic libraries. Only functions and global data variables.

@ax3l
Copy link
Member Author

ax3l commented May 3, 2024

I'll try patching in AMReX-Codes/amrex#3910 to the 24.05 release.

@ax3l
Copy link
Member Author

ax3l commented May 3, 2024

In parallel, I contributed to CMake 3.30+ the support for OpenMP from LLVM in MSVC (instead of LLVM-OpenMP w/ Clang-Cl, which we currently use on Conda-Forge -- or the OpenMP 2.0 that comes with MSVC by default, which we cannot use because it is too old):
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9475

Thus, we can try to compile on Conda-Forge with MSVC on Windows again using the new LLVM OpenMP support once that CMake release is out.

@ax3l
Copy link
Member Author

ax3l commented May 12, 2024

Testing the patch for the 24.05 release via #24

@ax3l
Copy link
Member Author

ax3l commented May 25, 2024

Patch in upstream for 24.05+

@ax3l ax3l closed this May 25, 2024
@ax3l ax3l deleted the fix-omp branch May 25, 2024 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants