Skip to content

Commit

Permalink
Added timings
Browse files Browse the repository at this point in the history
  • Loading branch information
jonycastagna committed Sep 9, 2024
1 parent 0ba4729 commit 7b1c502
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 9 deletions.
20 changes: 12 additions & 8 deletions examples/hasegawa-wakatani-3d/data/BOUT.inp
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
# Hasegawa-Wakatani test case
#

timestep = 1. # Output timestep
nout = 100 # Number of output steps
timestep = 0.000001 # Output timestep
nout = 1 # Number of output steps
#nout = 1 # Number of output steps

[mesh]
Lx = 51.2
Ly = 16.0
Lz = 51.2

nx = 68 # Note 4 guard cells in X
ny = 16
nz = 64 # Periodic, so no guard cells in Z
nx = 36 # Note 4 guard cells in X
ny = 16
nz = 32 # Periodic, so no guard cells in Z

dx = Lx/(nx-4)
dy = Ly/ny
dz = Lz/nz

dx = 0.2
dy = 1.
dz = 0.2

# Set periodic boundary condition in y
ixseps1 = nx
Expand Down
48 changes: 47 additions & 1 deletion examples/hasegawa-wakatani-3d/hw.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ class HW3D : public PhysicsModel {
double deltaz;
double psimtime = 0.0;

bool profile_StylES = false;
bool profile_StylES = true;
bool implicitStylES = false;

Field3D pPhiVort;
Expand Down Expand Up @@ -602,15 +602,36 @@ class HW3D : public PhysicsModel {

double *rLES;


if (profile_StylES){
timeStart = high_resolution_clock::now();
}

// Solve for potential
if (pStep>0){
phi = phiSolver->solve(vort, phi);
}

if (profile_StylES)
{
timeStop = high_resolution_clock::now();
auto timeDiff = duration_cast<microseconds>(timeStop - timeStart);
printf("BOUT++ timing solve potential %f\n", timeDiff.count()/1.0e6);
timeStart = high_resolution_clock::now();
}

Field3D phi_minus_n = phi - n;
// Communicate variables
mesh->communicate(n, vort, phi, phi_minus_n);

if (profile_StylES)
{
timeStop = high_resolution_clock::now();
auto timeDiff = duration_cast<microseconds>(timeStop - timeStart);
printf("BOUT++ timing communicate %f\n", timeDiff.count()/1.0e6);
timeStart = high_resolution_clock::now();
}

// Create accessors which enable fast access
auto n_acc = FieldAccessor<>(n);
auto vort_acc = FieldAccessor<>(vort);
Expand All @@ -631,13 +652,30 @@ class HW3D : public PhysicsModel {
int LES_it = int(rLES[0]);
int cont=1;

if (profile_StylES)
{
timeStop = high_resolution_clock::now();
auto timeDiff = duration_cast<microseconds>(timeStop - timeStart);
printf("BOUT++ timing findLESTerms %f\n", timeDiff.count()/1.0e6);
timeStart = high_resolution_clock::now();
}

for(int i=2; i<n.getNx()-2; i++) // we assume 2 guards cells in x-direction
for(int j=2; j<n.getNy()-2; j++)
for(int k=0; k<n.getNz(); k++){
pPhiVort(i,j,k) = rLES[cont + 0*SIZE];
pPhiN(i,j,k) = rLES[cont + 1*SIZE];
cont = cont+1;
}

if (profile_StylES)
{
timeStop = high_resolution_clock::now();
auto timeDiff = duration_cast<microseconds>(timeStop - timeStart);
printf("BOUT++ timing passing to CPU %f\n", timeDiff.count()/1.0e6);
timeStart = high_resolution_clock::now();
}

}
else{
BOUT_FOR_RAJA(i, n.getRegion("RGN_NOBNDRY"), CAPTURE(alpha, kappa, Dn, Dvort)) {
Expand All @@ -656,6 +694,14 @@ class HW3D : public PhysicsModel {
ddt(vort_acc)[i] = -pPhiVort[i] - div_current + Dvort * Delp2(vort_acc, i);
}

if (profile_StylES)
{
timeStop = high_resolution_clock::now();
auto timeDiff = duration_cast<microseconds>(timeStop - timeStart);
printf("BOUT++ timing integrate %f\n\n", timeDiff.count()/1.0e6);
timeStart = high_resolution_clock::now();
}

pStep++;
return 0;
}
Expand Down

0 comments on commit 7b1c502

Please sign in to comment.