Hello,
I'm using the following structure for a Macrobenchmark:
public class MyBenchmark extends Benchmark {
@Param({ "10", "30", "50", "70", "90", "110" })
private int n;
@Param
CalcType type;
public enum CalcType {
CPU, GPU
};
@Override
protected void setUp() throws Exception {
// ...
}
@Override
protected void tearDown() throws Exception {
// ...
}
@Macrobenchmark
public void timeCalculate() {
doBenchmark(0);
}
public int doBenchmark(int sum) {
switch (type) {
case CPU:
sum = doCPU(sum);
break;
case GPU:
sum = doGPU(sum);
break;
default:
break;
}
return sum;
}
private int doCPU(int sum) {
try {
sum += ToolRunner.run(new KMeans(false), null);
} catch (Exception e) {
e.printStackTrace();
}
return sum;
}
private int doGPU(int sum) {
try {
sum += ToolRunner.run(new KMeans(true), null);
} catch (Exception e) {
e.printStackTrace();
}
return sum;
}
private class Example extends Configured implements Tool {
private boolean useGPU;
public Example(boolean useGPU) {
this.useGPU = useGPU;
}
@Override
public int run(String[] arg0) throws Exception {
if (useGPU) {
// run GPU Program with parameter n
} else {
// run CPU Program with parameter n
}
return 0;
}
}
public static void main(String[] args) {
CaliperMain.main(MyBenchmark.class, args);
}
}
I'm executing this Marcobenchmark with the following command:
java -Xmx4G -javaagent:../../../lib/allocation-instrumenter-2.1.jar -jar KMeans-Benchmark.jar --time-limit 600s --instrument macro -Cinstrument.macro.options.measurements=5 -Cinstrument.macro.options.warmup=30s
Class loading breakage: Will not be able to instrument JDK classes
Experiment selection:
Instruments: [macro]
User parameters: {n=[10, 30, 50, 70, 90, 110], type=[CPU, GPU]}
Virtual machines: [default]
Selection type: Full cartesian product
This selection yields 12 experiments.
But I'm always observing the following warnings:
Starting experiment 1 of 12: {instrument=macro, method=timeCalculate, vm=default, parameters={k=10, type=CPU}}
WARNING: Hotspot compilation occurred during timing. Depending on the scope of the benchmark, this might significantly impact results. Consider running with a longer warmup.
WARNING: Hotspot compilation occurred after warmup, but outside of timing. Depending on the scope of the benchmark, this might significantly impact results. Consider running with a longer warmup.
1) May I ignore these warnings or should I use some other configuration?
Usually my applications are running 20 seconds and more.
2) How can I add custom measurements in caliper?
My applications do a more fine grained time measurement and I want to add these results to the measurement output.
Maybe I have to use an other caliper method? (not timeCalculate)
e.g., my program is measuring serialization, execution and deserialization time and I want to include these values in measurements? (like magnitude of timeCalculate)
Something like this?
@Override
public int run(String[] arg0) throws Exception {
Results r;
if (useGPU) {
r = runGPUProgram(n);
} else {
r = runGPUProgram(n);
}
CaliperMeasurement.addValue("serializationTime", r.getSerializationTime());
return 0;
}
Thanks in advance, Martin