Skip to content

Conversation

@Meinersbur
Copy link
Member

@Meinersbur Meinersbur commented Nov 26, 2025

Reapplication of #137828.

Draft -- Still to find the cause of the transient CMAKE_Fortran_PREPROCESS_SOURCE buildbot failure

@Meinersbur
Copy link
Member Author

Meinersbur commented Nov 26, 2025

@jhuber6 Based on the feedback in #137828, I made it easier to build the Fortran modules for nvptx and amdgpu targets. It is now possible to set both FLANG_RT_ENABLE_STATIC and FLANG_RT_ENABLE_SHARED to off, meaning no library is built, only the modules files. This is the default if the target is nvptx or amdgpu. However, this overrides the (experimental) default behavior of #131826. I could not get the gpu_sources to compile since it cannot find include files such as #include <cassert>. I could trick it to point to the libc++ versions, but I don't want other users have to do many steps. Please have a look specifically to 9041b78 (#169638)

In the spirit off adding LLVM_ENABLE_RUNTIMES=flang-rt automatically, we could also automatically add LLVM_RUNTIME_TARGETS=default;amdgcn-amd-amdhsa when the AMDGPU backend is enabled; respectively LLVM_RUNTIME_TARGETS=default;nvptx64-nvidia-cuda if LLVM_TARGETS_TO_BUILD=NVPTX is present. What do you think?

@Meinersbur Meinersbur requested a review from vzakhari November 26, 2025 11:41
@Meinersbur Meinersbur changed the title [Flang] Move builtin .mod generation into runtimes (#137828) [Flang] Move builtin .mod generation into runtimes (Reapply #137828) Nov 26, 2025
@github-actions
Copy link

github-actions bot commented Nov 26, 2025

🐧 Linux x64 Test Results

  • 193336 tests passed
  • 6211 tests skipped

@vzakhari
Copy link
Contributor

Thank you, Michael! The patchs seems to be working on my side (after some adjustments downstream). So it is good to go for the next week merge (once you merge it, I will resolve conflicts on my side).

I do not know about the experimental direct GPU build. @jhuber6 can you please comment on Michael's question above?

@Meinersbur
Copy link
Member Author

After working around the CMAKE_Fortran_PREPROCESS_SOURCE failure, openmp-offload-amdgpu-clang-flang is failing with a different problem: The builder is running Fortran+OpenMP offload tests on amdgpu-amd-amdhsa. For these to compile, omp_lib.mod and the builtin modules must be compiled for amdgpu-amd-amdhsa as well.

  1. The builtin modules are compiled by just adding/not removing LLVM_ENABLE_RUNTIMES=flang-rt.

  2. omp_lib.mod unfortunately involves more changes. openmp skips add_subdirectory(runtime) for amdgpu/nvptx which contains the module build instructions. Some restructure was needed to compile the Fortran modules for offload triples as well, mostly moving definitions out of the runtime/ directory into a new module/ directory for building omp_lib.mod for host and device.

@jhuber6
Copy link
Contributor

jhuber6 commented Nov 27, 2025

One problem with enabling flang-rt on the GPU is that it has a dependency on libc / libc++ on the GPU as well. Maybe there's a way to make it work there just to build the module files?

@Meinersbur
Copy link
Member Author

Meinersbur commented Nov 28, 2025

One problem with enabling flang-rt on the GPU is that it has a dependency on libc / libc++ on the GPU as well. Maybe there's a way to make it work there just to build the module files?

This is what FLANG_RT_ENABLE_STATIC=OFF FLANG_RT_ENABLE_SHARED=OFF does. It should only build the .f90 files which have no dependency to libc or libc++ headers, and only builds object libraries, so there is no linking step which would require libc. My question specifically is whether it is OK to make this the default on nvptx/amdgpu targets which this PR currently does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants