Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 17 additions & 4 deletions applications/solvers/dfLowMachFoam/dfLowMachFoam.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Description
pseudo-transient simulations.

\*---------------------------------------------------------------------------*/

#include "stdlib.h"
#include "dfChemistryModel.H"
#include "CanteraMixture.H"
// #include "hePsiThermo.H"
Expand Down Expand Up @@ -62,7 +62,8 @@ Description

#define GPUSolverNew_
#define TIME
// #define DEBUG_
// #define DEBUG_
#define SHOW_MEMINFO

#include "dfMatrixDataBase.H"

Expand Down Expand Up @@ -452,8 +453,6 @@ int main(int argc, char *argv[])
}
end = std::clock();
time_monitor_turbulence_correct += double(end - start) / double(CLOCKS_PER_SEC);
//fprintf(stderr, "sleep for 5s...\n");
//usleep(5 * 1000 * 1000);
}
clock_t loop_end = std::clock();
double loop_time = double(loop_end - loop_start) / double(CLOCKS_PER_SEC);
Expand Down Expand Up @@ -536,6 +535,19 @@ int main(int argc, char *argv[])
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s" << endl;

#ifdef GPUSolverNew_
#ifdef SHOW_MEMINFO
int rank = -1;
if (mpi_init_flag) {
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
}
if (!mpi_init_flag || rank == 0) {
fprintf(stderr, "show memory info...\n");
//usleep(1 * 1000 * 1000);
system("nvidia-smi");
}
#endif
#endif
time_monitor_other = 0;
time_monitor_rho = 0;
time_monitor_U = 0;
Expand Down Expand Up @@ -622,6 +634,7 @@ int main(int argc, char *argv[])
UEqn_GPU.cleanCudaResources();
rhoEqn_GPU.cleanCudaResources();
thermo_GPU.cleanCudaResources();
dfDataBase.resetAmgxSolvers();
dfDataBase.cleanCudaResources();
#endif

Expand Down
2 changes: 1 addition & 1 deletion src_gpu/AmgXSolver.cu
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void AmgXSolver::solve(
getIters(nIters);
getResidual(nIters, rnorm);
if (!isMPIEnabled || myRank == 0)
printf("Initial residual = %.10lf, Final residual = %.5e, No Iterations %d\n", irnorm, rnorm, nIters);
fprintf(stderr, "Initial residual = %.10lf, Final residual = %.5e, No Iterations %d\n", irnorm, rnorm, nIters);

}

Expand Down
1 change: 1 addition & 0 deletions src_gpu/dfMatrixDataBase.H
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ struct dfMatrixDataBase
void setConstantIndexes(const int *owner, const int *neighbor, const int *procRows,
const int *procCols, int globalOffset);
void setAmgxSolvers(const std::string &mode_string, const std::string &u_setting_path, const std::string &p_setting_path);
void resetAmgxSolvers();
void solve(int num_iteration, AMGXSetting setting, double *d_A, double *d_x, double *d_b);
void setCyclicInfo(std::vector<int> &cyclicNeighbor); // when use cyclic boundary

Expand Down
11 changes: 11 additions & 0 deletions src_gpu/dfMatrixDataBase.cu
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ void dfMatrixDataBase::setAmgxSolvers(const std::string &mode_string, const std:
u_setting_solver = new AmgXSolver(mode_string, u_setting_path, localRank);
p_setting_solver = new AmgXSolver(mode_string, p_setting_path, localRank);
}

void dfMatrixDataBase::resetAmgxSolvers() {
if (u_setting_solver) {
delete u_setting_solver;
u_setting_solver = nullptr;
}
if (p_setting_solver) {
delete p_setting_solver;
p_setting_solver = nullptr;
}
}

void dfMatrixDataBase::solve(int num_iteration, AMGXSetting setting, double *d_A, double *d_x, double *d_b) {
AmgXSolver *solver = (setting == AMGXSetting::u_setting) ? u_setting_solver : p_setting_solver;
Expand Down