Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doku:time [2015/04/02 11:34] – [MPI_WTIME()] irdoku:time [2015/04/17 11:45] (current) – [Hybrid OMP and MPI] ir
Line 5: Line 5:
 [[http://www.mpi-forum.org/docs/mpi-3.0/mpi30-report.pdf|mpi-3.0 Standard]].). [[http://www.mpi-forum.org/docs/mpi-3.0/mpi30-report.pdf|mpi-3.0 Standard]].).
  
-==== MPI_WTIME() ====+==== MPI internal functions ==== 
 + 
 +=== MPI_WTIME() ===
 <code> <code>
 double MPI_Wtime(void) double MPI_Wtime(void)
Line 13: Line 15:
  
 MPI_WTIME returns a floating-point number of seconds, representing elapsed wallclock MPI_WTIME returns a floating-point number of seconds, representing elapsed wallclock
-time since some time in the past and may be used as follows: +time since some time in the past. 
-<code>+Generally, **times can ONLY be compared within the same MPI-process.** The times returned are **local to the node that called them**. Di fferent nodes need not to be synchronized.
-double starttime, endtime; +
-starttime = MPI_Wtime(); +
-.... stuff to be timed ..+
-endtime = MPI_Wtime(); +
-printf("That took %f seconds\n",endtime-starttime); +
-}</code> +
-**Note:** The times returned are **local to the node that called them**. Di fferent nodes need not to be synchronized.+
 (MPI_WTIME_IS_GLOBAL is a Boolean variable that is 1 if synchronized and 0 if not. In Open MPI (MPI_WTIME_IS_GLOBAL is a Boolean variable that is 1 if synchronized and 0 if not. In Open MPI
 MPI_WTIME_IS_GLOBAL does not have a valid value since the clocks are not guaranteed to be synchronized.)  MPI_WTIME_IS_GLOBAL does not have a valid value since the clocks are not guaranteed to be synchronized.) 
-Therefore, compare times ONLY within the same MPI-process+ 
-==== MPI_WTICK() ====+MPI_WTIME has to be called inside the MPI region 
 +<code> 
 +MPI_Init(&argc, &argv); 
 +...  
 +MPI_Finalize( ); 
 +</code> 
 +otherwise its behavior is undefined. 
 + 
 +=== MPI_WTICK() ===
 <code>double MPI_Wtick(void) <code>double MPI_Wtick(void)
 DOUBLE PRECISION MPI_Wtick() BIND(C) DOUBLE PRECISION MPI_Wtick() BIND(C)
Line 31: Line 34:
 MPI_WTICK returns the resolution of MPI_WTIME in seconds, i.e. the time between successive clock ticks given in seconds.  MPI_WTICK returns the resolution of MPI_WTIME in seconds, i.e. the time between successive clock ticks given in seconds. 
  
-==== omp_get_wtime ====+=== Examples ==
 +In this  {{:doku:mpitime.c|example file}}, t1=MPI_WTIME() and t2=MPI_WTIME() enclose the region wich should be timed. 
 +There are two possibilities. Either a MPI_Barrier can be set before each time call. Then the time measured is the time needed that all MPI processes are finished. Or t1 and t2 are defined without a barrier, yielding the execution times for the individual processes. 
 +==== omp internal calls ==== 
 +=== omp_get_wtime ===
  
 c example: c example:
Line 47: Line 54:
 gives the amount of time that the CPU is busy for a particular task from one call to the next. gives the amount of time that the CPU is busy for a particular task from one call to the next.
  
 +===== Hybrid OMP and MPI ====== 
 +{{ :doku:mpi_omp:hybrid.png?400 |}}
 +{{ :doku:mpi_omp:hybridbarrier.png?400 |}}
 +{{:doku:mpi_omp:hybridtime.c|}}
 +====== Serial codes ====== 
 ==== fortran ==== ==== fortran ====
 <code> <code>
  • doku/time.1427974446.txt.gz
  • Last modified: 2015/04/02 11:34
  • by ir