Commit 2b578911 authored by Noric Couderc's avatar Noric Couderc
Browse files

Added test to check the PAPI lib can be called.

parent 476014ac
......@@ -4,6 +4,9 @@ import se.lth.cs.*;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import papi.*;
import static junit.framework.TestCase.assertEquals;
public class ApplicationTest {
......@@ -140,4 +143,35 @@ public class ApplicationTest {
apps
);
}
@Test
public void TestPapi() throws PapiException {
Papi.init();
// Throws exception
EventSet evset = EventSet.create(Constants.PAPI_TOT_CYC, Constants.PAPI_L1_DCM);
int[] results = new int[10];
// 9 warmup runs before measuring
for (int warmup = 10; warmup >= 0; --warmup) {
for (int i = 0; i < 10; i++) {
evset.start();
// some weird code to measure
for (int k = 0; k <= i*10; k++) {
results[i] += k*k;
}
// done with the code
evset.stop();
long[] data = evset.getCounters();
// only print the 10th run
if (warmup == 0) {
System.out.println("#" + i + ":\t" + data[0] + "\t" + data[1]);
}
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment