Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Pools #82

Merged
merged 22 commits into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
bca7ddc
[OCCA] Update OCCA with latest fixes
noelchalmers Nov 17, 2022
eccb689
[Core] Add occa memory pools to platform
noelchalmers Nov 17, 2022
d1c378b
[LinAlg] Use memory pools in linAlg. Also merge some okl kernels
noelchalmers Nov 17, 2022
9468c29
[InitialGuess] Use memory pools in initialGuess generators. Also twea…
noelchalmers Nov 17, 2022
468d917
[InitialGuess] Update some initial guess kernels
noelchalmers Nov 17, 2022
efedee1
[LinearSolver] Use memory pools in linearSolvers and update some kernels
noelchalmers Nov 17, 2022
5b67c67
[ParAlmond] Use memory pools in parAlmond and update some kernels
noelchalmers Nov 17, 2022
da181d0
[TimeStepper] Use memory pools in timesteppers and update some kernels
noelchalmers Nov 17, 2022
234d46e
[Elliptic] Use memory pools in elliptic solver
noelchalmers Nov 17, 2022
0894686
[Advection] Use memory pools in advection solver
noelchalmers Nov 17, 2022
00541b7
[Acoustics] Use memory pools in acoustics solver
noelchalmers Nov 17, 2022
1e5656f
[Gradient] Use memory pools in gradient solver
noelchalmers Nov 17, 2022
1fc2eb4
[cns] Use memory pools in cns solver
noelchalmers Nov 17, 2022
99a3c79
[bns] Use memory pools in bns solver
noelchalmers Nov 17, 2022
a7eb5e2
[fpe] Use memory pools in fpe solver
noelchalmers Nov 17, 2022
6545f03
[ins] Use memory pools in ins solver
noelchalmers Nov 17, 2022
ea3c3c1
[Test] Small tweak in elliptic test
noelchalmers Nov 17, 2022
84b190b
[Elliptic] Initialize x to zero in elliptic solver runs
noelchalmers Nov 17, 2022
ce58ea5
[Memory] Don't let pinnedMemory be implicitly convertable to deviceMe…
noelchalmers Nov 18, 2022
cea4e35
[Mesh] Fix a warning about uninitialized variables
noelchalmers Nov 18, 2022
c3aa8e8
Make some unintentionally synchronous memcopies asynchronous
noelchalmers Nov 18, 2022
7a74aff
The 'do nothing' initialGuess strategy isn't safe since the input vec…
noelchalmers Nov 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Elliptic] Use memory pools in elliptic solver
  • Loading branch information
noelchalmers committed Nov 18, 2022
commit 234d46e09aedbfc88a3cd6b51ba2f5fda2fdd37f
5 changes: 0 additions & 5 deletions solvers/elliptic/elliptic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,10 @@ class elliptic_t: public solver_t {

int disc_ipdg, disc_c0;

deviceMemory<dfloat> o_AqL;

ogs::halo_t traceHalo;

precon_t precon;

memory<dfloat> grad;
deviceMemory<dfloat> o_grad;

memory<dfloat> weight, weightG;
deviceMemory<dfloat> o_weight, o_weightG;

Expand Down
32 changes: 6 additions & 26 deletions solvers/elliptic/ellipticPrecon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class MassMatrixPrecon: public operator_t {
mesh_t mesh;
settings_t settings;

deviceMemory<dfloat> o_MrL, o_rtmp;
deviceMemory<dfloat> o_invMM;

kernel_t blockJacobiKernel;
Expand All @@ -70,9 +69,6 @@ class ParAlmondPrecon: public operator_t {

parAlmond::parAlmond_t parAlmond;

memory<dfloat> xG, rhsG;
deviceMemory<dfloat> o_xG, o_rhsG;

public:
ParAlmondPrecon() = default;
ParAlmondPrecon(elliptic_t& elliptic);
Expand Down Expand Up @@ -105,12 +101,11 @@ class SEMFEMPrecon: public operator_t {
elliptic_t femElliptic;
parAlmond::parAlmond_t parAlmond;

deviceMemory<dfloat> o_MrL;

deviceMemory<dfloat> o_zFEM, o_rFEM;
deviceMemory<dfloat> o_GzFEM, o_GrFEM;

ogs::ogs_t FEMogs;
ogs::halo_t FEMgHalo;

memory<dlong> FEMGlobalToLocal;
deviceMemory<dlong> o_FEMGlobalToLocal;

kernel_t SEMFEMInterpKernel;
kernel_t SEMFEMAnterpKernel;
Expand Down Expand Up @@ -146,13 +141,6 @@ class MGLevel: public parAlmond::multigridLevel {
dfloat lambda1, lambda0;
int ChebyshevIterations;

static dlong NsmootherResidual, Nscratch;
static memory<dfloat> smootherResidual;
static deviceMemory<dfloat> o_smootherResidual;
static deviceMemory<dfloat> o_smootherResidual2;
static deviceMemory<dfloat> o_smootherUpdate;
static deviceMemory<dfloat> o_transferScratch;

//jacobi data
deviceMemory<dfloat> o_invDiagA;

Expand All @@ -176,12 +164,12 @@ class MGLevel: public parAlmond::multigridLevel {
void smoothJacobi (deviceMemory<dfloat> &o_r, deviceMemory<dfloat> &o_X, bool xIsZero);
void smoothChebyshev (deviceMemory<dfloat> &o_r, deviceMemory<dfloat> &o_X, bool xIsZero);

size_t SmootherScratchSize();

void Report();

void SetupSmoother();
dfloat maxEigSmoothAx();

void AllocateStorage();
};

// Overlapping additive Schwarz with patch problems consisting of the
Expand All @@ -206,14 +194,6 @@ class OASPrecon: public operator_t {
ogs::ogs_t ogsMasked;
parAlmond::parAlmond_t parAlmond;

memory<dfloat> rPatch, zPatch;
memory<dfloat> rPatchL, zPatchL;
deviceMemory<dfloat> o_rPatch, o_zPatch;
deviceMemory<dfloat> o_rPatchL, o_zPatchL;

memory<dfloat> rC, zC;
deviceMemory<dfloat> o_rC, o_zC;

memory<dfloat> patchWeight;
deviceMemory<dfloat> o_patchWeight;

Expand Down
5 changes: 4 additions & 1 deletion solvers/elliptic/okl/ellipticSEMFEMAnterp.okl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SOFTWARE.


@kernel void ellipticSEMFEMAnterp(const dlong Nelements,
@restrict const dlong * GlobalToLocal,
@restrict const dfloat * P,
@restrict const dfloat * q,
@restrict dfloat * Pq){
Expand All @@ -39,7 +40,9 @@ SOFTWARE.
const dlong e = eo + es;
if(e<Nelements){
for (int t=n;t<p_NpFEM;t+=p_Np) {
s_q[es][t] = q[e*p_NpFEM+t];
const dlong base = t + e*p_NpFEM;
const dlong id = GlobalToLocal[base];
s_q[es][t] = (id!=-1) ? q[id] : 0.0;
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion solvers/elliptic/okl/ellipticSEMFEMInterp.okl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SOFTWARE.


@kernel void ellipticSEMFEMInterp(const dlong Nelements,
@restrict const dlong * GlobalToLocal,
@restrict const dfloat * I,
@restrict const dfloat * q,
@restrict dfloat * Iq){
Expand All @@ -39,7 +40,9 @@ SOFTWARE.
const dlong e = eo + es;
if(e<Nelements){
for (int t=n;t<p_Np;t+=p_NpFEM) {
s_q[es][t] = q[e*p_Np+t];
const dlong base = t + e*p_Np;
const dlong id = GlobalToLocal[base];
s_q[es][t] = (id!=-1) ? q[id] : 0.0;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions solvers/elliptic/src/ellipticOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
void elliptic_t::Operator(deviceMemory<dfloat> &o_q, deviceMemory<dfloat> &o_Aq){

if(disc_c0){
//buffer for local Ax
deviceMemory<dfloat> o_AqL = platform.reserve<dfloat>(mesh.Np*mesh.Nelements);

// int mapType = (mesh.elementType==Mesh::HEXAHEDRA &&
// mesh.settings.compareSetting("ELEMENT MAP", "TRILINEAR")) ? 1:0;

Expand Down Expand Up @@ -106,6 +109,9 @@ void elliptic_t::Operator(deviceMemory<dfloat> &o_q, deviceMemory<dfloat> &o_Aq)
ogsMasked.GatherFinish(o_Aq, o_AqL, 1, ogs::Add, ogs::Trans);

} else if(disc_ipdg) {
//buffer for gradient
dlong Ntotal = mesh.Np*(mesh.Nelements+mesh.totalHaloPairs);
deviceMemory<dfloat> o_grad = platform.reserve<dfloat>(Ntotal*4);

if(mesh.Nelements) {
dlong offset = 0;
Expand Down
7 changes: 3 additions & 4 deletions solvers/elliptic/src/ellipticPreconMassMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ MassMatrixPrecon::MassMatrixPrecon(elliptic_t& _elliptic):
blockJacobiKernel = elliptic.platform.buildKernel(DELLIPTIC "/okl/ellipticPreconBlockJacobi.okl",
"blockJacobi", kernelInfo);
} else if (settings.compareSetting("DISCRETIZATION", "CONTINUOUS")) {
dlong Ntotal = elliptic.ogsMasked.Ngather + elliptic.gHalo.Nhalo;
o_rtmp = elliptic.platform.malloc<dfloat>(Ntotal);
o_MrL = elliptic.platform.malloc<dfloat>(mesh.Np*mesh.Nelements);

partialBlockJacobiKernel = elliptic.platform.buildKernel(DELLIPTIC "/okl/ellipticPreconBlockJacobi.okl",
"partialBlockJacobi", kernelInfo);
}
Expand All @@ -67,6 +63,9 @@ void MassMatrixPrecon::Operator(deviceMemory<dfloat>& o_r, deviceMemory<dfloat>&
linAlg_t& linAlg = elliptic.platform.linAlg();

if (elliptic.disc_c0) {//C0
dlong Ntotal = elliptic.ogsMasked.Ngather + elliptic.gHalo.Nhalo;
deviceMemory<dfloat> o_rtmp = elliptic.platform.reserve<dfloat>(Ntotal);
deviceMemory<dfloat> o_MrL = elliptic.platform.reserve<dfloat>(mesh.Np*mesh.Nelements);

// rtmp = invDegree.*r
linAlg.amxpy(elliptic.Ndofs, 1.0, elliptic.o_weightG, o_r, 0.0, o_rtmp);
Expand Down
Loading