ParRes / Kernels

This is a set of simple programs that can be used to explore the features of a parallel platform.
https://groups.google.com/forum/#!forum/parallel-research-kernels
Other
409 stars 107 forks source link

F90 PIC #542

Closed hattom closed 3 years ago

hattom commented 3 years ago

Limitations:

Features

If this pull request is fixing a bug, please link the associated issue. The rest of this template does not apply.

If this pull request is providing a new implementation of the PRKs, please use the following template.

Note that checking all of the boxes is not required.

New PRK implementation checklist

Which kernels are implemented?

Documentation and build examples

If your implementation uses a new programming model that is not ubiquitious (i.e. included in the system compiler on most systems) then you need to provide a link to the appropriate documentation for a new user to install it, etc.

We strongly recommend that you add the appropriate features to make.defs.${toolchain} if appropriate.

Do you certify that your contribution is made in good faith and does not attempt to introduce any negative behavior into this project?

jeffhammond commented 3 years ago

Please make sure the code is standard Fortran and portable to Intel, PGI/NV or Flang, IBM and/or Cray Fortran.

% gfortran -std=f2008 -cpp -g -O3 -mtune=native -ffast-math -Wall pic.F90 -o pic
pic.F90:374:83:

  374 |     x_periodic = mod(x_final + real(iterations+1, kind=REAL64) * (2*part%k + 1)*L, real(L))
      |                                                                                   1
Error: GNU Extension: Different type kinds at (1)
pic.F90:375:80:

  375 |     y_periodic = mod(y_final + real(iterations+1, kind=REAL64) * abs(part%m)*L, real(L))
      |                                                                                1
Error: GNU Extension: Different type kinds at (1)
pic.F90:298:25:

  298 |       q_sign = 2 * mod(x,2) - 1
      |                         1
Error: GNU Extension: Different type kinds at (1)
pic.F90:223:17:

  223 |         if(mod(x,2)==0) then
      |                 1
Error: GNU Extension: Different type kinds at (1)
% gfortran -v 
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc/10.2.0_3/libexec/gcc/aarch64-apple-darwin20/10.2.1/lto-wrapper
Target: aarch64-apple-darwin20
Configured with: ../configure --build=aarch64-apple-darwin20 --prefix=/opt/homebrew/Cellar/gcc/10.2.0_3 --libdir=/opt/homebrew/Cellar/gcc/10.2.0_3/lib/gcc/10 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-10 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 10.2.0_3' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk SED=/usr/bin/sed
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.1 20201220 (Homebrew GCC 10.2.0_3) 
jeffhammond commented 3 years ago

It seems that PIC can be useful to evaluate SOA vs AOS issues, which is really cool. I have barely looked at it and didn't realize this.

hattom commented 3 years ago

Only 1 remaining warning (t0 could be uninitialized).

Indeed, SoA vs AoS (vs AoSoA) is an interesting topic for PIC codes, both for vectorization and GPU. We have codes using both column first and row first particle data.

jeffhammond commented 3 years ago

Thanks! The t0 warning is false since the code should bail out if the user specifies less than one iteration, but gfortran is not a static analysis tool and I do not expect it to detect this. I have silenced the warning in the C/C++ codes but only because I need to worry more about false positives there.