Skip to content

Commit

Permalink
merge gpu main
Browse files Browse the repository at this point in the history
  • Loading branch information
cguzman95 committed Dec 15, 2023
1 parent 7e2d577 commit 40f44b9
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/camp_solver.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void *solver_new(int n_state_var, int n_cells, int *var_type, int n_rxn,
int n_sub_model, int n_sub_model_int_param,
int n_sub_model_float_param, int n_sub_model_env_param,
int use_cpu) {
// Create the SolverData object

// Create the SolverData object
SolverData *sd = (SolverData *)malloc(sizeof(SolverData));
if (sd == NULL) {
printf("\n\nERROR allocating space for SolverData\n\n");
Expand Down
5 changes: 3 additions & 2 deletions src/cuda/cvode_init.cu
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ void constructor_cvode_gpu(SolverData *sd){
MPI_INFO_NULL, &commNode);
MPI_Comm_rank(commNode, &rankNode);
MPI_Comm_size(commNode, &sizeNode);
int MPIsPerGPU = sizeNode / nGPUsMax;
cudaSetDevice(rankNode / MPIsPerGPU);
int MPIsPerGPU = (sizeNode + nGPUsMax - 1) / nGPUsMax;
int iDevice = rankNode / MPIsPerGPU;
cudaSetDevice(iDevice);
mGPU->n_rxn=md->n_rxn;
mGPU->n_rxn_env_data=md->n_rxn_env_data;
HANDLE_ERROR(cudaMalloc((void **) &mGPU->state, state_size));
Expand Down
12 changes: 6 additions & 6 deletions test/monarch/TestMonarch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def all_timesteps():
conf.profileCuda = ""
# conf.profileCuda = "nvprof"
# conf.profileCuda = "nsight"
conf.is_import = True
conf.mpiProcessesCaseBase = 40
conf.mpiProcessesCaseOptimList = [40]
conf.cells = [100000]
conf.timeSteps = 720
#conf.is_import = True
conf.mpiProcessesCaseBase = 10
conf.mpiProcessesCaseOptimList = [1,2,3,4]
conf.cells = [10000]
conf.timeSteps = 1
conf.caseBase = "CPU One-cell"
# conf.caseBase = "GPU BDF"
#conf.caseBase = "GPU BDF"
conf.casesOptim = []
# conf.casesOptim.append("CPU One-cell")
conf.casesOptim.append("GPU BDF")
Expand Down
2 changes: 1 addition & 1 deletion test/monarch/TestMonarch2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def all_timesteps():
conf.is_import = True
conf.mpiProcessesCaseBase = 20
conf.mpiProcessesCaseOptimList = [20]
conf.cells = [10000]
conf.cells = [100000]
conf.timeSteps = 720
conf.caseBase = "CPU One-cell"
# conf.caseBase = "GPU BDF"
Expand Down
4 changes: 2 additions & 2 deletions test/monarch/TestMonarch4.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def all_timesteps():
# conf.profileCuda = "nsight"
conf.is_import = True
conf.mpiProcessesCaseBase = 1
conf.mpiProcessesCaseOptimList = [10,20,30,40]
conf.cells = [10000]
conf.mpiProcessesCaseOptimList = [1,2,3,4]
conf.cells = [100000]
conf.timeSteps = 720
conf.caseBase = "CPU One-cell"
# conf.caseBase = "GPU BDF"
Expand Down
23 changes: 12 additions & 11 deletions test/monarch/camp_monarch_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ module camp_monarch_interface
contains
procedure :: integrate
procedure :: get_init_conc
procedure :: finalize
procedure, private :: load
procedure, private :: create_map
procedure, private :: load_init_conc
final :: finalize
end type camp_monarch_interface_t

interface camp_monarch_interface_t
Expand Down Expand Up @@ -808,8 +808,8 @@ subroutine get_init_conc(this, MONARCH_conc, water_conc, &
end if
end subroutine get_init_conc

elemental subroutine finalize(this)
type(camp_monarch_interface_t), intent(inout) :: this
subroutine finalize(this)
class(camp_monarch_interface_t) :: this
if (associated(this%camp_core)) &
deallocate(this%camp_core)
if (associated(this%camp_state)) &
Expand All @@ -824,13 +824,14 @@ elemental subroutine finalize(this)
deallocate(this%init_conc_camp_id)
if (allocated(this%init_conc)) &
deallocate(this%init_conc)
if (associated(this%species_map_data)) &
deallocate(this%species_map_data)
if (associated(this%init_conc_data)) &
deallocate(this%init_conc_data)
if (associated(this%property_set)) &
deallocate(this%property_set)

end subroutine finalize
if(camp_mpi_rank()==0) then
if (associated(this%init_conc_data)) &
deallocate(this%init_conc_data)
if (associated(this%species_map_data)) &
deallocate(this%species_map_data)
if (associated(this%property_set)) &
deallocate(this%property_set)
end if
end subroutine

end module
4 changes: 2 additions & 2 deletions test/monarch/mainMonarch.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def run(conf):
exec_str += 'ddt --connect '
except Exception:
pass
maxCoresPerNode = 40
maxCoresPerNode = 40 #CTE-POWER Architecture
if conf.mpiProcesses <= maxCoresPerNode:
exec_str += "mpirun -v -np " + str(
conf.mpiProcesses) + " --bind-to core " #for plogin (fails squeue)
else:
exec_str += "srun --cpu-bind=core -n " + str(
conf.mpiProcesses) + " " #foqueue (slow plogin)
conf.mpiProcesses) + " " #for queue (slow plogin)
if (conf.profileCuda == "nvprof" and conf.caseGpuCpu ==
"GPU"):
pathNvprof = ("../../compile/power9/" +
Expand Down
1 change: 1 addition & 0 deletions test/monarch/mock_monarch.F90
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ program mock_monarch_t
deallocate(camp_input_file)
deallocate(output_path)
deallocate(output_file_title)
call camp_interface%finalize()
deallocate(camp_interface)
call camp_mpi_finalize()

Expand Down
4 changes: 2 additions & 2 deletions test/monarch/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ make_run() {
cd ../../build
make -j 4
cd $curr_path
#python TestMonarch.py
python checkGPU.py
python TestMonarch4.py
#python checkGPU.py
}

make_run
Expand Down
2 changes: 0 additions & 2 deletions test/monarch/sbatch_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ make_run(){
cd ../../build
make -j 4
cd $curr_path
python TestMonarch1.py
python TestMonarch2.py
python TestMonarch3.py
python TestMonarch4.py
}
time make_run

0 comments on commit 40f44b9

Please sign in to comment.