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

specfem3d #1463

Open
Sezoir opened this issue Feb 10, 2022 · 1 comment
Open

specfem3d #1463

Sezoir opened this issue Feb 10, 2022 · 1 comment
Labels
apps Building Fortran applications with Flang - status + instructions

Comments

@Sezoir
Copy link
Collaborator

Sezoir commented Feb 10, 2022

Enable building and execution of the specfem3d application with the LLVM Flang compiler.

@Sezoir
Copy link
Collaborator Author

Sezoir commented Feb 10, 2022

Next steps: I am not planning to take on this project. This is just an initial report found. Please feel free to work on this.

specfem3d:

https://geodynamics.org/cig/software/specfem3d/
https://github.com/geodynamics/specfem3d_globe/tree/master

Initial report for specfem3d:

  • Minimum version of Fortran required using gfortran: F2003

    • Required arguments to compile with version: "-fdec"
  • How to compile with gfortran:

    1. First you can download the project by running in bash:
    git clone https://github.com/geodynamics/specfem3d_globe.git
    cd specfem3d_globe
    
    1. This project requires an MPI compiler. For this project I used the ompi wrapper compiler around my gfortran/gcc compilers. After that you can compile the project by running:
    ./configure FC=mpifort CC=gcc MPIFC=mpifort
    make
    

          Where the paths to the OMPI wrapper and gcc compilers are correctly substituted in.

    In theory the FC compiler can be replaced with gfortran, however when I did this I was getting a "warning treated as error":

    Error: ‘__builtin_memcpy’ reading 128 bytes from a region of size 112 [-Werror=stringop-overflow=]
    

    Which does not occur when compiling with mpifort. From a quick look the configure script seems to set quite a lot more flags when using gfortran (one of them being -wError which I believe caused the compile error).

  • Does it compile with flang-new: No
    According to documentation you should just be able to replace the FC And CC variables when calling configure. While I could successfully configure the project with ./configure FC=flang-new CC=clang-12 MPIFC=mpifort, when it came to compiling I ended up getting this error:

    $ clang-12 -c -I./setup    -g -O2 -o obj/force_ftz.cc.o src/specfem3D/force_ftz.c
    src/shared/param_reader.c:92:9: error: function cannot return function type 'void (char *, int *, int *)'
    FC_FUNC_(param_open,PARAM_OPEN)(char * filename, int * length, int * ierr)
    

    Whilst the error is a bit confusing, from a quick look I found the configure script does not correctly configure setup/config.h. The FC_FUNC(name,NAME) macro definition is not being generated, leading to the clang compiler getting confused when compiling. It results in looking like:

    /* Define to a macro mangling the given C identifier (in lower and upper
    case), which must not contain underscores, for linking with Fortran. */
    /* #undef FC_FUNC */
    
    /* As FC_FUNC, but for C identifiers containing underscores. */
    /* #undef FC_FUNC_ */
    

    However, if we configure with either gfortran or mpifort the macro definition is generated such:

    /* Define to a macro mangling the given C identifier (in lower and upper
    case), which must not contain underscores, for linking with Fortran. */
    #define FC_FUNC(name,NAME) name ## _
    
    /* As FC_FUNC, but for C identifiers containing underscores. */
    #define FC_FUNC_(name,NAME) name ## _
    

    From looking at the Makefile generating this, and the comment of the macro, I believe this issue is due to not currently including the ExternalNameConversion pass in the pass pipeline definition in the driver. The Makefile should then start generating the macro definition correctly once the pass is included in the default pass pipeline.

Versions:

  • gcc version used: 9.3.0
  • gfortran version used: 9.3.0
  • flang-new, fir-dev branch, HEAD: fb8eb63
  • clang-12: 12.0.0
  • openmpi version used: 4.1.1
  • Architecture for compilation: aarch64

@banach-space banach-space added the apps Building Fortran applications with Flang - status + instructions label Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apps Building Fortran applications with Flang - status + instructions
Projects
None yet
Development

No branches or pull requests

2 participants