Skip to content

Commit

Permalink
Making version
Browse files Browse the repository at this point in the history
  • Loading branch information
OSUmageed committed Oct 29, 2017
1 parent a36db41 commit 741aec3
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ cubin/
tempSol.json
src/rslts/*.json
main.pdf
src/utilities/js*
*~*
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- [HeterogeneousSwept1D](#heterogeneousswept1d)
- [Dependencies:](#dependencies)
- [To Run](#to-run)

<!-- /TOC -->

Expand All @@ -13,8 +14,20 @@ Python files in main folder are entry points.

## Dependencies:

------------------------------
[jsoncpp](https://github.com/open-source-parsers/jsoncpp) - jsoncpp.sh in main folder will download, amalgamate and put in utilities folder.

My dependents include:
[palettable](http://www.palettable.io) - to run some of the plotting scripts

------------------------------
CUDA 7.5 or greater
MPI 2

# To Run

make with makefile in src folder

Run from src folder
mpirun -np [nprocs] ./bin/[executable] [scheme (C or S) for classic or swept] [path to json with run specifications (eg. tests folder)] [path to output folder] [additional options as tokens eg. tpb 32 or lx 85]

python script stdExp will run standard experiment.

json files in result folder are coded [s or t for solution or timing[problem eg Euler or Heat][_rank]or[S or C for swept or classic]]
Binary file modified results/Euler_2304.pdf
Binary file not shown.
4 changes: 3 additions & 1 deletion runtools/result_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ def annotatePlot(self, fh, ax):
fh.subplots_adjust(bottom=0.08, right=0.85, top=0.9,
wspace=0.15, hspace=0.25)

def savePlot(self, fh, plotpath):
def savePlot(self, fh, plotpath, shw=False):

plotfile = op.join(plotpath, self.plotname + self.ext)
fh.savefig(plotfile, dpi=200, bbox_inches="tight")
if shw:
plt.show()

def gifify(self, plotpath, fh, ax):

Expand Down
2 changes: 1 addition & 1 deletion src/decomposition/classic.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void classicStepCPU(states *state, int numx, int tstep)
{
stepUpdate(state, k, tstep);
}
// if (tstep % 5000 == 5) cout << numx << " " << ranks[1] << " " << printout(state, 0) << " " << printout(state+1, 0) << " " << tstep << " " << printout(state+numx-1, 0) << " " << printout(state + numx, 0) << endl;
if ((tstep>120 && tstep <125) || tstep<6 ) cout << ranks[1] << " " << printout(state, 0) << " " << printout(state+1, 0) << " " << tstep << " " << printout(state+numx-10, 0) << " " << printout(state + numx, 0) << endl;
}

// void classicDPass(double *putSt, double *getSt, int tstep)
Expand Down
18 changes: 14 additions & 4 deletions src/decomposition/swept.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ void wholeDiamondCPU(states *state, int tstep)
}
tnow++;
}
if(!ranks[1]) cout << tnow << " " << tstep << endl;
}

void splitDiamondCPU(states *state, int tstep)
Expand All @@ -200,13 +201,13 @@ void splitDiamondCPU(states *state, int tstep)
if (n == cGlob.ht)
{
ssLeft[0] = state[n-1], ssLeft[1] = state[n];
stepUpdate(ssLeft, n, tnow);
stepUpdate(&ssLeft[0], n, tnow);
state[n] = ssLeft[1];
}
else if (n == cGlob.htp)
{
ssRight[1] = state[n], ssRight[2] = state[n+1];
stepUpdate(ssRight, n, tnow);
stepUpdate(&ssRight[0], n, tnow);
state[n] = ssRight[1];
}
else
Expand All @@ -224,13 +225,13 @@ void splitDiamondCPU(states *state, int tstep)
if (n == cGlob.ht)
{
ssLeft[0] = state[n-1], ssLeft[1] = state[n];
stepUpdate(ssLeft, n, tnow);
stepUpdate(&ssLeft[0], n, tnow);
state[n] = ssLeft[1];
}
else if (n == cGlob.htp)
{
ssRight[1] = state[n], ssRight[2] = state[n+1];
stepUpdate(ssRight, n, tnow);
stepUpdate(&ssRight[0], n, tnow);
state[n] = ssRight[1];
}
else
Expand Down Expand Up @@ -329,6 +330,8 @@ double sweptWrapper(states **state, ivec xpts, ivec alen, int *tstep)

cout << "UP " << endl;

MPI_Send(state[2] + 5, 1, struct_type, 0, 0, MPI_COMM_WORLD);

// ------------ Pass Edges ------------ //
// -- FRONT TO BACK -- //

Expand Down Expand Up @@ -560,6 +563,13 @@ double sweptWrapper(states **state, ivec xpts, ivec alen, int *tstep)
}
else
{
states tmp;
if (!ranks[1])
{
MPI_Recv(&tmp, 1, struct_type, 3, MPI_ANY_TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
cout << printout(&tmp, 2) << " " << printout(state[0]+1, 2) << endl;
}

const int xc = cGlob.xcpu, xcp = xc+1;
for (int k=0; k<cGlob.cBks; k++)
{
Expand Down
20 changes: 10 additions & 10 deletions src/equations/euler.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ struct eqConsts {

//---------------//
struct states {
REALthree Q[2]; // Full Step, Midpoint step state variables
REAL Pr; // Pressure ratio
REALthree Q[2]; // Full Step, Midpoint step state variables
};

std::string outVars[NVARS] = {"DENSITY", "VELOCITY", "ENERGY", "PRESSURE"}; //---------------//
Expand Down Expand Up @@ -193,7 +193,7 @@ __host__ inline states icond(double xs, double lx)
int side = (xs > HALF*lx);
s.Q[0] = hBounds[side];
s.Q[1] = hBounds[side];
s.Pr = 0.0;
s.Pr = -10.0;
return s;
}

Expand Down Expand Up @@ -247,12 +247,11 @@ __host__ void mpi_type(MPI_Datatype *dtype)
MPI_Type_create_struct(3, n, disp, typs, &vtype);
MPI_Type_commit(&vtype);

typs[0] = vtype;
typs[2] = vtype;
disp[1] = 3*sizeof(vtype);
disp[2] = 4*sizeof(REAL);
int n2[2] = {1, 2};
MPI_Datatype typs2[2] = {MPI_R, vtype};
MPI_Aint disp2[2] = {0, sizeof(REAL)};

MPI_Type_create_struct(3, n, disp, typs, dtype);
MPI_Type_create_struct(2, n2, disp2, typs2, dtype);
MPI_Type_commit(dtype);

MPI_Type_free(&vtype);
Expand Down Expand Up @@ -291,7 +290,7 @@ __device__ __host__
__forceinline__
REALthree limitor(REALthree qH, REALthree qN, REAL pRatio)
{
if(QNAN(pRatio) || pRatio<0)
if(QNAN(pRatio) || (pRatio<1.0e-8))
{
return qH;
}
Expand Down Expand Up @@ -374,12 +373,13 @@ void eulerStep(states *state, int idx, int tstep)
__device__ __host__
void stepUpdate(states *state, int idx, int tstep)
{
int ts = DIVMOD(tstep);
if (tstep & 1) //Odd - Rslt is 0 for even numbers
{
pressureRatio(state, idx, DIVMOD(tstep));
pressureRatio(state, idx, ts);
}
else
{
eulerStep(state, idx, DIVMOD(tstep));
eulerStep(state, idx, ts);
}
}
6 changes: 1 addition & 5 deletions src/equations/heat.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,7 @@ __host__ void initialState(jsons inJs, states *inl, int idx, int xst)

__host__ void mpi_type(MPI_Datatype *dtype)
{
MPI_Datatype typs[2] = {MPI_R, MPI_R};
int n[2] = {1};
MPI_Aint disp[2] = {0, sizeof(REAL)};

MPI_Type_create_struct(2, n, disp, typs, dtype);
MPI_Type_contiguous(2, MPI_R, dtype);
MPI_Type_commit(dtype);
}

Expand Down
4 changes: 2 additions & 2 deletions src/jpyparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
fg, axi = plt.subplots(sp[0], sp[1])
jdf.metaparse(meta)
jdf.plotResult(fg, axi)
jdf.savePlot(fg, resultpath)
jdf.savePlot(fg, resultpath, shw=True)
dff = jdf.ddf
ddfk = list(dff.keys())
dsam = dff[ddfk[0]]
dsk = dsam.columns.values.tolist()


Empty file added src/nohup.out
Empty file.
24 changes: 14 additions & 10 deletions src/solmain.cu
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ int main(int argc, char *argv[])
}
else
{
state = new states* [1];
cudaCheckError(cudaHostAlloc((void **) &state[0], xalloc * cGlob.szState, cudaHostAllocDefault));
state = new states*[1];
state[0] = new states[xalloc * cGlob.szState];
}

for (int i=0; i<nrows; i++)
Expand All @@ -128,7 +128,6 @@ int main(int argc, char *argv[])
}

// If you have selected scheme I, it will only initialize and output the initial values.
if (!ranks[1]) std::cout << "Initial Values Instantiated." << std::endl;

if (scheme.compare("I"))
{
Expand Down Expand Up @@ -207,17 +206,22 @@ int main(int argc, char *argv[])
soljson << solution;
soljson.close();

endMPI();

for (int k=0; k<nrows; k++)
{
cudaFreeHost(state[k]);
}
delete[] state;
if (cGlob.hasGpu)
{
for (int k=0; k<3; k++)cudaFreeHost(state[k]);
cudaDeviceSynchronize();
cudaDeviceReset();
}
else
{
delete[] state[0];
}
delete[] state;
for (int k=0; k<nrows; k++)
{
std::cout << nrows << " " << ranks[1] << " " << cGlob.hasGpu << endl;
}

endMPI();
return 0;
}

0 comments on commit 741aec3

Please sign in to comment.