Notes on porting pair styles to KOKKOS

Hi all (and the kokkos folks in particular),

Today I ran into the fact that pair_yukawa was GPU-enabled but not KOKKOS-enabled, so I ported it, following the approach I followed for pair_morse.
This time, however, I was smart enough to write down notes about the porting process, which will probably be of use to anyone that is interested in porting pair styles to kokkos.

I have attached the notes here. I also ran into some questions, which I will put here:

  • Why does PairKokkos check narg before calling Pair::settings? This seems like a violation of Don’t Repeat Yourself?
  • A lot of it is just boiler-plating and renaming. Can we template more?
    I know this will make compile times even worse but it will save a lot of copy paste errors. My C++ metaprogramming is not good enough to do this I think.
  • There is no factor_lj in compute_fpair/compute_evdwl. Are these applied later?
  • Which headers are really required? I just included everything pair_morse_kokkos.cpp also included, but it might be worth filtering out some.

I am thinking it would be useful to have this floating around the website as a tutorial, because I can imagine other people might want to take advantage of GPU acceleration for their pair styles. Although KOKKOS looks intimidating, it really is mostly a copy-paste job…

I will file a pull request for pair_yukawa_kokkos.{cpp,h} later.

Hope this helps,

P.S.: Are there any plans to have KOKKOS target OpenCL in the future?

porting-pair-styles-to-kokkos.txt (13.5 KB)

Thanks Stefan, it sounds quite useful to have this doc
distributed with LAMMPS. I’ll let Stan answer the specific Qs.

I don’t think the Kokkos folks have current plans to support
OpenCL. I think they don’t view it as having a strong future.