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

Enable Flang-RT for all Flang builders. #333

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Meinersbur
Copy link
Member

Modify all build configurations that build Flang to also build Flang-RT. Flang-RT is the runtime component of Flang that is refactored into its own runtime project in llvm/llvm-project#110217.

The following classes of builder are affected:

  • Builders with LLVM_ENABLE_PROJECTS=flang and running check-flang: Adding LLVM_ENABLE_RUNTIMES=flang-rt and check-flang-rt. These builders would continue to be green after [Flang] LLVM_ENABLE_RUNTIMES=flang-rt llvm-project#110217 even without this PR, just testing less.

  • Clang builders with checkout_flang=True: Automatically add flang-rt to depends_on_projects which also adds LLVM_ENABLE_PROJECTS with enable_runtimes="auto". These builders would continue to be green after [Flang] LLVM_ENABLE_RUNTIMES=flang-rt llvm-project#110217 even without this PR, just testing less.

  • Clang builders with checkout_flang=True and runTestSuite=True: Running the the test-suite with Flang requires Flang-RT, so these builders would start failing with [Flang] LLVM_ENABLE_RUNTIMES=flang-rt llvm-project#110217 without this PR.

  • linaro-flang-aarch64-out-of-tree: Has its own build factory that would require larger changes to also check/run Flang-RT. Should stay green even after [Flang] LLVM_ENABLE_RUNTIMES=flang-rt llvm-project#110217.

  • flang-runtime-cuda-gcc: Only compiles but does not run check. Used to be a flang/runtime out-of-tree build. Runtime-only builds of Flang-RT needs the path to flang. I do not know where/whether this can be found on the workers so changing it to a bootstrap build. More important to keep the buildbots green.

  • flang-runtime-cuda-clang: Staged build of first compiling LLVM+Clang, then Flang out-of-tree. With this PR also building Flang in-tree and Flang-RT as runtime-only build. Building both Flang and Flang-RT out-of-tree would require another stage, but "linaro-flang-aarch64-out-of-tree" is already testing the Flang out-of-tree build.

@Meinersbur Meinersbur marked this pull request as ready for review December 9, 2024 16:47
@Meinersbur
Copy link
Member Author

@gkistanova The get the buildsbots green after pushing llvm/llvm-project#110217, pushing this PR and restarting the buildbot master would be time-critical. Is it possible to schedule these things together so we can minimize the time the buildbots are failing?

@vvereschaka vvereschaka self-requested a review January 4, 2025 05:10
Copy link
Contributor

@vvereschaka vvereschaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Meinersbur ,

I'm checking updated builder configurations for flang-runtime-cuda-gcc and flang-runtime-cuda-clang locally on users/meinersbur/flang_runtime branch. My review is for these builders.

In additional, I have noticed the following build error for flang-runtime-cuda-gcc builder with these changes:

[1/14] Generating ../../../../include/flang/__fortran_builtins.mod
FAILED:include/flang/__fortran_builtins.mod /home/buildbot/worker/temp/build-flang-runtime-gcc/include/flang/__fortran_builtins.mod
cd /home/buildbot/worker/temp/build-flang-runtime-gcc/tools/flang/tools/f18 && /usr/bin/cmake -E make_directory /home/buildbot/worker/temp/build-flang-runtime-gcc/include/flang && /home/buildbot/worker/temp/build-flang-runtime-gcc/bin/flang -cpp -fsyntax-only -module-dir /home/buildbot/worker/temp/build-flang-runtime-gcc/include/flang /home/buildbot/worker/temp/llvm-project/flang/module/__fortran_builtins.f90
Error creating directory "/home/buildbot/worker/temp/build-flang-runtime-gcc/include/flang".
ninja: build stopped: subcommand failed.

it gets failed because that folder was already exist. The step has passed after I removed the directory. Not sure, but possible because of the changes.

},
targets = ["FortranRuntime"],
src_to_build_dir = "flang/runtime",
targets = ["flang_rt"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be "flang-rt" instead of "flang_rt"

cmake --build . --target flang_rt
ninja: error: unknown target 'flang_rt', did you mean 'flang-rt'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ... and no. Both targets should exist. flang-rt for all non-EXCLUDE_FROM_ALL artifacts, flang_rt for only the artifact called flang_rt (usually libflang_rt.a) which corresponds to the old FortranRuntime. I don't know why it does not exist.

Anyway, changing it to flang-rt.

buildbot/osuosl/master/config/builders.py Show resolved Hide resolved
buildbot/osuosl/master/config/builders.py Show resolved Hide resolved
targets = ["FortranRuntime"],
src_to_build_dir = "flang/runtime",
targets = ["flang_rt"],
src_to_build_dir = "flang-rt",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line must be removed. There is no llvm-project/flang-rt project's folder. Should be used default (llvm).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I misunderstood the purpose of this paramters. I assumed it was the CMake build directory.

For runtimes it should be runtimes, which corresponds to https://github.com/llvm/llvm-project/blob/main/runtimes/CMakeLists.txt. It contains the boilerplate for an out-of-source build of any runtime project like flang-rt, like llvm/CMakeLists.txt is for all LLVM_ENABLE_PROJECTS.

buildbot/osuosl/master/config/builders.py Show resolved Hide resolved
@vvereschaka
Copy link
Contributor

Just in case, the cmake/build commands for 'flang-runtime-cuda-gcc' and 'flang-runtime-cuda-clang' I used for checking:

  • 'flang-runtime-cuda-gcc'
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DLLVM_ENABLE_ASSERTIONS=ON -DBUILD_SHARED_LIBS=OFF -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CUDA_HOST_COMPILER=/usr/bin/g++ -DCMAKE_CUDA_ARCHITECTURES=80 -DCMAKE_CUDA_FLAGS="-G -g" -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DLLVM_ENABLE_PROJECTS="clang;flang" -DLLVM_ENABLE_RUNTIMES=flang-rt -DLLVM_LIT_ARGS="-v -vv" -DFLANG_RT_LIBCUDACXX_PATH=/home/buildbot/worker/third-party/nv/cccl/libcudacxx -GNinja ../llvm-project/llvm

cmake --build . -- -j 128
  • 'flang-runtime-cuda-clang' - stage 1
cmake -G Ninja -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=Native -DCLANG_DEFAULT_LINKER=lld -DLLVM_ENABLE_PROJECTS="clang-tools-extra;openmp;lld;clang;llvm;flang" -DLLVM_ENABLE_RUNTIMES=compiler-rt -DCMAKE_INSTALL_PREFIX=../install-clang ../llvm-project/llvm

cmake --build . --target install
  • 'flang-runtime-cuda-clang' - stage 2
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/home/buildbot/worker/temp/install-clang/bin/clang -DCMAKE_CXX_COMPILER=/home/buildbot/worker/temp/install-clang/bin/clang++ -DCMAKE_Fortran_COMPILER=/home/buildbot/worker/temp/install-clang/bin/flang -DFLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=OpenMP -DFLANG_RT_DEVICE_ARCHITECTURES='sm_50;sm_60;sm_70;sm_80' -DLLVM_ENABLE_PROJECTS='clang;flang' -DLLVM_ENABLE_RUNTIMES=flang-rt  ../llvm-project/llvm

cmake --build . --target flang-rt

@vvereschaka vvereschaka requested a review from andreil99 January 4, 2025 05:33
Copy link
Member Author

@Meinersbur Meinersbur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for trying out. I currently don't understand why depends_on_projects does not work, it should derive it automatically. This line tells the LLVMBuildFactory that flang-rt should be put into enable_runtimes: https://github.com/Meinersbur/llvm-zorg/blob/0db03958adf4c6c96d94d625b30959482b079954/zorg/buildbot/process/factory.py#L15
Did you apply it? How did you test the configuration? In the past I did it by seeting up my own buildbot master, but that requires some effort.

It seems that I underestimated the effort. Since @gkistanova also did not respond to ensure a timely application of both patches, I will keep the old way to build the runtime unless LLVM_ENABLE_RUNTIMES=flang-rt is passed. This way the buildbots can be updated iteratively.
 

it gets failed because that folder was already exist. The step has passed after I removed the directory. Not sure, but possible because of the changes.

The command should not fail if the directory already exists, as by its documentation. Maybe a permission problem?

buildbot/osuosl/master/config/builders.py Show resolved Hide resolved
buildbot/osuosl/master/config/builders.py Show resolved Hide resolved
},
targets = ["FortranRuntime"],
src_to_build_dir = "flang/runtime",
targets = ["flang_rt"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ... and no. Both targets should exist. flang-rt for all non-EXCLUDE_FROM_ALL artifacts, flang_rt for only the artifact called flang_rt (usually libflang_rt.a) which corresponds to the old FortranRuntime. I don't know why it does not exist.

Anyway, changing it to flang-rt.

targets = ["FortranRuntime"],
src_to_build_dir = "flang/runtime",
targets = ["flang_rt"],
src_to_build_dir = "flang-rt",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I misunderstood the purpose of this paramters. I assumed it was the CMake build directory.

For runtimes it should be runtimes, which corresponds to https://github.com/llvm/llvm-project/blob/main/runtimes/CMakeLists.txt. It contains the boilerplate for an out-of-source build of any runtime project like flang-rt, like llvm/CMakeLists.txt is for all LLVM_ENABLE_PROJECTS.

@DavidSpickett
Copy link
Contributor

In the past I did it by seeting up my own buildbot master, but that requires some effort.

It is less effort than it used to be: https://llvm.org/docs/HowToAddABuilder.html#testing-a-builder-config-locally.

@Meinersbur
Copy link
Member Author

@DavidSpickett Thanks, that will be helpful. 😎

@vvereschaka
Copy link
Contributor

@Meinersbur ,

Did you apply it? How did you test the configuration? In the past I did it by seeting up my own buildbot master, but that requires some effort.

I didn't apply your buildbot patch. I jet took the expanded cmake/build commands from the appropriate builds for flang-runtime-cuda-gcc and flang-runtime-cuda-clang and substituted changed parts there accordingly to your patch. The main goal was to check how the result build sequence will work with new parameters.

I didn't check depends_on_projects . Probably I didn't get something and it will work fine as you expect.

it gets failed because that folder was already exist. The step has passed after I removed the directory. Not sure, but possible because of the changes.

The command should not fail if the directory already exists, as by its documentation. Maybe a permission problem?

It didn't look like a permission problem, but possible. I'm just letting you know about the seen problems, just in case.

@Meinersbur
Copy link
Member Author

I didn't apply your buildbot patch. I jet took the expanded cmake/build commands from the appropriate builds for flang-runtime-cuda-gcc and flang-runtime-cuda-clang and substituted changed parts there accordingly to your patch. The main goal was to check how the result build sequence will work with new parameters.

With the change in factory.py, depends_on_projects=["flang", "flang-rt"] goes to LLVM_ENABLE_PROJECTS=flang and LLVM_ENABLE_RUNTIMES=flang-rt. You may have not considered that.

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.

3 participants