stfc / PSycloneBench

Various benchmarks used to inform PSyclone optimisations
BSD 3-Clause "New" or "Revised" License
6 stars 5 forks source link

Building with llvm #71

Open LonelyCat124 opened 3 years ago

LonelyCat124 commented 3 years ago

I'm trying to build PSycloneBench with flang/clang for the Excalibur project.

I have made a first version of llvm.sh compiler script, but I've found a couple of things that don't work, some of which might be our issues and some which aren't.

  1. dl_timer doesn't compile with flang. It complains in clear_timers that with default(none) various things are not declared (MAX_TIMERS, _int64, _r_def, etc.). Now I'm pretty sure these don't need to be defined, but using default(shared) works around the issue for now.
  2. dl_esm_inf fails to build, and this one confuses me. The error I see is
    /home/achalk/PSycloneBench/shared/dl_esm_inf/finite_difference/src//field_mod.f90:60:11: error: The derived type 'grid_type' was forward-referenced but not defined
       type(grid_type), pointer :: grid
            ^^^^^^^^^

    Now this should be defined in grid_mod, which does exist and compiled:

    [achalk@glados src]$ ls grid_mod*
    grid_mod.f18.mod  grid_mod.f90  grid_mod.mod  grid_mod.o

I could try using clang + gfortran but I'm not sure if I can use the correct openmp library, but will give it a try in the mean time. Edit: ar won't work with clang .o files and gfortran .o files combined so I can't do clang + gfortran.

LonelyCat124 commented 3 years ago

So somehow in spite of the errors for dl_esm_inf, it still decides to make lib_fd.a, however the later imports on field_mod all fail

LonelyCat124 commented 3 years ago

Ok, so I think this again a flang bug? But I'm no expert on fortran The issues seems to be that flang believes that the definition ofgrid_type` as public is not allowed, i..e:

type, public :: grid_type

does not work (or is hidden by the interface?)

Instead, if I remove that declaration of encapsulation, and instead add

public grid_init, HALO_WIDTH_X, HALO_WIDTH_Y, grid_type

then it seems to compile the library

Next confusion is what is

benchmarks/nemo/nemolite2d/common/gocean2d_io_mod.f90:    use parallel_mod, only: on_master
benchmarks/nemo/nemolite2d/common/gocean2d_io_mod.f90:    if (on_master()) then
arporter commented 3 years ago

I think this code compiles and works with gfortran, nvidia and Intel so it seems likely it's a Flang bug :-)

LonelyCat124 commented 3 years ago

I discussed with rupert this morning and am going to hold off reporting bugs to flang until the next llvm release.