Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Port to flang and F90 compliance of madgraph fortran codebase #804

Open
valassi opened this issue Jan 27, 2024 · 0 comments
Open

Port to flang and F90 compliance of madgraph fortran codebase #804

valassi opened this issue Jan 27, 2024 · 0 comments

Comments

@valassi
Copy link
Member

valassi commented Jan 27, 2024

Hi @oliviermattelaer , as part of PR #801 for porting to LUMI with AMD GPUs, I am experimenting with flang as a fortran compiler.

(I am using flang because I get several issues with gfortran... linking c++, fortran and hip code seems rather complex, see for instance #802).

I managed to use the /opt/rocm/llvm/bin/flang compiler for the standalone code, where there is very limited fortran. But the moment I try building madevent, it's just a catastrophe (see below*).

I guess that this flang does not support F77, or at least all the legacy f77 stuff in madevent. This is not a blocker per se, but something to keep in mind. I think flang looks like the future of fortran compilers. Maybe more features will be added, maybe not.

In my understanding (I may be wrong), the flang I am testing is the "new flang" aka f18, a rewrite from the grounds up of the flang compiler in c++. See https://github.com/llvm/llvm-project/blob/main/flang/README.md#getting-started. The features supported are here I think https://github.com/llvm/llvm-project/blob/main/flang/docs/Extensions.md. (For comparison, the "old flang" or "classic flang" is here https://github.com/flang-compiler/flang).

I am trying to check if I can do anything with it, but I guess on LUMI we need to go back to gfortran and massage all link issues. (@Jooorgen in case you read this, any suggestion on what combination to use? thanks)

Andrea

PS *One example, for myamp

ccache /opt/rocm-5.2.3/llvm/bin/flang -w -fPIC -O3 -ffast-math -fbounds-check -ffixed-line-length-132 -w -cpp -c myamp.f -I../../Source/ -I../../Source/PDF/g\
ammaUPC
F90-S-0023-Syntax error - unbalanced parentheses (../../Source/genps.inc: 9)
F90-S-0087-Non-constant expression where constant expression required (../../Source/genps.inc: 25)
F90-S-0087-Non-constant expression where constant expression required (../../Source/genps.inc: 27)
F90-S-0034-Syntax error at or near end of line (../../Source/run.inc: 10)
F90-S-0023-Syntax error - unbalanced parentheses (../../Source/run.inc: 55)
F90-S-0023-Syntax error - unbalanced parentheses (../../Source/run.inc: 56)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 83)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 117)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 132)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 152)
F90-S-0038-Symbol, mue_over_fixed_ren_scale, has not been explicitly declared (myamp.f)
F90-S-0038-Symbol, fixed_fac_scale2fixed_couplings, has not been explicitly declared (myamp.f)
F90-S-0038-Symbol, hmdynamical_scale_choice, has not been explicitly declared (myamp.f)
F90-S-0038-Symbol, ievo_eva, has not been explicitly declared (myamp.f)
F90-S-0038-Symbol, n_pdfrw, has not been explicitly declared (myamp.f)
F90-S-0038-Symbol, i_pdgpdf, has not been explicitly declared (myamp.f)
F90-S-0038-Symbol, s_xpdf, has not been explicitly declared (myamp.f)
F90-S-0038-Symbol, s_qpdf, has not been explicitly declared (myamp.f)
  0 inform,   0 warnings,  18 severes, 0 fatal for cut_bw
F90-S-0023-Syntax error - unbalanced parentheses (../../Source/genps.inc: 9)
F90-S-0087-Non-constant expression where constant expression required (../../Source/genps.inc: 25)
F90-S-0087-Non-constant expression where constant expression required (../../Source/genps.inc: 27)
F90-S-0034-Syntax error at or near end of line (../../Source/run.inc: 10)
F90-S-0023-Syntax error - unbalanced parentheses (../../Source/run.inc: 55)
F90-S-0023-Syntax error - unbalanced parentheses (../../Source/run.inc: 56)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 273)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 275)
F90-S-0050-Assumed size array, spole, is not a dummy argument (myamp.f: 283)
F90-S-0050-Assumed size array, swidth, is not a dummy argument (myamp.f: 283)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 298)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 323)
F90-S-0034-Syntax error at or near end of line (myamp.f: 370)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 396)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 399)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 410)
F90-S-0034-Syntax error at or near end of line (myamp.f: 422)
F90-S-0034-Syntax error at or near . (myamp.f: 429)
F90-S-0023-Syntax error - unbalanced parentheses (myamp.f: 436)
valassi added a commit to valassi/madgraph4gpu that referenced this issue Jan 27, 2024
…xe using $FC=gfortran on LUMI/HIP madgraph5#802

Otherwise the link was failing using gfortran
/opt/cray/pe/gcc/12.2.0/snos/bin/gfortran -o runTest.exe ./CPPProcess.o ./MatrixElementKernels.o ./BridgeKernels.o ./CrossSectionKernels.o ./CommonRandomNumberKernel.o ./RamboSamplingKernels.o ./testxxx.o  ./testmisc.o  ./runTest.o ./gCPPProcess.o ./gMatrixElementKernels.o ./gBridgeKernels.o ./gCrossSectionKernels.o ./gCommonRandomNumberKernel.o ./gRamboSamplingKernels.o ./testxxx_cu.o  ./testmisc_cu.o  ./runTest_cu.o -ldl -L../../lib -lmg5amc_common -L../../../../../test/googletest/install_gcc12.2.0/lib64/ -lgtest -lgtest_main -Xlinker -rpath='$ORIGIN/../../lib'   -lstdc++ -L/opt/rocm-5.2.3/llvm/bin/../../lib -lamdhip64
/usr/bin/ld: ../../../../../test/googletest/install_gcc12.2.0/lib64//libgtest.a(gtest-all.cc.o): undefined reference to symbol 'pthread_setspecific@@GLIBC_2.2.5'
/usr/bin/ld: /lib64/libpthread.so.0: error adding symbols: DSO missing from command line

I went back to gfortran because flang gives too many F90 errors on madevent madgraph5#804
valassi added a commit to valassi/madgraph4gpu that referenced this issue Jan 27, 2024
…gtt.mad, after adding pthread in the link madgraph5#802

Note, the log was created with mad so there was no need to copy it

LUMI setup is now the following, using again gcc and gfortran (I dropped flang because of f90 issues madgraph5#804 in madevent)
module load cray-python
module load gcc/12.2.0
export FC=`which gfortran`
export PATH=~/CCACHE/ccache-4.8.2-INSTALL/bin:$PATH
export CCACHE_DIR=~/CCACHE/ccache
export USECCACHE=1

Note, as in previous tests, HIP_HOME is automatically determined as /usr (hipcc is in /usr/bin/hipcc)
valassi added a commit to valassi/madgraph4gpu that referenced this issue Jan 27, 2024
…)... why? due to link issues madgraph5#802 again?

LUMI setup is now the following, using again gcc and gfortran (I dropped flang because of f90 issues madgraph5#804 in madevent)
module load cray-python
module load gcc/12.2.0
export FC=`which gfortran`
export PATH=~/CCACHE/ccache-4.8.2-INSTALL/bin:$PATH
export CCACHE_DIR=~/CCACHE/ccache
export USECCACHE=1
valassi added a commit to valassi/madgraph4gpu that referenced this issue Jan 27, 2024
… when linking runTest.exe using $FC=gfortran on LUMI/HIP madgraph5#802

Otherwise the link was failing using gfortran
/opt/cray/pe/gcc/12.2.0/snos/bin/gfortran -o runTest.exe ./CPPProcess.o ./MatrixElementKernels.o ./BridgeKernels.o ./CrossSectionKernels.o ./CommonRa>
/usr/bin/ld: ../../../../../test/googletest/install_gcc12.2.0/lib64//libgtest.a(gtest-all.cc.o): undefined reference to symbol 'pthread_setspecific@@>
/usr/bin/ld: /lib64/libpthread.so.0: error adding symbols: DSO missing from command line

I went back to gfortran because flang gives too many F90 errors on madevent madgraph5#804
valassi added a commit to valassi/madgraph4gpu that referenced this issue Sep 20, 2024
… hipcc to link fcheck_hip.exe

Revert "[helas] in gg_tt.mad cudacpp.mk, temporarely go back and try to use hipcc instead of gfortran to link fcheck_hip.exe: this links but it fails at runtime, will revert"
This reverts commit 988419b.

NOTE: I tried to use FC=hipcc and this also compiles the fortran ok!
Probably it internally uses flang from llvm madgraph5#804

The problem however is that there is no lowercase 'main' in fcheck_sa_fortran.o, only an uppercase 'MAIN_'.

Summary of the status" HELINL=L "rdc" is not supported on our AMD GPUs for now.
valassi added a commit to valassi/madgraph4gpu that referenced this issue Sep 21, 2024
… hipcc to link fcheck_hip.exe

Revert "[helas] in gg_tt.mad cudacpp.mk, temporarely go back and try to use hipcc instead of gfortran to link fcheck_hip.exe: this links but it fails at runtime, will revert"
This reverts commit 988419b.

NOTE: I tried to use FC=hipcc and this also compiles the fortran ok!
Probably it internally uses flang from llvm madgraph5#804

The problem however is that there is no lowercase 'main' in fcheck_sa_fortran.o, only an uppercase 'MAIN_'.

Summary of the status" HELINL=L "rdc" is not supported on our AMD GPUs for now.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant