Actual source code: ex3.c
2: static char help[] = "Augmenting PETSc profiling by add events.\n\
3: Run this program with one of the\n\
4: following options to generate logging information: -log, -log_summary,\n\
5: -log_all. The PETSc routines automatically log event times and flops,\n\
6: so this monitoring is intended solely for users to employ in application\n\
7: codes. Note that the code must be compiled with the flag -DPETSC_USE_LOG\n\
8: (the default) to activate logging.\n\n";
10: /*T
11: Concepts: PetscLog^user-defined event profiling
12: Concepts: profiling^user-defined event
13: Concepts: PetscLog^activating/deactivating events for profiling
14: Concepts: profiling^activating/deactivating events
15: Processors: n
16: T*/
18: /*
19: Include "petsc.h" so that we can use PETSc profiling routines.
20: */
21: #include petsc.h
25: int main(int argc,char **argv)
26: {
28: int i,imax=10000,icount;
29: #if defined (PETSC_USE_LOG)
30: PetscEvent USER_EVENT;
31: #endif
33: PetscInitialize(&argc,&argv,(char *)0,help);
35: /*
36: Create a new user-defined event.
38: integer event number, which should then be used for profiling
40: - The user can also optionally log floating point operations
41: with the routine PetscLogFlops().
42: */
45: icount = 0;
46: for (i=0; i<imax; i++) icount++;
47: PetscLogFlops(imax);
48: PetscSleep(1);
51: /*
52: We disable the logging of an event.
54: */
57: PetscSleep(1);
60: /*
61: We next enable the logging of an event
62: */
65: PetscSleep(1);
68: PetscFinalize();
69: return 0;
70: }
71: