devitocodes / devito

DSL and compiler framework for automated finite-differences and stencil computation
http://www.devitoproject.org
MIT License
537 stars 221 forks source link

mpi: Generate deterministic code for overlap mode #2303

Closed georgebisbas closed 4 months ago

georgebisbas commented 4 months ago

Overlap mode did not have deterministic code generation.

static void remainder0(struct dataobj *restrict u_vec, const float a, const float dt, float r0, float r1, float r2, int t0, int t1, const int x_M, const int x_m, const int y_M, const int y_m, const int nthreads)
{
  compute0(a,u_vec,dt,r0,r1,r2,t0,t1,x_M - 2,x_m + 2,MIN(y_M, y_m + 1),y_m,nthreads);
  compute0(a,u_vec,dt,r0,r1,r2,t0,t1,x_M - 2,x_m + 2,y_M,MAX(y_m, y_M - 1),nthreads);
  compute0(a,u_vec,dt,r0,r1,r2,t0,t1,MIN(x_M, x_m + 1),x_m,y_M - 2,y_m + 2,nthreads);
  compute0(a,u_vec,dt,r0,r1,r2,t0,t1,MIN(x_M, x_m + 1),x_m,MIN(y_M, y_m + 1),y_m,nthreads);
  compute0(a,u_vec,dt,r0,r1,r2,t0,t1,MIN(x_M, x_m + 1),x_m,y_M,MAX(y_m, y_M - 1),nthreads);
  compute0(a,u_vec,dt,r0,r1,r2,t0,t1,x_M,MAX(x_m, x_M - 1),y_M - 2,y_m + 2,nthreads);
  compute0(a,u_vec,dt,r0,r1,r2,t0,t1,x_M,MAX(x_m, x_M - 1),MIN(y_M, y_m + 1),y_m,nthreads);
  compute0(a,u_vec,dt,r0,r1,r2,t0,t1,x_M,MAX(x_m, x_M - 1),y_M,MAX(y_m, y_M - 1),nthreads);
}

compute0 calls could have random order.

Also, MIN/MAX macros could have random order. (this is a side-effect, not overlap specific)

To reproduce, you could run a script multiple times with DEVITO_MPI=overlap

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (313c980) 86.69% compared to head (a272ba3) 86.69%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2303 +/- ## ======================================= Coverage 86.69% 86.69% ======================================= Files 229 229 Lines 43043 43043 Branches 7983 7983 ======================================= Hits 37318 37318 Misses 5034 5034 Partials 691 691 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

georgebisbas commented 4 months ago

@mloubout @FabioLuporini this should be ok?

FabioLuporini commented 4 months ago

Thanks, merged