From 1c231167848f922f655feec73d7acec8060a067f Mon Sep 17 00:00:00 2001 From: zaikunzhang Date: Wed, 10 Apr 2024 00:57:15 +0800 Subject: [PATCH] 240410.005715.HKT fortran: shift `ftest` from Classic Flang to LLVM Flang --- .github/workflows/cmake.yml | 10 +++++----- fortran/common/consts.F90 | 7 +++++-- fortran/examples/README.txt | 2 +- fortran/examples/bobyqa/Makefile | 4 ++-- fortran/examples/cobyla/Makefile | 4 ++-- fortran/examples/lincoa/Makefile | 4 ++-- fortran/examples/newuoa/Makefile | 4 ++-- fortran/examples/uobyqa/Makefile | 4 ++-- fortran/tests/makefiles/Makefile.common | 14 +++++++------- 9 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index dd7899534f..76e01f98a7 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -156,10 +156,10 @@ jobs: fail-fast: false matrix: toolchain: - # Flang family with -Mchkptr would fail. See https://forums.developer.nvidia.com/t/bug-in-nvfortran-with-mchkptr-for-unallocated-optional-arguments/223220 - # As of 20240220, flang and aflang with -Mbounds would fail due to the bug at https://github.com/flang-compiler/flang/issues/1238 + # Classic Flang family with -Mchkptr would fail. See https://forums.developer.nvidia.com/t/bug-in-nvfortran-with-mchkptr-for-unallocated-optional-arguments/223220 + # As of 20240220, aflang with -Mbounds would fail due to the bug at https://github.com/flang-compiler/flang/issues/1238 - {compiler: nvfortran, cflags: '-Wall', fflags: '-C -Wall -Wextra -Minform=warn -Mstandard -Mrecursive -Mbounds -Mchkstk'} - - {compiler: flang, cflags: '-Wall', fflags: '-pedantic -Weverything -Wall -Wextra -Minform=warn -Mstandard -Mrecursive'} + - {compiler: flang, cflags: '-Wall', fflags: '-pedantic'} - {compiler: aflang, cflags: '-Wall', fflags: '-pedantic -Weverything -Wall -Wextra -Minform=warn -Mstandard -Mrecursive'} steps: @@ -205,8 +205,8 @@ jobs: cmake --build . --target install cmake --build . --target tests - # As of 20240316, CMake test fails on cobyla with the Classic flang, AOCC flang, and - # nvfortran. See https://github.com/libprima/prima/issues/165 + # As of 20240316, CMake test fails on cobyla with the AOCC flang and nvfortran. + # See https://github.com/libprima/prima/issues/165 ctest --output-on-failure -V -E "stress|cobyla" shell: bash env: diff --git a/fortran/common/consts.F90 b/fortran/common/consts.F90 index 83544a3b16..598f02c04a 100644 --- a/fortran/common/consts.F90 +++ b/fortran/common/consts.F90 @@ -8,7 +8,7 @@ module consts_mod ! ! Started: July 2020 ! -! Last Modified: Saturday, March 16, 2024 AM01:29:42 +! Last Modified: Wednesday, April 10, 2024 AM12:54:17 !--------------------------------------------------------------------------------------------------! !--------------------------------------------------------------------------------------------------! @@ -155,7 +155,10 @@ module consts_mod integer, parameter :: HALF_MAXPOW10 = floor(real(MAXPOW10) / 2.0) ! TINYCV is used in LINCOA. Powell set TINYCV = 1.0D-60. What about setting TINYCV = REALMIN? -real(RP), parameter :: TINYCV = TEN**max(-60, -MAXPOW10) +!real(RP), parameter :: TINYCV = TEN**max(-60, -MAXPOW10) +! The above code would lead to a warning with LLVM flang 19.0. See +! https://fortran-lang.discourse.group/t/flang-new-19-0-warning-overflow-on-power-with-integer-exponent/7801 +real(RP), parameter :: TINYCV = TEN**max(-60.0, -real(MAXPOW10)) ! FUNCMAX is used in the moderated extreme barrier. All function values are projected to the ! interval [-FUNCMAX, FUNCMAX] before passing to the solvers, and NaN is replaced with FUNCMAX. ! CONSTRMAX plays a similar role for constraints. diff --git a/fortran/examples/README.txt b/fortran/examples/README.txt index abad78546a..b534807809 100644 --- a/fortran/examples/README.txt +++ b/fortran/examples/README.txt @@ -19,7 +19,7 @@ compliant with Fortran 2008 and above. 5. As of March 2024, the examples run successfully with the following compilers on Ubuntu 22.04. - AMD AOCC Flang 4.2 - Arm Fortran Compiler 23.10 -- Classic Flang 17.0 +- LLVM Flang 19.0 - GNU gfortran 13.1 - Intel ifx 2024.0 - Intel ifort 2021.11.1 diff --git a/fortran/examples/bobyqa/Makefile b/fortran/examples/bobyqa/Makefile index 05bcf034c8..936379ba78 100644 --- a/fortran/examples/bobyqa/Makefile +++ b/fortran/examples/bobyqa/Makefile @@ -53,8 +53,8 @@ test: AFLANG := $(shell find -L /opt/AMD -type f -executable -name flang -print 2> /dev/null | sort | tail -n 1) dtest: FC := $(AFLANG) -Wall -Wextra -std=f$(FSTD) -Mstandard -# Flang -ftest: FC := flang -Wall -Wextra -std=f$(FSTD) -Mstandard +# LLVM Flang +ftest: FC := flang -std=f$(FSTD) # GNU gfortran: due to `error stop` and `backtrace`, we must either compile wit no `-std` or # use `-std=f20xy -fall-intrinsics` with xy >= 18. diff --git a/fortran/examples/cobyla/Makefile b/fortran/examples/cobyla/Makefile index afba052acf..872163f168 100644 --- a/fortran/examples/cobyla/Makefile +++ b/fortran/examples/cobyla/Makefile @@ -53,8 +53,8 @@ test: AFLANG := $(shell find -L /opt/AMD -type f -executable -name flang -print 2> /dev/null | sort | tail -n 1) dtest: FC := $(AFLANG) -Wall -Wextra -std=f$(FSTD) -Mstandard -# Flang -ftest: FC := flang -Wall -Wextra -std=f$(FSTD) -Mstandard +# LLVM Flang +ftest: FC := flang -std=f$(FSTD) # GNU gfortran: due to `error stop` and `backtrace`, we must either compile wit no `-std` or # use `-std=f20xy -fall-intrinsics` with xy >= 18. diff --git a/fortran/examples/lincoa/Makefile b/fortran/examples/lincoa/Makefile index 373d421b54..4c457fbb57 100644 --- a/fortran/examples/lincoa/Makefile +++ b/fortran/examples/lincoa/Makefile @@ -53,8 +53,8 @@ test: AFLANG := $(shell find -L /opt/AMD -type f -executable -name flang -print 2> /dev/null | sort | tail -n 1) dtest: FC := $(AFLANG) -Wall -Wextra -std=f$(FSTD) -Mstandard -# Flang -ftest: FC := flang -Wall -Wextra -std=f$(FSTD) -Mstandard +# LLVM Flang +ftest: FC := flang -std=f$(FSTD) # GNU gfortran: due to `error stop` and `backtrace`, we must either compile wit no `-std` or # use `-std=f20xy -fall-intrinsics` with xy >= 18. diff --git a/fortran/examples/newuoa/Makefile b/fortran/examples/newuoa/Makefile index 815dceb3f1..b00c4cf3b5 100644 --- a/fortran/examples/newuoa/Makefile +++ b/fortran/examples/newuoa/Makefile @@ -53,8 +53,8 @@ test: AFLANG := $(shell find -L /opt/AMD -type f -executable -name flang -print 2> /dev/null | sort | tail -n 1) dtest: FC := $(AFLANG) -Wall -Wextra -std=f$(FSTD) -Mstandard -# Flang -ftest: FC := flang -Wall -Wextra -std=f$(FSTD) -Mstandard +# LLVM Flang +ftest: FC := flang -std=f$(FSTD) # GNU gfortran: due to `error stop` and `backtrace`, we must either compile wit no `-std` or # use `-std=f20xy -fall-intrinsics` with xy >= 18. diff --git a/fortran/examples/uobyqa/Makefile b/fortran/examples/uobyqa/Makefile index 1be889b670..91e7681e9a 100644 --- a/fortran/examples/uobyqa/Makefile +++ b/fortran/examples/uobyqa/Makefile @@ -53,8 +53,8 @@ test: AFLANG := $(shell find -L /opt/AMD -type f -executable -name flang -print 2> /dev/null | sort | tail -n 1) dtest: FC := $(AFLANG) -Wall -Wextra -std=f$(FSTD) -Mstandard -# Flang -ftest: FC := flang -Wall -Wextra -std=f$(FSTD) -Mstandard +# LLVM Flang +ftest: FC := flang -std=f$(FSTD) # GNU gfortran: due to `error stop` and `backtrace`, we must either compile wit no `-std` or # use `-std=f20xy -fall-intrinsics` with xy >= 18. diff --git a/fortran/tests/makefiles/Makefile.common b/fortran/tests/makefiles/Makefile.common index 28d4f6f4ca..9c46e8842f 100644 --- a/fortran/tests/makefiles/Makefile.common +++ b/fortran/tests/makefiles/Makefile.common @@ -4,7 +4,7 @@ # 9: G95 (compilation only; no compilation of test_*.f90 and other testing code, which contains F03 constructs unsupported by G95) # a: Absoft af95 (compilation only; the compiler is buggy and not maintained anymore) # d: AOCC flang -# f: Classic flang or Huawei Bisheng flang +# f: LLVM flang # g: GNU gfortran # n: NAG nagfor # i: Intel ifort @@ -160,7 +160,7 @@ CHCKTST := $(TOOLS_DIR)/checktest # Define the tests. ###################################################################################### # Decide whether to test QP, i.e., REAL128. -# Flang 17.0 and nvfortran 24.1 do not support REAL128; +# Classic Flang 17.0 and nvfortran 24.1 do not support REAL128; # AOCC Flang 4.2 complains about a symbol lookup error: undefined symbol: "fort_rnumq_i8"; TESTS_QP = atest gtest ntest itest stest 9test xtest TESTS_NO_QP = dtest ftest rtest vtest @@ -383,18 +383,18 @@ dtest_i2_r16_d1_tst_c dtest_i4_r16_d1_tst_c dtest_i8_r16_d1_tst_c dtest_i2_r16_d dtest_i2_r16_d1_tst_c dtest_i4_r16_d1_tst_c dtest_i8_r16_d1_tst_c dtest_i2_r16_d0_tst_c dtest_i4_r16_d0_tst_c dtest_i8_r16_d0_tst_c: \ FCF := $(DFORT) -ffp-exception-behavior=strict $(DFF) -# Classic Flang +# LLVM Flang # We must define FFORT as follows, because AOCC will also provide "flang", except that it is # located under /opt/AMD. Similar for ARM Flang. FFORT := $(shell find -L /usr/bin /usr/local/bin ${HOME}/local ${HOME}/.local /tmp -type f -executable -name flang -print 2>/dev/null | sort | tail -n 1) FFINC := $(shell dirname $$(dirname $(FFORT) 2>/dev/null) 2>/dev/null)/include FFLIB := $(shell dirname $$(dirname $(FFORT) 2>/dev/null) 2>/dev/null)/lib FFORT := $(FFORT) -I$(FFINC) -L$(FFLIB) -FFORT := $(FFORT) -pedantic-errors -Werror +FFORT := $(FFORT) -fimplicit-none -Werror ifeq ($(TESTDIM),small) - FFORT := $(FFORT) -Mstack_arrays + FFORT := $(FFORT) endif -FFORT := $(FFORT) -std=f$(FSTD) -pedantic -Weverything -Wall -Wextra -Minform=warn -Mstandard -Mbounds -Mrecursive -Mchkptr #-Kieee +FFORT := $(FFORT) -std=f2018 -pedantic #-Kieee ftest_i2_r4_d1_tst_c ftest_i4_r4_d1_tst_c ftest_i8_r4_d1_tst_c ftest_i2_r4_d0_tst_c ftest_i4_r4_d0_tst_c ftest_i8_r4_d0_tst_c: \ FCO := $(FFORT) $(FFLAGSO) @@ -992,7 +992,7 @@ source_%: $(SRC_DIRS) printf "\nPreparing the source code for $@.\n" ; \ bash $(TOOLS_DIR)/gsrc ./ ; \ fi - @if echo $@ | grep -q "ftest\|rtest\|dtest"; then \ + @if echo $@ | grep -q "rtest\|dtest"; then \ printf "\nPreparing the source code for $@.\n" ; \ bash $(TOOLS_DIR)/frdsrc ./ ; \ fi