Skip to content
Open
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
40 changes: 40 additions & 0 deletions src/t8_forest/t8_forest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3799,6 +3799,10 @@ t8_forest_compute_profile (t8_forest_t forest)
sc_stats_set1 (&forest->stats[14], profile->balance_rounds, "forest: Tree offset runtime.");
sc_stats_set1 (&forest->stats[15], profile->balance_rounds, "forest: offset runtime.");
sc_stats_set1 (&forest->stats[16], profile->balance_rounds, "forest: first descendant runtime.");
sc_stats_set1 (&forest->stats[17], profile->balance_rounds, "forest: search check element runtime.");
sc_stats_set1 (&forest->stats[18], profile->balance_rounds, "forest: search check queries runtime.");
sc_stats_set1 (&forest->stats[19], profile->balance_rounds, "forest: search split_array runtime.");
sc_stats_set1 (&forest->stats[20], profile->balance_rounds, "forest: search total runtime.");
/* compute stats */
sc_stats_compute (sc_MPI_COMM_WORLD, T8_PROFILE_NUM_STATS, forest->stats);
forest->stats_computed = 1;
Expand Down Expand Up @@ -3968,6 +3972,42 @@ t8_forest_profile_get_first_descendant_runtime (t8_forest_t forest)
}
return 0;
}
double
t8_forest_profile_get_search_check_element_runtime (t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));
if (forest->profile != NULL) {
return forest->profile->search_check_element_time;
}
return 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

double
t8_forest_profile_search_check_query_runtime (t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));
if (forest->profile != NULL) {
return forest->profile->search_check_query_time;
}
return 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

double
t8_forest_profile_search_split_array_runtime (t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));
if (forest->profile != NULL) {
return forest->profile->search_split_array_time;
}
return 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

double
t8_forest_profile_search_total_runtime (t8_forest_t forest)
{
T8_ASSERT (t8_forest_is_committed (forest));
if (forest->profile != NULL) {
return forest->profile->search_time;
}
return 0;
}

void
t8_forest_compute_elements_offset (t8_forest_t forest)
Expand Down
42 changes: 42 additions & 0 deletions src/t8_forest/t8_forest_profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,48 @@ t8_forest_profile_get_forest_offsets_runtime (t8_forest_t forest);
*/
double
t8_forest_profile_get_first_descendant_runtime (t8_forest_t forest);

/** Get the sum of the runtimes of the last calls to \ref check_element in search.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All comments do not match the actual function. Please re-edit them.

* \param [in] forest The forest.
* \return The time
* \a forest must be committed before calling this function.
* \see t8_forest_set_profiling
*/
double
t8_forest_profile_get_search_check_element_runtime (t8_forest_t forest);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t8_forest_profile_get_search_check_element_runtime (t8_forest_t forest);
t8_forest_profile_get_search_check_element_runtime (t8_forest_t forest);

/** Get the sum of the runtimes of the last calls to \ref check_element in search.
* \param [in] forest The forest.
* \return The time
* \a forest must be committed before calling this function.
* \see t8_forest_set_profiling
*/
double
t8_forest_profile_get_search_check_query_runtime (t8_forest_t forest);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t8_forest_profile_get_search_check_query_runtime (t8_forest_t forest);
t8_forest_profile_get_search_check_query_runtime (t8_forest_t forest);

/** Get the sum of the runtimes of the last calls to \ref check_query in search.
* \param [in] forest The forest.
* \return The time
* \a forest must be committed before calling this function.
* \see t8_forest_set_profiling
*/
double
t8_forest_profile_get_search_split_array_runtime (t8_forest_t forest);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t8_forest_profile_get_search_split_array_runtime (t8_forest_t forest);
t8_forest_profile_get_search_split_array_runtime (t8_forest_t forest);

/** Get the sum of the runtimes of the last calls to \ref split_array in search.
* \param [in] forest The forest.
* \return The time
* \a forest must be committed before calling this function.
* \see t8_forest_set_profiling
*/
double
t8_forest_profile_get_search_check_element_runtime (t8_forest_t forest);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t8_forest_profile_get_search_check_element_runtime (t8_forest_t forest);
t8_forest_profile_get_search_check_element_runtime (t8_forest_t forest);

/** Get the runtime of the last call to \ref search.
* \param [in] forest The forest.
* \return The time
* \a forest must be committed before calling this function.
* \see t8_forest_set_profiling
*/
double
t8_forest_profile_get_search_total_runtime (t8_forest_t forest);

T8_EXTERN_C_END ();

#endif /* !T8_FOREST_PROFILING_H */
38 changes: 37 additions & 1 deletion src/t8_forest/t8_forest_search/t8_forest_search.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,39 @@ t8_search_base::search_recursion (const t8_locidx_t ltreeid, t8_element_t *eleme
}
}
/* Call the callback function for the element */
if (forest->profile != NULL) {
/* If profiling is enabled, we measure the runtime of partition */
forest->profile->search_check_element_time -= sc_MPI_Wtime ();
}
const bool ret = check_element (ltreeid, element, is_leaf, leaf_elements, tree_lindex_of_first_leaf);
if (forest->profile != NULL) {
/* If profiling is enabled, we measure the runtime of partition */
forest->profile->search_check_element_time += sc_MPI_Wtime ();
}

if (!ret) {
/* The function returned false. We abort the recursion */
return;
}
std::vector<size_t> new_active_queries;
if (forest->profile != NULL) {
/* If profiling is enabled, we measure the runtime of partition */
forest->profile->search_check_query_time -= sc_MPI_Wtime ();
}
this->check_queries (new_active_queries, ltreeid, element, is_leaf, leaf_elements, tree_lindex_of_first_leaf);

if (forest->profile != NULL) {
/* If profiling is enabled, we measure the runtime of partition */
forest->profile->search_check_query_time += sc_MPI_Wtime ();
}
if (is_leaf) {
return;
}

if (forest->profile != NULL) {
/* If profiling is enabled, we measure the runtime of partition */
forest->profile->search_split_array_time -= sc_MPI_Wtime ();
}

/* Enter the recursion (the element is definitely not a leaf at this point) */
/* We compute all children of E, compute their leaf arrays and call search_recursion */
/* allocate the memory to store the children */
Expand All @@ -89,6 +109,11 @@ t8_search_base::search_recursion (const t8_locidx_t ltreeid, t8_element_t *eleme
ts->element_get_children (eclass, element, num_children, children);
/* Split the leaves array in portions belonging to the children of element */
t8_forest_split_array (element, leaf_elements, split_offsets);
if (forest->profile != NULL) {
/* If profiling is enabled, we measure the runtime of partition */
forest->profile->search_split_array_time += sc_MPI_Wtime ();
}

for (int ichild = 0; ichild < num_children; ichild++) {
/* Check if there are any leaf elements for this child */
const size_t indexa = split_offsets[ichild]; /* first leaf of this child */
Expand Down Expand Up @@ -135,12 +160,23 @@ t8_search_base::search_tree (const t8_locidx_t ltreeid)
void
t8_search_base::do_search ()
{
if (forest->profile != NULL) {
/* If profiling is enabled, we measure the runtime of partition */
forest->profile->search_time = -sc_MPI_Wtime ();
forest->profile->search_check_element_time = 0;
forest->profile->search_check_query_time = 0;
forest->profile->search_split_array_time = 0;
}
T8_ASSERT (t8_forest_is_committed (forest));
const t8_locidx_t num_local_trees = t8_forest_get_num_local_trees (this->forest);
for (t8_locidx_t itree = 0; itree < num_local_trees; itree++) {
this->init_queries ();
this->search_tree (itree);
}
if (forest->profile != NULL) {
/* If profiling is enabled, we measure the runtime of partition */
forest->profile->search_time += sc_MPI_Wtime ();
}
}

/* #################### t8_forest_search c interface #################### */
Expand Down
7 changes: 5 additions & 2 deletions src/t8_forest/t8_forest_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ typedef int8_t t8_forest_from_t;
#define T8_FOREST_BALANCE_NO_REPART 2 /**< Value of forest->set_balance if balancing without repartitioning */

/** The number of statistics collected by a profile struct. */
#define T8_PROFILE_NUM_STATS 17
#define T8_PROFILE_NUM_STATS 21

/** This structure is private to the implementation. */
typedef struct t8_forest
Expand Down Expand Up @@ -187,7 +187,10 @@ typedef struct t8_profile
double cmesh_offsets_runtime; /**< The runtime of the last call to \a t8_forest_partition_create_tree_offsets. */
double forest_offsets_runtime; /**< The runtime of the last call to \a t8_forest_partition_create_offsets. */
double first_descendant_runtime; /**< The runtime of the last call to \a t8_forest_partition_create_first_desc. */

double search_time;
double search_check_element_time;
double search_check_query_time;
double search_split_array_time;
} t8_profile_struct_t;

/**
Expand Down