Previous: , Up: Iterating   [Contents][Index]


Timed loops

Timed loops

A timed loop is similar to a counted loop (see Counted loops) but instead of running for a given number of iterations it runs for a given length of time. Timed loops are absent from all general-purpose programming languages but can be quite useful in the context of network correctness and performance testing. The syntax of coNCePTuaL’s timed-loop construct is “ FOR <expr> <time_unit> <simple_stmt>”. <time_unit> is unit of time as listed in Delaying execution and <expr> specifies the number of <time_unit>s for which to execute.

The following example shows how to spend three seconds sending messages from task 0 to task 1:

FOR 3 SECONDS TASK 0 SENDS A 1 MEGABYTE MESSAGE TO TASK 1

Although coNCePTuaL tries its best to run for exactly the specified length of time there will invariably be some error in the process. Always use elapsed_usecs (see Predeclared variables) as the indicator of actual time instead of the time requested in the loop.

Timed loops can optionally run for a length of “warmup” time in addition to the base execution time. The syntax is “ FOR <expr> <time_unit> PLUS <expr> WARMUP <time_unit> <simple_stmt>”. During warmup repetitions, the OUTPUTS statement (see Writing to standard output), the LOGS statement (see Writing to a log file), and the COMPUTES AGGREGATES statement (see Computing aggregates) are all suppressed (i.e., they have no effect) and none of the special variables predeclared by coNCePTuaL (see Predeclared variables) are updated. Many benchmarks synchronize all tasks after performing a set of warmup repetitions. This behavior can be expressed conveniently as part of a timed loop by appending the AND A SYNCHRONIZATION clause:

FOR 3 SECOND PLUS 1 WARMUP MILLISECOND AND A SYNCHRONIZATION TASK 0
SENDS A 1 MEGABYTE MESSAGE TO TASK 1

coNCePTuaL also provides a separate SYNCHRONIZES statement. This is described in Synchronizing.

The importance of performing warmup repetitions is that many communication layers give atypically poor performance on the first few transmissions. This may be because the messages miss in the cache; because the communication layer needs to establish connections between pairs of communicating tasks; or, because the operating system needs to “register” message buffers with the network interface. Regardless of the reason, specifying warmup repetitions helps make performance measurements less variable.


Previous: , Up: Iterating   [Contents][Index]

Scott Pakin, pakin@lanl.gov