Skip to content

Commit

Permalink
Add device_t::mallocHost (Nek5000#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
MalachiTimothyPhillips authored Aug 25, 2021
1 parent b97d4a8 commit aed7ea7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/core/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ device_t::buildKernel(const std::string &filename,
return _kernel;
}
occa::memory
device_t::mallocHost(const dlong Nbytes)
{
occa::properties props;
props["host"] = true;
occa::memory h_scratch = occa::device::malloc(Nbytes, props);
return h_scratch;
}
occa::memory
device_t::malloc(const dlong Nbytes, const occa::properties& properties)
{
return occa::device::malloc(Nbytes, nullptr, properties);
Expand Down
3 changes: 3 additions & 0 deletions src/core/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class device_t : public occa::device{
occa::memory malloc(const dlong Nbytes, const occa::properties& properties);
occa::memory malloc(const dlong Nwords, const dlong wordSize, occa::memory src);
occa::memory malloc(const dlong Nwords, const dlong wordSize);

occa::memory mallocHost(const dlong Nbytes);

int id() const { return _device_id; }
private:
dlong bufferSize;
Expand Down
4 changes: 1 addition & 3 deletions src/elliptic/linearSolver/PGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ GmresData::GmresData(elliptic_t* elliptic)
const dlong Nbytes = restart * Nblock * sizeof(dfloat);
//pinned scratch buffer
{
occa::properties props = platform->kernelInfo;
props["host"] = true;
h_scratch = platform->device.malloc(Nbytes, props);
h_scratch = platform->device.mallocHost(Nbytes);
scratch = (dfloat*) h_scratch.ptr();
}
o_scratch = platform->device.malloc(Nbytes);
Expand Down
4 changes: 1 addition & 3 deletions src/linAlg/linAlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ void linAlg_t::reallocScratch(const dlong Nbytes)
if(o_scratch.size()) o_scratch.free();
//pinned scratch buffer
{
occa::properties props = kernelInfo;
props["host"] = true;
h_scratch = device.malloc(Nbytes, props);
h_scratch = device.mallocHost(Nbytes);
scratch = (dfloat*) h_scratch.ptr();
}
o_scratch = device.malloc(Nbytes);
Expand Down

0 comments on commit aed7ea7

Please sign in to comment.