Make any split operators have lifetime the lifetime of the BatchedCG object

This commit is contained in:
Peter Boyle committed 2026-10-05 11:34:17 -04:00
1 parent 38c6fa78b2
commit f7c25052f4
4 files changed
+72 -58

No files matched your search

+13 -10
View File
@@ -145,16 +145,19 @@ void CheckSplitBatched(const std::string &name,
sol_split[i] = Zero();
}
MixedPrecisionConjugateGradientBatched<FieldD,FieldF> mCG(TOLERANCE,10000,50,1000,grid_f,Linop_f,Linop_d);
std::cout << GridLogMessage << name << ": unsplit batched solve" << std::endl;
mCG.BatchedSplit = Coordinate();
mCG.BatchedSplitNode = false;
mCG(src,sol_ref);
std::cout << GridLogMessage << name << ": split batched solve, partition layout " << layout << std::endl;
mCG.BatchedSplit = layout;
mCG(src,sol_split);
{
std::cout << GridLogMessage << name << ": unsplit batched solve" << std::endl;
MixedPrecisionConjugateGradientBatched<FieldD,FieldF> mCG(TOLERANCE,10000,50,1000,grid_f,Linop_f,Linop_d,
true,Coordinate(),false);
mCG(src,sol_ref);
}
{
std::cout << GridLogMessage << name << ": split batched solve, partition layout " << layout << std::endl;
MixedPrecisionConjugateGradientBatched<FieldD,FieldF> mCG(TOLERANCE,10000,50,1000,grid_f,Linop_f,Linop_d,
true,layout,false);
GRID_ASSERT( (mCG.Partitions == 1) || (mCG.split != nullptr) );
mCG(src,sol_split);
}
FieldD Msol(src[0].Grid());
Msol.Checkerboard() = cb;
+12 -13
View File
@@ -213,25 +213,24 @@ int main (int argc, char ** argv)
ReportMemory(UGrid_d,"operators and sources ready");
MixedPrecisionConjugateGradientBatched<FieldD,FieldF> mCG(tol,10000,50,10000,FrbGrid_f,Linop_f,Linop_d);
Coordinate split = mCG.BatchedSplit;
bool splitnode = mCG.BatchedSplitNode;
if ( unsplit ) {
mCG.BatchedSplit = Coordinate();
mCG.BatchedSplitNode = false;
MixedPrecisionConjugateGradientBatched<FieldD,FieldF> mCG(tol,10000,50,10000,FrbGrid_f,Linop_f,Linop_d,
true,Coordinate(),false);
SolveAndReport("UNSPLIT",mCG,Linop_d,src,sol);
ReportMemory(UGrid_d,"after unsplit solve");
}
mCG.BatchedSplit = split;
mCG.BatchedSplitNode = splitnode;
// Repeated split solves expose allocations not released between calls
for(int r=0;r<repeat;r++){
SolveAndReport("SPLIT",mCG,Linop_d,src,sol);
ReportMemory(UGrid_d,"after split solve "+std::to_string(r));
if ( repeat > 0 ) {
// Split layout from the command line; the split operator is cloned here, once
MixedPrecisionConjugateGradientBatched<FieldD,FieldF> mCG(tol,10000,50,10000,FrbGrid_f,Linop_f,Linop_d);
ReportMemory(UGrid_d,"after split solver construction");
// Repeated split solves reuse the clone and expose allocations not released between calls
for(int r=0;r<repeat;r++){
SolveAndReport("SPLIT",mCG,Linop_d,src,sol);
ReportMemory(UGrid_d,"after split solve "+std::to_string(r));
}
}
ReportMemory(UGrid_d,"after split solver destruction");
Grid_finalize();
}