added pagelocked tests and some refactoring
This commit is contained in:
@@ -26,9 +26,7 @@ public class Main {
|
||||
});
|
||||
utils.setInput(new MatInput(Imgcodecs.imread("src/main/resources/car.jpg")));
|
||||
utils.initializeCommands();
|
||||
utils.warmupGPUTests(5);
|
||||
utils.warmupCPUTests(5);
|
||||
utils.runCPUTests(10);
|
||||
utils.runGPUTests(10);
|
||||
utils.warmup(10);
|
||||
utils.runTests(50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bytedeco.opencv.global.opencv_core;
|
||||
import org.bytedeco.opencv.opencv_core.GpuMat;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.exception.AlreadyInitializedException;
|
||||
@@ -64,6 +65,16 @@ public class TestUtils<T> {
|
||||
Objects.requireNonNull(this.input);
|
||||
}
|
||||
|
||||
public void warmup(int iterations) {
|
||||
warmupCPUTests(iterations);
|
||||
warmupGPUTests(iterations);
|
||||
}
|
||||
|
||||
public void runTests(int iterations) {
|
||||
runCPUTests(iterations);
|
||||
runGPUTests(iterations);
|
||||
}
|
||||
|
||||
public void warmupCPUTests(int iterations) {
|
||||
checkInitialized();
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
@@ -78,6 +89,7 @@ public class TestUtils<T> {
|
||||
public void warmupGPUTests(int iterations) {
|
||||
checkInitialized();
|
||||
warmupUploadAndDownload(iterations);
|
||||
warmupPageLockedUpload(iterations);
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
|
||||
this.originalInput.copyTo(this.input);
|
||||
@@ -91,6 +103,18 @@ public class TestUtils<T> {
|
||||
}
|
||||
}
|
||||
|
||||
private void warmupPageLockedUpload(int iterations) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
this.originalInput.copyTo(this.input);
|
||||
try (org.bytedeco.opencv.opencv_core.Mat jcvMat = new org.bytedeco.opencv.opencv_core.Mat(); GpuMat gpuMat = new GpuMat()) {
|
||||
MatConverter.copyMat(this.input.toMat(), jcvMat);
|
||||
opencv_core.registerPageLocked(jcvMat);
|
||||
gpuMat.upload(jcvMat);
|
||||
opencv_core.unregisterPageLocked(jcvMat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void warmupUploadAndDownload(int iterations) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
this.originalInput.copyTo(this.input);
|
||||
@@ -138,9 +162,31 @@ public class TestUtils<T> {
|
||||
|
||||
private void testUploadAndDownload(int iterations) {
|
||||
testUpload(iterations);
|
||||
testPageLockedUpload(iterations);
|
||||
testDownload(iterations);
|
||||
}
|
||||
|
||||
private void testPageLockedUpload(int iterations) {
|
||||
org.bytedeco.opencv.opencv_core.Mat[] jcvMat = new org.bytedeco.opencv.opencv_core.Mat[1];
|
||||
GpuMat[] gpuMat = new GpuMat[1];
|
||||
|
||||
Runnable setUp = () -> {
|
||||
jcvMat[0] = new org.bytedeco.opencv.opencv_core.Mat();
|
||||
gpuMat[0] = new GpuMat();
|
||||
this.originalInput.copyTo(this.input);
|
||||
MatConverter.copyMat(this.input.toMat(), jcvMat[0]);
|
||||
opencv_core.registerPageLocked(jcvMat[0]);
|
||||
};
|
||||
Runnable test = () -> gpuMat[0].upload(jcvMat[0]);
|
||||
|
||||
Runnable cleanUp = () -> {
|
||||
opencv_core.unregisterPageLocked(jcvMat[0]);
|
||||
gpuMat[0].close();
|
||||
jcvMat[0].close();
|
||||
};
|
||||
TimeDto time = TimingUtil.testPerformance(setUp, test, cleanUp, iterations);
|
||||
}
|
||||
|
||||
private void testDownload(int iterations) {
|
||||
org.bytedeco.opencv.opencv_core.Mat[] jcvMat = new org.bytedeco.opencv.opencv_core.Mat[1];
|
||||
GpuMat[] gpuMat = new GpuMat[1];
|
||||
|
||||
@@ -5,10 +5,33 @@ package de.unidue.nes.gpu.testframework.internal.timing;
|
||||
*/
|
||||
public class TimeDto {
|
||||
|
||||
public double avgTime;
|
||||
public double varTime;// sigma²
|
||||
public double stdAbweichung;// sqrt(varTime)
|
||||
public int iterations;
|
||||
private double avgTime;
|
||||
private double varTime;// sigma²
|
||||
private double stdAbweichung;// sqrt(varTime)
|
||||
private int iterations;
|
||||
|
||||
public TimeDto(double avgTime, double varTime, double stdAbweichung, int iterations) {
|
||||
this.avgTime = avgTime;
|
||||
this.varTime = varTime;
|
||||
this.stdAbweichung = stdAbweichung;
|
||||
this.iterations = iterations;
|
||||
}
|
||||
|
||||
public double getAvgTime() {
|
||||
return this.avgTime;
|
||||
}
|
||||
|
||||
public double getVarTime() {
|
||||
return this.varTime;
|
||||
}
|
||||
|
||||
public double getStdAbweichung() {
|
||||
return this.stdAbweichung;
|
||||
}
|
||||
|
||||
public int getIterations() {
|
||||
return this.iterations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
+2
-6
@@ -37,11 +37,7 @@ public class TimingUtil {
|
||||
}
|
||||
var /= times.length;
|
||||
double stdAbw = Math.sqrt(var);
|
||||
TimeDto dto = new TimeDto();
|
||||
dto.avgTime = avg;
|
||||
dto.varTime = var;
|
||||
dto.stdAbweichung = stdAbw;
|
||||
dto.iterations = iterations;
|
||||
return dto;
|
||||
|
||||
return new TimeDto(avg, var, stdAbw, iterations);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user