Files
TheRock/compiler/amd-llvm/flang/docs/FortranLLVMTestSuite.md
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

2.8 KiB

Fortran Tests in the LLVM Test Suite

---
local:
---

The LLVM Test Suite is a separate git repo from the main LLVM project. We recommend that first-time users read through LLVM Test Suite Guide which describes the organizational structure of the test suite and how to run it.

Running the LLVM test-suite with Fortran

Fortran support can be enabled by setting the following CMake variables:

cmake -G "Ninja" -DCMAKE_C_COMPILER=<path to C compiler> \
    -DCMAKE_CXX_COMPILER=<path to C++ compiler> \
    -DCMAKE_Fortran_COMPILER=<path to Fortran compiler> \
    -DTEST_SUITE_COLLECT_CODE_SIZE:STRING=OFF \
    -DTEST_SUITE_SUBDIRS:STRING="Fortran" \
    -DTEST_SUITE_FORTRAN:STRING=ON \
    -DTEST_SUITE_LIT=<path to llvm-lit> \
    <path to llvm-test-suite>

This will configure the test-suite to run only the Fortran tests which are found in the Fortran subdirectory. To run the C/C++ tests alongside the Fortran tests omit the -DTEST_SUITE_SUBDIRS CMake variable.

If your Fortran compiler is Flang, there are a couple of other things you need to do, which are explained here.

Then to build and run the tests:

ninja
ninja check

Running the SPEC CPU 2017

We recently added CMake hooks into the LLVM Test Suite to support Fortran tests from SPEC CPU 2017. We strongly encourage the use of the CMake Ninja (1.10 or later) generator due to better support for Fortran module dependency detection. Some of the SPEC CPU 2017 Fortran tests, those that are derived from climate codes, require support for little-endian/big-endian byte swapping capabilities which we automatically detect at CMake configuration time. Note that a copy of SPEC CPU 2017 must be purchased by your home institution and is not provided by LLVM.

Here is an example of how to build SPEC CPU 2017 with GCC

cmake -G "Ninja" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \
    -DCMAKE_Fortran_COMPILER=gfortran \
    -DTEST_SUITE_COLLECT_CODE_SIZE:STRING=OFF \
    -DTEST_SUITE_SUBDIRS:STRING="External/SPEC" \
    -DTEST_SUITE_FORTRAN:STRING=ON \
    -DTEST_SUITE_SPEC2017_ROOT=<path to SPEC directory>  ..

Running the gfortran tests

Tests from the gfortran test suite have been imported into the LLVM Test Suite. The tests will be run automatically if the test suite is built following the instructions described above. There are additional configure-time options that can be used with the gfortran tests. More details about those options and their purpose can be found in Fortran/gfortran/README.md.