Skip to content

Commit

Permalink
Import latest changes (#137)
Browse files Browse the repository at this point in the history
* fix shared Dirichlet-Neumann edges for scalars
* add support for oogs min/max
* fix kernel launch issues for some kernels if threadBlockCount is zero
* fix oogs buffer size
* fix swapped bdf/ext in scalar rhs 
* do not use extrapolated velocity in convection term for scalars
  • Loading branch information
stgeke authored Aug 13, 2020
1 parent 9a1a70b commit d9c871f
Show file tree
Hide file tree
Showing 25 changed files with 687 additions and 696 deletions.
5 changes: 3 additions & 2 deletions 3rd_party/gslib/ogs/ogs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ typedef struct {
occa::memory o_scatterOffsets, o_gatherOffsets;
occa::memory o_scatterIds, o_gatherIds;

occa::kernel packBufDoubleKernel, unpackBufDoubleKernel;
occa::kernel packBufFloatKernel, unpackBufFloatKernel;
occa::kernel packBufDoubleKernel, packBufFloatKernel;
occa::kernel unpackBufDoubleAddKernel, unpackBufDoubleMinKernel, unpackBufDoubleMaxKernel;
occa::kernel unpackBufFloatAddKernel;

oogs_mode mode;

Expand Down
96 changes: 73 additions & 23 deletions 3rd_party/gslib/ogs/okl/oogs.okl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@kernel void packBuf_float(const dlong Nscatter,
const int Nentries,
@restrict const dlong * scatterStarts,
@restrict const dlong * scatterIds,
@restrict const float * q,
@restrict float * scatterq){
const int Nentries,
@restrict const dlong * scatterStarts,
@restrict const dlong * scatterIds,
@restrict const float * q,
@restrict float * scatterq){

for(dlong s=0;s<Nscatter*Nentries;++s;@tile(256,@outer,@inner)){

Expand All @@ -22,11 +22,11 @@
}

@kernel void packBuf_double(const dlong Nscatter,
const int Nentries,
@restrict const dlong * scatterStarts,
@restrict const dlong * scatterIds,
@restrict const double * q,
@restrict double * scatterq){
const int Nentries,
@restrict const dlong * scatterStarts,
@restrict const dlong * scatterIds,
@restrict const double * q,
@restrict double * scatterq){

for(dlong s=0;s<Nscatter*Nentries;++s;@tile(256,@outer,@inner)){

Expand All @@ -44,12 +44,12 @@
}
}

@kernel void unpackBuf_float(const dlong Ngather,
const int Nentries,
@restrict const dlong * gatherStarts,
@restrict const dlong * gatherIds,
@restrict const float * q,
@restrict float * gatherq){
@kernel void unpackBuf_floatAdd(const dlong Ngather,
const int Nentries,
@restrict const dlong * gatherStarts,
@restrict const dlong * gatherIds,
@restrict const float * q,
@restrict float * gatherq){

for(dlong g=0;g<Ngather*Nentries;++g;@tile(256,@outer,@inner)){

Expand All @@ -69,13 +69,13 @@
}
}

@kernel void unpackBuf_double(const dlong Ngather,
const int Nentries,
@restrict const dlong * gatherStarts,
@restrict const dlong * gatherIds,
@restrict const double * q,
@restrict double * gatherq){

@kernel void unpackBuf_doubleAdd(const dlong Ngather,
const int Nentries,
@restrict const dlong * gatherStarts,
@restrict const dlong * gatherIds,
@restrict const double * q,
@restrict double * gatherq){
for(dlong g=0;g<Ngather*Nentries;++g;@tile(256,@outer,@inner)){

const dlong gid = g%Ngather;
Expand All @@ -94,4 +94,54 @@
}
}

@kernel void unpackBuf_doubleMin(const dlong Ngather,
const int Nentries,
@restrict const dlong * gatherStarts,
@restrict const dlong * gatherIds,
@restrict const double * q,
@restrict double * gatherq){

for(dlong g=0;g<Ngather*Nentries;++g;@tile(256,@outer,@inner)){

const dlong gid = g%Ngather;
const int k = g/Ngather;
const dlong start = gatherStarts[gid];
const dlong end = gatherStarts[gid+1];

const dlong startId = gatherIds[start];
double gq = q[startId*Nentries+k];
for(dlong n=start;n<end;++n){
const dlong id = gatherIds[n];
gq = (q[id*Nentries+k] < gq) ? q[id*Nentries+k] : gq;
}

//contiguously packed
gatherq[g] = gq;
}
}

@kernel void unpackBuf_doubleMax(const dlong Ngather,
const int Nentries,
@restrict const dlong * gatherStarts,
@restrict const dlong * gatherIds,
@restrict const double * q,
@restrict double * gatherq){

for(dlong g=0;g<Ngather*Nentries;++g;@tile(256,@outer,@inner)){

const dlong gid = g%Ngather;
const int k = g/Ngather;
const dlong start = gatherStarts[gid];
const dlong end = gatherStarts[gid+1];

const dlong startId = gatherIds[start];
double gq = q[startId*Nentries+k];
for(dlong n=start;n<end;++n){
const dlong id = gatherIds[n];
gq = (q[id*Nentries+k] > gq) ? q[id*Nentries+k] : gq;
}

//contiguously packed
gatherq[g] = gq;
}
}
Loading

0 comments on commit d9c871f

Please sign in to comment.