Bog'liq (Lecture Notes in Computer Science 10793) Mladen Berekovic, Rainer Buchty, Heiko Hamann, Dirk Koch, Thilo Pionteck - Architecture of Computing Systems – ARCS
Table 1. Ampehre library C interface. The function call sequence
0 – 9
presents a correct use of the library. Actual measurements are obtained between
ms start measurement() and ms stop measurement()
#
Function
Explanation
0
MS = ms init ();
Initialize Ampehre and PAPI libraries
1
MD = ms alloc measurement ();
Allocate data containers storing measured and calculated
data
2
ms set timer (MD, Component, Sampling Period); Set component-specific sampling period. Repeat function
call for all required PAPI components
3
ms init measurement (MS, MD);
Register data containers with Ampehre. Initialize timers
for periodic sampling
4
ms start measurement (MS);
Start measuring. Each component is periodically sampled
by a dedicated thread. Data are stored in priorly
registered
MD
5
ms stop measurement (MS);
Stop measuring. Terminate sampling threads
6
ms join measurement (MS);
Wait until all sampling threads have terminated
7
ms fini measurement (MS);
Clean up environment
8
ms free measurement (MD);
Free data containers
9
ms fini(MS);
Shut down Ampehre and PAPI libraries
measurements. The sequence of function calls in the table shows the correct use
of the library. The library implementation as well as the API isolate the data
structures storing the measurement results from the actual measuring system.
We refer to these two parts as measurement data MD and measuring system MS,
respectively. Step 0 initializes the MS, i.e., the underlying Ampehre library, the
PAPI library, the Linux OS drivers, and the vendor libraries are opened and con-
figured to retrieve measurements. The MD is allocated subsequently in step 1 .
Step 2 sets the sampling period for the measurement, where for each under-
lying PAPI component a separate sampling period can be chosen. Setting sam-
pling periods involves a trade-off since short sampling periods lead to measure-
ments with high accuracy, but can increase the CPU load caused by the measur-
ing framework unacceptably. Long sampling periods lead to smaller increases of
CPU load but also to less accurate measurements. We discuss this trade-off in
more detail in Sect.
4
. The next step 3 links the MD with the MS and initializes
one periodic timer per PAPI component. Whenever a timer expires, it triggers
the actual measuring procedures in the PAPI respective component followed by
internal calculations mainly in the Ampehre library. The measurement frame-
work starts with step 4 , that creates a POSIX thread for each component.
This way, we can perform the required computations for the components inde-
pendently. The gained results are stored in the registered MD structures. Properly
stopping the measurement framework requires the steps 5 , 6 , and 7 . These
steps terminate the measurement threads and performs cleanups. The accumu-
lated measurements remain stored in MD until 8 and 9 are called to free the
data structures and shut down all libraries.