Skip to content

Commit d360380

Browse files
Merge pull request #1904 from DLR-AMR/enhancement-bigarray_timing
Add timing of big arrays in forest
2 parents 8d06ad1 + 4702303 commit d360380

File tree

4 files changed

+94
-10
lines changed

4 files changed

+94
-10
lines changed

src/t8_forest/t8_forest.cxx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,6 +3796,9 @@ t8_forest_compute_profile (t8_forest_t forest)
37963796
sc_stats_set1 (&forest->stats[11], profile->ghost_waittime, "forest: Ghost waittime.");
37973797
sc_stats_set1 (&forest->stats[12], profile->balance_runtime, "forest: Balance runtime.");
37983798
sc_stats_set1 (&forest->stats[13], profile->balance_rounds, "forest: Balance rounds.");
3799+
sc_stats_set1 (&forest->stats[14], profile->balance_rounds, "forest: Tree offset runtime.");
3800+
sc_stats_set1 (&forest->stats[15], profile->balance_rounds, "forest: offset runtime.");
3801+
sc_stats_set1 (&forest->stats[16], profile->balance_rounds, "forest: first descendant runtime.");
37993802
/* compute stats */
38003803
sc_stats_compute (sc_MPI_COMM_WORLD, T8_PROFILE_NUM_STATS, forest->stats);
38013804
forest->stats_computed = 1;
@@ -3936,6 +3939,35 @@ t8_forest_profile_get_balance (t8_forest_t forest, int *balance_rounds)
39363939
}
39373940
return 0;
39383941
}
3942+
double
3943+
t8_forest_profile_get_cmesh_offset_runtime (t8_forest_t forest)
3944+
{
3945+
T8_ASSERT (t8_forest_is_committed (forest));
3946+
if (forest->profile != NULL) {
3947+
return forest->profile->cmesh_offsets_runtime;
3948+
}
3949+
return 0;
3950+
}
3951+
3952+
double
3953+
t8_forest_profile_get_forest_offset_runtime (t8_forest_t forest)
3954+
{
3955+
T8_ASSERT (t8_forest_is_committed (forest));
3956+
if (forest->profile != NULL) {
3957+
return forest->profile->forest_offsets_runtime;
3958+
}
3959+
return 0;
3960+
}
3961+
3962+
double
3963+
t8_forest_profile_get_first_descendant_runtime (t8_forest_t forest)
3964+
{
3965+
T8_ASSERT (t8_forest_is_committed (forest));
3966+
if (forest->profile != NULL) {
3967+
return forest->profile->first_descendant_runtime;
3968+
}
3969+
return 0;
3970+
}
39393971

39403972
void
39413973
t8_forest_compute_elements_offset (t8_forest_t forest)

src/t8_forest/t8_forest_partition.cxx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ t8_forest_compute_first_local_element_id (t8_forest_t forest)
9090
void
9191
t8_forest_partition_create_offsets (t8_forest_t forest)
9292
{
93+
if (forest->profile != NULL) {
94+
/* If profiling is enabled, we measure the runtime of partition */
95+
forest->profile->forest_offsets_runtime = -sc_MPI_Wtime ();
96+
}
97+
9398
sc_MPI_Comm comm;
9499
t8_gloidx_t first_local_element;
95100

@@ -113,6 +118,10 @@ t8_forest_partition_create_offsets (t8_forest_t forest)
113118
t8_shmem_array_set_gloidx (forest->element_offsets, forest->mpisize, forest->global_num_leaf_elements);
114119
}
115120
t8_shmem_array_end_writing (forest->element_offsets);
121+
if (forest->profile != NULL) {
122+
/* If profiling is enabled, we measure the runtime of partition */
123+
forest->profile->forest_offsets_runtime += sc_MPI_Wtime ();
124+
}
116125
}
117126

118127
#if T8_ENABLE_DEBUG
@@ -255,6 +264,10 @@ t8_forest_partition_test_boundary_element ([[maybe_unused]] const t8_forest_t fo
255264
void
256265
t8_forest_partition_create_first_desc (t8_forest_t forest)
257266
{
267+
if (forest->profile != NULL) {
268+
/* If profiling is enabled, we measure the runtime of partition */
269+
forest->profile->first_descendant_runtime = -sc_MPI_Wtime ();
270+
}
258271
sc_MPI_Comm comm;
259272
t8_linearidx_t local_first_desc;
260273
t8_element_t *first_desc = NULL;
@@ -333,11 +346,21 @@ t8_forest_partition_create_first_desc (t8_forest_t forest)
333346
}
334347
t8_forest_partition_test_desc (forest);
335348
#endif
349+
if (forest->profile != NULL) {
350+
/* If profiling is enabled, we measure the runtime of partition */
351+
forest->profile->first_descendant_runtime += sc_MPI_Wtime ();
352+
}
336353
}
337354

338355
void
339356
t8_forest_partition_create_tree_offsets (t8_forest_t forest)
340357
{
358+
359+
if (forest->profile != NULL) {
360+
/* If profiling is enabled, we measure the runtime of partition */
361+
forest->profile->cmesh_offsets_runtime = -sc_MPI_Wtime ();
362+
}
363+
341364
t8_gloidx_t tree_offset;
342365
sc_MPI_Comm comm;
343366
int is_empty, has_empty;
@@ -401,6 +424,10 @@ t8_forest_partition_create_tree_offsets (t8_forest_t forest)
401424
/* Communicate the new tree offsets */
402425
t8_shmem_array_allgather (&tree_offset, 1, T8_MPI_GLOIDX, forest->tree_offsets, 1, T8_MPI_GLOIDX);
403426
}
427+
if (forest->profile != NULL) {
428+
/* If profiling is enabled, we measure the runtime of partition */
429+
forest->profile->cmesh_offsets_runtime += sc_MPI_Wtime ();
430+
}
404431
}
405432

406433
/* Calculate the new element_offset for forest from

src/t8_forest/t8_forest_profiling.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,31 @@ t8_forest_profile_get_ghost_time (t8_forest_t forest, t8_locidx_t *ghosts_sent);
185185
*/
186186
double
187187
t8_forest_profile_get_ghostexchange_waittime (t8_forest_t forest);
188+
189+
/** Get the runtime of the last call to \ref t8_forest_partition_create_tree_offsets.
190+
* \param [in] forest The forest.
191+
* \return The time
192+
* \a forest must be committed before calling this function.
193+
* \see t8_forest_set_profiling
194+
*/
195+
double
196+
t8_forest_profile_get_cmesh_offsets_runtime (t8_forest_t forest);
197+
/** Get the runtime of the last call to \ref t8_forest_partition_create_offsets.
198+
* \param [in] forest The forest.
199+
* \return The time
200+
* \a forest must be committed before calling this function.
201+
* \see t8_forest_set_profiling
202+
*/
203+
double
204+
t8_forest_profile_get_forest_offsets_runtime (t8_forest_t forest);
205+
/** Get the waittime of the last call to \ref t8_forest_partition_create_first_desc.
206+
* \param [in] forest The forest.
207+
* \return The time
208+
* \a forest must be committed before calling this function.
209+
* \see t8_forest_set_profiling
210+
*/
211+
double
212+
t8_forest_profile_get_first_descendant_runtime (t8_forest_t forest);
188213
T8_EXTERN_C_END ();
189214

190215
#endif /* !T8_FOREST_PROFILING_H */

src/t8_forest/t8_forest_types.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ typedef int8_t t8_forest_from_t;
6262
#define T8_FOREST_BALANCE_NO_REPART 2 /**< Value of forest->set_balance if balancing without repartitioning */
6363

6464
/** The number of statistics collected by a profile struct. */
65-
#define T8_PROFILE_NUM_STATS 14
65+
#define T8_PROFILE_NUM_STATS 17
6666

6767
/** This structure is private to the implementation. */
6868
typedef struct t8_forest
@@ -157,9 +157,6 @@ typedef struct t8_tree
157157
* \see t8_cmesh_set_profiling and \see t8_cmesh_print_profile
158158
*/
159159

160-
/** The number of statistics collected by a profile struct. */
161-
#define T8_PROFILE_NUM_STATS 14
162-
163160
/**
164161
* This struct holds profiling information, such as timings or statistics about communication.
165162
*/
@@ -179,14 +176,17 @@ typedef struct t8_profile
179176
int ghosts_remotes; /**< The number of processes this process have sent ghost elements to
180177
(and received from). */
181178
int balance_rounds; /**< The number of iterations during balance. */
182-
double adapt_runtime; /**< The runtime of the last call to \a t8_forest_adapt (not counting adaptation
179+
double adapt_runtime; /**< The runtime of the last call to \a t8_forest_adapt (not counting adaptation
183180
in t8_forest_balance). */
184-
double partition_runtime; /**< The runtime of the last call to \a t8_cmesh_partition (not count in
181+
double partition_runtime; /**< The runtime of the last call to \a t8_cmesh_partition (not count in
185182
partition in t8_forest_balance). */
186-
double ghost_runtime; /**< The runtime of the last call to \a t8_forest_ghost_create. */
187-
double ghost_waittime; /**< Amount of synchronisation time in ghost. */
188-
double balance_runtime; /**< The runtime of the last call to \a t8_forest_balance. */
189-
double commit_runtime; /**< The runtime of the last call to \a t8_cmesh_commit. */
183+
double ghost_runtime; /**< The runtime of the last call to \a t8_forest_ghost_create. */
184+
double ghost_waittime; /**< Amount of synchronisation time in ghost. */
185+
double balance_runtime; /**< The runtime of the last call to \a t8_forest_balance. */
186+
double commit_runtime; /**< The runtime of the last call to \a t8_cmesh_commit. */
187+
double cmesh_offsets_runtime; /**< The runtime of the last call to \a t8_forest_partition_create_tree_offsets. */
188+
double forest_offsets_runtime; /**< The runtime of the last call to \a t8_forest_partition_create_offsets. */
189+
double first_descendant_runtime; /**< The runtime of the last call to \a t8_forest_partition_create_first_desc. */
190190

191191
} t8_profile_struct_t;
192192

0 commit comments

Comments
 (0)