1717 License along with this library. If not, see <http://www.gnu.org/licenses/>.
1818
1919*/
20-
21-
22- #include " mpi.h"
2320#include < iostream>
2421#include < iomanip>
2522#include < string>
2623#include < vector>
24+ #include " mpi.h"
25+ #include " omp.h"
2726#include " phiprof.hpp"
2827
2928using namespace std ;
@@ -58,9 +57,11 @@ int main(int argc,char **argv){
5857 const int nIterations=1000000 ;
5958 if (rank==0 )
6059 cout << " Measuring performance of start-stop calls" <<endl;
61-
6260
63- phiprof::start (" Benchmarking phiprofr" );
61+ phiprof::initialize ();
62+
63+ phiprof::start (" Benchmarking phiprof" );
64+
6465 phiprof::start (" Initalized timers using ID" );
6566
6667 if (rank==0 )
@@ -74,6 +75,7 @@ int main(int argc,char **argv){
7475
7576 if (rank==0 )
7677 cout << " 2/3" <<endl;
78+
7779 phiprof::start (" Re-initialized timers using ID" );
7880 for (int i=0 ;i<nIterations;i++){
7981 id_a=phiprof::initializeTimer (" a" ," A with ID" );
@@ -89,44 +91,68 @@ int main(int argc,char **argv){
8991 phiprof::start (" a" );
9092 phiprof::stop (" a" );
9193 }
92- phiprof::stop (" Timers using labels" ,nIterations*2 ," start-stop" );
93- phiprof::stop (" Benchmarking phiprofr " );
94+ phiprof::stop (" Timers using labels" , nIterations*2 , " start-stop" );
95+ phiprof::stop (" Benchmarking phiprof " );
9496
9597 MPI_Barrier (MPI_COMM_WORLD);
9698
9799 if (rank==0 )
98100 cout << " Measuring accuracy" <<endl;
99- /*
101+
102+
100103 phiprof::start (" Test accuracy" );
104+
101105 if (rank==0 )
102- cout << " 1/2 " <<endl;
103- phiprof::start("100x0.1s computations");
106+ cout << " 1/3 " <<endl;
107+ phiprof::start (" 100x0.01s computations" );
104108 for (int i=0 ;i<100 ;i++){
105109 phiprof::start (" compute" );
106- compute(0.1 );
110+ compute (0.01 );
107111 phiprof::stop (" compute" );
108112 }
109- phiprof::stop("100x0.1s computations");
113+ phiprof::stop (" 100x0.01s computations" );
114+
115+ if (rank==0 )
116+ cout << " 2/3" <<endl;
117+ MPI_Barrier (MPI_COMM_WORLD);
118+
119+ phiprof::start (" 100 x 0.01 (threadId + 1)s, ID" );
120+ int id = phiprof::initializeTimer (" compute" );
121+ #pragma omp parallel
122+ for (int i=0 ;i<100 ;i++){
123+ phiprof::start (id);
124+ compute (0.01 * (omp_get_thread_num () + 1 ));
125+ phiprof::stop (id);
126+ }
127+ phiprof::stop (" 100 x 0.01 (threadId + 1)s, ID" );
110128
111129 if (rank==0 )
112- cout << " 2/2 " <<endl;
130+ cout << " 3/3 " <<endl;
113131 MPI_Barrier (MPI_COMM_WORLD);
114- phiprof::start("100x0.1s computations + logprofile");
132+
133+ phiprof::start (" 100 x 0.01 (threadId + 1)s, String" );
134+ #pragma omp parallel
115135 for (int i=0 ;i<100 ;i++){
116136 phiprof::start (" compute" );
117- compute(0.1);
118- phiprof::printLogProfile(MPI_COMM_WORLD,i);
119- phiprof::printLogProfile(MPI_COMM_WORLD,i,"profile_log_maxlev1"," ",1);
137+ compute (0.01 * (omp_get_thread_num () + 1 ));
120138 phiprof::stop (" compute" );
121139 }
122- phiprof::stop("100x0.1s computations + logprofile");
140+ phiprof::stop (" 100 x 0.01 (threadId + 1)s, String" );
141+
142+
123143
124144 phiprof::stop (" Test accuracy" );
125- */
145+
146+ if (rank%2 == 1 ) {
147+
148+ phiprof::start (" Test-profile-groups" );
149+ phiprof::stop (" Test-profile-groups" );
150+ }
151+
152+
126153 MPI_Barrier (MPI_COMM_WORLD);
127154 double t1=MPI_Wtime ();
128155 phiprof::print (MPI_COMM_WORLD);
129- phiprof::print (MPI_COMM_WORLD," profile_minfrac0.01" ,0.01 );
130156 if (rank==0 )
131157 cout<< " Print time is " <<MPI_Wtime ()-t1<<endl;
132158// phiprof::print(MPI_COMM_WORLD,0.1);
0 commit comments