Commit be56b7c0 authored by Morales Hernandez, Mario's avatar Morales Hernandez, Mario
Browse files

Add TRITON-SWMM coupling timer to timing framework

This commit adds a new timer specifically for TRITON-SWMM coupling
operations, following the existing timer implementation pattern.

Changes:
- Added SWMM_TIME constant definition in src/constants.h
- Added timer start/stop around SWMM coupling computation in src/triton.h
 - Timer stops COMPUTE_TIME before starting SWMM_TIME (mutually exclusive)
 - Timer restarts COMPUTE_TIME after SWMM_TIME stops
- Updated write_times() in src/output.h to include SWMM_TIME reporting
 - Added swmm_time calculation and MPI gather
 - Updated other_time formula to subtract swmm_time
 - Updated output CSV header to include SWMM column

Timer hierarchy verification:
- SWMM_TIME is mutually exclusive with COMPUTE_TIME
- Sum of all component timers equals SIMULATION_TIME
- other_time = simulation_time - (compute + mpi + io + resize + swmm)

Performance output format (new SWMM column):
%Rank, Compute, MPI, IO, Resize, SWMM, Other, Simulation, Init, Total
parent 02438b60
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ typedef double value_t; /**< Data type to represent floating-point number. It
#define IO_TIME "io_time"    /**< Timer to get time needed for outputting in file. */
#define RESIZE_TIME "resize_time"    /**< Timer to get time needed for resizing and re-balancing */
#define BALANCING_MPI_TIME "balancing_mpi_time"    /**< Timer to get time needed for resizing and re-balancing */
#define SWMM_TIME "swmm_time"    /**< Timer to get time needed for TRITON-SWMM coupling operations */


#define TYPE_STATIC "static"    /**< Domain decomposition type: static*/
+8 −5
Original line number Diff line number Diff line
@@ -1466,9 +1466,10 @@ namespace Output
		T mpi_time = st.get_custom_time(MPI_TIME);
		T io_time = st.get_custom_time(IO_TIME);
		T resize_time = st.get_custom_time(RESIZE_TIME);
		T swmm_time = st.get_custom_time(SWMM_TIME);
		T simulation_time = st.get_custom_time(SIMULATION_TIME);
		T total_time = st.get_custom_time(TOTAL_TIME);
		T other_time = simulation_time - compute_time - mpi_time - io_time - resize_time;
		T other_time = simulation_time - compute_time - mpi_time - io_time - resize_time - swmm_time;
		T init_time = total_time - simulation_time;

		T *compute_time_all = new T[size_];
@@ -1479,6 +1480,7 @@ namespace Output
		T *other_time_all = new T[size_];
		T *init_time_all = new T[size_];
		T *resize_time_all = new T[size_];
		T *swmm_time_all = new T[size_];


		MPI_Gather(&compute_time, 1, MPI_DATA_TYPE, &compute_time_all[rank_], 1, MPI_DATA_TYPE, 0, ENSIFY_COMM_WORLD);
@@ -1489,6 +1491,7 @@ namespace Output
		MPI_Gather(&other_time, 1, MPI_DATA_TYPE, &other_time_all[rank_], 1, MPI_DATA_TYPE, 0, ENSIFY_COMM_WORLD);
		MPI_Gather(&init_time, 1, MPI_DATA_TYPE, &init_time_all[rank_], 1, MPI_DATA_TYPE, 0, ENSIFY_COMM_WORLD);
		MPI_Gather(&resize_time, 1, MPI_DATA_TYPE, &resize_time_all[rank_], 1, MPI_DATA_TYPE, 0, ENSIFY_COMM_WORLD);
		MPI_Gather(&swmm_time, 1, MPI_DATA_TYPE, &swmm_time_all[rank_], 1, MPI_DATA_TYPE, 0, ENSIFY_COMM_WORLD);

		if (size_ > 1)
		{
@@ -1527,13 +1530,13 @@ namespace Output
				filedir = outdir + "performance.txt";	
			}
			std::ofstream output(filedir);
			output << "%Rank, Compute, MPI, IO, Resize, Other, Simulation, Init, Total" << std::endl;
			output << "%Rank, Compute, MPI, IO, Resize, SWMM, Other, Simulation, Init, Total" << std::endl;
			
			for(int j=0;j<size_;j++){
				output << std::setprecision(4) << j << ", " << compute_time_all[j] << ", " <<  mpi_time_all[j] << ", " <<	io_time_all[j] << ", " <<	resize_time_all[j] << ", " << other_time_all[j] << ", " 
				output << std::setprecision(4) << j << ", " << compute_time_all[j] << ", " <<  mpi_time_all[j] << ", " <<	io_time_all[j] << ", " <<	resize_time_all[j] << ", " << swmm_time_all[j] << ", " << other_time_all[j] << ", "
				<< simulation_time_all[j] << ", " << init_time_all[j] <<  ", " << total_time_all[j] << std::endl;
			}
			output << std::setprecision(4) << "Average" << ", " << average(compute_time_all,size_) << ", " <<  average(mpi_time_all,size_) << ", " <<	 average(io_time_all,size_) << ", " << average(resize_time_all,size_) << ", " <<  average(other_time_all,size_) << ", " <<  average(simulation_time_all,size_) << ", " <<  average(init_time_all,size_) <<  ", " << average(total_time_all,size_) << std::endl;
			output << std::setprecision(4) << "Average" << ", " << average(compute_time_all,size_) << ", " <<  average(mpi_time_all,size_) << ", " <<	 average(io_time_all,size_) << ", " << average(resize_time_all,size_) << ", " << average(swmm_time_all,size_) << ", " <<  average(other_time_all,size_) << ", " <<  average(simulation_time_all,size_) << ", " <<  average(init_time_all,size_) <<  ", " << average(total_time_all,size_) << std::endl;

			output.close();
		}
+4 −0
Original line number Diff line number Diff line
@@ -2330,6 +2330,8 @@ namespace Triton
#ifdef TRITON_SWMM
    // SWMM-TRITON coupling
    if (swmm_model.num_of_swmm_links > 0) {
      st.stop(COMPUTE_TIME);
      st.start(SWMM_TIME);
      int nbytes_swmm = (sizeof(T) * swmm_model.num_of_swmm_links);
      int nbytes_swmm_int = (sizeof(int) * swmm_model.num_of_swmm_links);

@@ -2366,6 +2368,8 @@ namespace Triton
      MPI_Scatterv(swmm_model.aux_global_new_depth, swmm_model.counts, swmm_model.displs,
                   MPI_DATA_TYPE, host_vec[SWMM_NEWD], swmm_model.num_of_swmm_links,
                   MPI_DATA_TYPE, 0, ENSIFY_COMM_WORLD);
      st.stop(SWMM_TIME);
      st.start(COMPUTE_TIME);
    }
#endif