Skip to content

Commit

Permalink
Replace useSerial with platform->serial. (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
MalachiTimothyPhillips authored Oct 22, 2021
1 parent 2fbe4ba commit 08d40d1
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/cds/registerCdsKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void registerCdsKernels(occa::properties kernelInfoBC) {
fileName = oklpath + "cds/subCycle" + suffix + ".okl";
occa::properties subCycleStrongCubatureProps = prop;

if(useSerial())
if(platform->serial)
fileName = oklpath + "cds/subCycle" + suffix + ".c";

kernelName = "subCycleStrongCubatureVolume" + suffix;
Expand Down
2 changes: 2 additions & 0 deletions src/core/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,6 @@ device_t::device_t(setupAide& options, MPI_Comm commParent, MPI_Comm comm)
}

_device_id = device_id;

deviceAtomic = this->mode() == "CUDA";
}
2 changes: 2 additions & 0 deletions src/core/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class device_t : public occa::device{
const occa::properties &props,
std::string suffix = std::string(),
bool buildRank0 = false) const;
bool deviceAtomic;

private:
occa::kernel doBuildKernel(const std::string &filename,
const std::string &kernelName,
Expand Down
2 changes: 0 additions & 2 deletions src/core/nrssys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ struct platform_t;
extern platform_t* platform;

bool useNodeLocalCache();
bool useSerial();
bool supportsAtomicReductions();

#define EXIT_AND_FINALIZE(a) { fflush(stdout); MPI_Finalize(); exit(a); }
#define ABORT(a) { fflush(stdout); MPI_Abort(MPI_COMM_WORLD, a); }
Expand Down
3 changes: 3 additions & 0 deletions src/core/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ platform_t::platform_t(setupAide& _options, MPI_Comm _commg, MPI_Comm _comm)
kernelInfo["compiler_flags"] += " -funsafe-math-optimizations ";
kernelInfo["compiler_flags"] += " -ffast-math ";
}

serial = platform->device.mode() == "Serial" ||
platform->device.mode() == "OpenMP";
}
void memPool_t::allocate(const dlong offset, const dlong fields)
{
Expand Down
1 change: 1 addition & 0 deletions src/core/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ struct platform_t{
void create_mempool(const dlong offset, const dlong fields);
platform_t(setupAide& _options, MPI_Comm _commg, MPI_Comm _comm);
inipp::Ini *par;
bool serial;

static platform_t* getInstance(setupAide& _options, MPI_Comm _commg, MPI_Comm _comm){
if(!singleton)
Expand Down
2 changes: 1 addition & 1 deletion src/core/registerNrsKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void registerNrsKernels(occa::properties kernelInfoBC)
prop["defines/p_cubNp"] = cubNp;
fileName = oklpath + "nrs/Urst" + suffix + ".okl";

const bool serial = useSerial();
const bool serial = platform->serial;
if(serial) fileName = oklpath + "nrs/Urst" + suffix + ".c";
kernelName = "UrstCubature" + suffix;
platform->kernels.add(
Expand Down
7 changes: 1 addition & 6 deletions src/elliptic/ellipticBuildSEMFEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,7 @@ SEMFEMData* ellipticBuildSEMFEM(const int N_, const int n_elem_,
/* mode */ 0);
}

constructOnHost =
platform->device.mode() == std::string("OpenCL")
||
platform->device.mode() == std::string("HIP")
||
platform->device.mode() == std::string("Serial");
constructOnHost = !platform->device.deviceAtomic;

if(!constructOnHost) load();

Expand Down
4 changes: 2 additions & 2 deletions src/elliptic/registerEllipticKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void registerGMRESKernels(const std::string &section, int Nfields) {
installDir.assign(getenv("NEKRS_INSTALL_DIR"));
const std::string oklpath = installDir + "/okl/elliptic/";
std::string fileName;
const bool serial = useSerial();
const bool serial = platform->serial;

const std::string fileNameExtension = (serial) ? ".c" : ".okl";
const std::string sectionIdentifier = std::to_string(Nfields) + "-";
Expand Down Expand Up @@ -67,7 +67,7 @@ void registerEllipticKernels(std::string section) {
return false;
}();

const bool serial = useSerial();
const bool serial = platform->serial;

const std::string fileNameExtension = (serial) ? ".c" : ".okl";

Expand Down
8 changes: 4 additions & 4 deletions src/elliptic/registerEllipticPreconditionerKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void registerSchwarzKernels(const std::string &section, int N) {
const int Np_e = Nq_e * Nq_e * Nq_e;

bool overlap = false;
const bool serial = useSerial();
const bool serial = platform->serial;
if (Nq >= 5 && !serial)
overlap = true;

Expand Down Expand Up @@ -174,7 +174,7 @@ void registerFineLevelKernels(const std::string &section, int N) {
std::string installDir;
installDir.assign(getenv("NEKRS_INSTALL_DIR"));
const std::string oklpath = installDir + "/okl/elliptic/";
const bool serial = useSerial();
const bool serial = platform->serial;
const std::string fileNameExtension = (serial) ? ".c" : ".okl";

{
Expand Down Expand Up @@ -258,7 +258,7 @@ void registerMultigridLevelKernels(const std::string &section, int Nf, int N) {
const std::string oklpath = installDir + "/okl/elliptic/";
registerCommonMGPreconditionerKernels(N, kernelInfo);

const bool serial = useSerial();
const bool serial = platform->serial;

const std::string fileNameExtension = (serial) ? ".c" : ".okl";

Expand Down Expand Up @@ -441,7 +441,7 @@ void registerSEMFEMKernels(const std::string &section, int N) {
stiffnessKernelInfo["defines/p_rows_sorted"] = 1;
stiffnessKernelInfo["defines/p_cols_sorted"] = 0;

const bool constructOnHost = !supportsAtomicReductions();
const bool constructOnHost = !platform->device.deviceAtomic;

if (!constructOnHost) {
platform->kernels.add("computeStiffnessMatrix",
Expand Down
9 changes: 0 additions & 9 deletions src/lib/nekrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ bool useNodeLocalCache(){
return (buildNodeLocal > 0);
}

bool useSerial(){
return (platform->device.mode() == "Serial" ||
platform->device.mode() == "OpenMP");
}

bool supportsAtomicReductions(){
return platform->device.mode() == "CUDA";
}

namespace nekrs
{
double startTime(void)
Expand Down
2 changes: 1 addition & 1 deletion src/linAlg/registerLinAlgKernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void registerLinAlgKernels()
oklDir.assign(getenv("NEKRS_INSTALL_DIR"));
oklDir += "/okl/linAlg/";
std::string fileName;
const bool serial = useSerial();
const bool serial = platform->serial;

platform->kernels.add(
"fill", oklDir + "linAlgFill.okl", "fill", kernelInfo);
Expand Down

0 comments on commit 08d40d1

Please sign in to comment.