@@ -64,19 +64,40 @@ t8_search_base::search_recursion (const t8_locidx_t ltreeid, t8_element_t *eleme
6464 }
6565 }
6666 /* Call the callback function for the element */
67+ if (forest->profile != NULL ) {
68+ /* If profiling is enabled, we measure the runtime of partition */
69+ forest->profile ->search_check_element_time -= sc_MPI_Wtime ();
70+ }
6771 const bool ret = check_element (ltreeid, element, is_leaf, leaf_elements, tree_lindex_of_first_leaf);
72+ if (forest->profile != NULL ) {
73+ /* If profiling is enabled, we measure the runtime of partition */
74+ forest->profile ->search_check_element_time += sc_MPI_Wtime ();
75+ }
6876
6977 if (!ret) {
7078 /* The function returned false. We abort the recursion */
7179 return ;
7280 }
7381 std::vector<size_t > new_active_queries;
82+ if (forest->profile != NULL ) {
83+ /* If profiling is enabled, we measure the runtime of partition */
84+ forest->profile ->search_check_query_time -= sc_MPI_Wtime ();
85+ }
7486 this ->check_queries (new_active_queries, ltreeid, element, is_leaf, leaf_elements, tree_lindex_of_first_leaf);
75-
87+ if (forest->profile != NULL ) {
88+ /* If profiling is enabled, we measure the runtime of partition */
89+ forest->profile ->search_check_query_time += sc_MPI_Wtime ();
90+ }
7691 if (is_leaf) {
7792 return ;
7893 }
7994
95+
96+ if (forest->profile != NULL ) {
97+ /* If profiling is enabled, we measure the runtime of partition */
98+ forest->profile ->search_split_array_time -= sc_MPI_Wtime ();
99+ }
100+
80101 /* Enter the recursion (the element is definitely not a leaf at this point) */
81102 /* We compute all children of E, compute their leaf arrays and call search_recursion */
82103 /* allocate the memory to store the children */
@@ -89,6 +110,11 @@ t8_search_base::search_recursion (const t8_locidx_t ltreeid, t8_element_t *eleme
89110 ts->element_get_children (eclass, element, num_children, children);
90111 /* Split the leaves array in portions belonging to the children of element */
91112 t8_forest_split_array (element, leaf_elements, split_offsets);
113+ if (forest->profile != NULL ) {
114+ /* If profiling is enabled, we measure the runtime of partition */
115+ forest->profile ->search_split_array_time += sc_MPI_Wtime ();
116+ }
117+
92118 for (int ichild = 0 ; ichild < num_children; ichild++) {
93119 /* Check if there are any leaf elements for this child */
94120 const size_t indexa = split_offsets[ichild]; /* first leaf of this child */
@@ -135,12 +161,23 @@ t8_search_base::search_tree (const t8_locidx_t ltreeid)
135161void
136162t8_search_base::do_search ()
137163{
164+ if (forest->profile != NULL ) {
165+ /* If profiling is enabled, we measure the runtime of partition */
166+ forest->profile ->search_time = -sc_MPI_Wtime ();
167+ forest->profile ->search_check_element_time = 0 ;
168+ forest->profile ->search_check_query_time = 0 ;
169+ forest->profile ->search_split_array_time = 0 ;
170+ }
138171 T8_ASSERT (t8_forest_is_committed (forest));
139172 const t8_locidx_t num_local_trees = t8_forest_get_num_local_trees (this ->forest );
140173 for (t8_locidx_t itree = 0 ; itree < num_local_trees; itree++) {
141174 this ->init_queries ();
142175 this ->search_tree (itree);
143176 }
177+ if (forest->profile != NULL ) {
178+ /* If profiling is enabled, we measure the runtime of partition */
179+ forest->profile ->search_time += sc_MPI_Wtime ();
180+ }
144181}
145182
146183/* #################### t8_forest_search c interface #################### */
0 commit comments