Skip to content

Deterministic YAFluxRegister on GPU #4677

Description

@BenWibking

On GPU, YAFluxRegister is nondeterministic due to the use of atomics in yafluxreg_fineadd:

> Src/Boundary/AMReX_YAFluxRegister_3D_K.H:70:

      case 0 :
      {
          for (int n = 0; n < nc; ++n) {
              for     (int k = lo.z; k <= hi.z; ++k) {
                  for (int j = lo.y; j <= hi.y; ++j) {
                      const int i = lo.x;
                      const int ii = (i+1)*rr.x;
                      T* AMREX_RESTRICT dp = &(d(i,j,k,n));
                      for (    int koff = 0; koff < rr.z; ++koff) {
                          const     int kk =      k*rr.z  + koff;
                          for (int joff = 0; joff < rr.y; ++joff) {
                              const int jj =      j*rr.y  + joff;
                              T tmp = -dtdx*f(ii,jj,kk,n);
                              HostDevice::Atomic::Add(dp, tmp);

>  Src/Boundary/AMReX_YAFluxRegister_3D_K.H:92:

      case 1 :
      {
          for (int n = 0; n < nc; ++n) {
              for     (int k = lo.z; k <= hi.z; ++k) {
                  for (int j = lo.y; j <= hi.y; ++j) {
                      const int i = lo.x;
                      const int ii = i*rr.x;
                      T* AMREX_RESTRICT dp = &(d(i,j,k,n));
                      for (int     koff = 0; koff < rr.z; ++koff) {
                          const     int kk =      k*rr.z  + koff;
                          for (int joff = 0; joff < rr.y; ++joff) {
                              const int jj =      j*rr.y  + joff;
                              T tmp = dtdx*f(ii,jj,kk,n);
                              HostDevice::Atomic::Add(dp, tmp);

This means that bitwise reproducibility is currently not possible for our code when using AMR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions