added more stuff
This commit is contained in:
@@ -40,7 +40,7 @@ public class Main {
|
||||
// utils.setInput(new MatInput(Imgcodecs.imread("src/main/resources/car.jpg")));
|
||||
// utils.setInput(new MatInput(Imgcodecs.imread("src/main/resources/skyscraper_small.jpg")));
|
||||
|
||||
utils.initializeCommands(false);
|
||||
utils.initializeCommands(true);
|
||||
utils.warmup(2);
|
||||
utils.runTests(2);
|
||||
utils.evaluate();
|
||||
|
||||
@@ -127,7 +127,7 @@ public class TestUtils<T> {
|
||||
*
|
||||
* @param iterations the number of warmup iterations
|
||||
*/
|
||||
public void warmupCPUTests(int iterations) {
|
||||
private void warmupCPUTests(int iterations) {
|
||||
checkInitialized();
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
|
||||
@@ -144,7 +144,7 @@ public class TestUtils<T> {
|
||||
*
|
||||
* @param iterations the number of warmup iterations
|
||||
*/
|
||||
public void warmupGPUTests(int iterations) {
|
||||
private void warmupGPUTests(int iterations) {
|
||||
checkInitialized();
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
|
||||
@@ -200,7 +200,7 @@ public class TestUtils<T> {
|
||||
*
|
||||
* @param iterations the number of iterations
|
||||
*/
|
||||
public void runCPUTests(int iterations) {
|
||||
private void runCPUTests(int iterations) {
|
||||
checkInitialized();
|
||||
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
@@ -235,7 +235,7 @@ public class TestUtils<T> {
|
||||
*
|
||||
* @param iterations the number of iterations
|
||||
*/
|
||||
public void runGPUTests(int iterations) {
|
||||
private void runGPUTests(int iterations) {
|
||||
testUploadAndDownload(iterations);
|
||||
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
@@ -326,12 +326,116 @@ public class TestUtils<T> {
|
||||
ResultHandler.buildGraph();
|
||||
|
||||
if (this.testFullGraph) {
|
||||
// test other stuff
|
||||
MatPool.reset();
|
||||
UploadDownloadCaptor.reset();
|
||||
resetTasks();
|
||||
warmupAdditionalUploadsAndDownloads(this.warmupIterations);
|
||||
testAdditionalUploadsAndDownloads(this.testIterations);
|
||||
ResultHandler.addAdditionalEdges();
|
||||
}
|
||||
ResultHandler.evaluate();
|
||||
}
|
||||
|
||||
private void testAdditionalUploadsAndDownloads(int iterations) {
|
||||
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
MatPool.reset();
|
||||
UploadDownloadCaptor.reset();
|
||||
resetTasks();
|
||||
this.originalInput.copyTo(this.input);
|
||||
for (int j = 0; j < i; j++) {
|
||||
Task t = tasks.get(j);
|
||||
t.toCpuTask().run();
|
||||
}
|
||||
GpuTask gpuTask = tasks.get(i).toGpuTask();
|
||||
if (gpuTask != null) {
|
||||
gpuTask.init();
|
||||
gpuTask.run();
|
||||
gpuTask.cleanUp();
|
||||
|
||||
if (i != 0) {
|
||||
testUploadsAndDownloads1(iterations, tasks.get(i - 1), tasks.get(i));
|
||||
}
|
||||
UploadDownloadCaptor.reset();
|
||||
if (i != tasks.size() - 1) {
|
||||
gpuTask = new GenericGpuTask(tasks.get(i + 1));
|
||||
gpuTask.init();
|
||||
gpuTask.run();
|
||||
gpuTask.cleanUp();
|
||||
testUploadsAndDownloads2(iterations, tasks.get(i), tasks.get(i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void testUploadsAndDownloads2(int iterations, Task gpuBefore, Task cpuTask) {
|
||||
List<MatTaskTuple> uploads = UploadDownloadCaptor.getUploads();
|
||||
List<MatTaskTuple> downloads = UploadDownloadCaptor.getDownloads();
|
||||
for (int i = 0; i < uploads.size(); i++) {
|
||||
UploadTask task = new UploadTask(uploads.get(i).getMat(), uploads.get(i).getTask());
|
||||
TimeDto time = testUpload(iterations, task);
|
||||
ResultHandler.newResultGpuToCpu(gpuBefore, cpuTask, time, true, task);
|
||||
}
|
||||
for (int i = 0; i < downloads.size(); i++) {
|
||||
DownloadTask task = new DownloadTask(downloads.get(i).getMat(), downloads.get(i).getTask());
|
||||
TimeDto time = testDownload(iterations, task);
|
||||
ResultHandler.newResultGpuToCpu(gpuBefore, cpuTask, time, false, task);
|
||||
}
|
||||
}
|
||||
|
||||
private void testUploadsAndDownloads1(int iterations, Task cpuBefore, Task gpuTask) {
|
||||
List<MatTaskTuple> uploads = UploadDownloadCaptor.getUploads();
|
||||
List<MatTaskTuple> downloads = UploadDownloadCaptor.getDownloads();
|
||||
for (int i = 0; i < uploads.size(); i++) {
|
||||
UploadTask task = new UploadTask(uploads.get(i).getMat(), uploads.get(i).getTask());
|
||||
TimeDto time = testUpload(iterations, task);
|
||||
ResultHandler.newResultCpuToGpu(cpuBefore, gpuTask, time, true, task);
|
||||
}
|
||||
for (int i = 0; i < downloads.size(); i++) {
|
||||
DownloadTask task = new DownloadTask(downloads.get(i).getMat(), downloads.get(i).getTask());
|
||||
TimeDto time = testDownload(iterations, task);
|
||||
ResultHandler.newResultCpuToGpu(cpuBefore, gpuTask, time, false, task);
|
||||
}
|
||||
}
|
||||
|
||||
private TimeDto testDownload(int iterations, DownloadTask task) {
|
||||
GpuTask gpuTask = task.toGpuTask();
|
||||
return TimingUtil.testPerformance(() -> {
|
||||
this.originalInput.copyTo(this.input);
|
||||
gpuTask.init();
|
||||
}, gpuTask::run, gpuTask::cleanUp, iterations);
|
||||
}
|
||||
|
||||
private TimeDto testUpload(int iterations, UploadTask task) {
|
||||
GpuTask gpuTask = task.toGpuTask();
|
||||
return TimingUtil.testPerformance(() -> {
|
||||
this.originalInput.copyTo(this.input);
|
||||
gpuTask.init();
|
||||
}, gpuTask::run, gpuTask::cleanUp, iterations);
|
||||
}
|
||||
|
||||
private void warmupAdditionalUploadsAndDownloads(int iterations) {
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
|
||||
this.originalInput.copyTo(this.input);
|
||||
for (Task t : tasks) {
|
||||
GpuTask task = t.toGpuTask();
|
||||
if (task != null) {
|
||||
task.init();
|
||||
task.run();
|
||||
task.cleanUp();
|
||||
}
|
||||
task = new GenericGpuTask(t);
|
||||
task.init();
|
||||
task.run();
|
||||
task.cleanUp();
|
||||
}
|
||||
MatPool.reset();
|
||||
resetTasks();
|
||||
}
|
||||
warmupUploadAndDownload(iterations);
|
||||
}
|
||||
|
||||
private void resetTasks() {
|
||||
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
|
||||
tasks.forEach(Task::reset);
|
||||
|
||||
-2
@@ -37,8 +37,6 @@ public class UploadDownloadCaptor {
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
uploads.forEach(tuple -> tuple.getMat().release());
|
||||
downloads.forEach(tuple -> tuple.getMat().release());
|
||||
uploads.clear();
|
||||
downloads.clear();
|
||||
}
|
||||
|
||||
+24
@@ -16,10 +16,34 @@ public class Result {
|
||||
|
||||
private final TimeDto time;
|
||||
|
||||
private final Task before;
|
||||
|
||||
private final Task after;
|
||||
|
||||
public Result(Task task, TestExecution execution, TimeDto time) {
|
||||
this.task = task;
|
||||
this.execution = execution;
|
||||
this.time = time;
|
||||
|
||||
this.before = null;
|
||||
this.after = null;
|
||||
}
|
||||
|
||||
public Result(Task before, Task after, TimeDto time, Task task) {
|
||||
this.task = task;
|
||||
this.execution = TestExecution.GPU;
|
||||
this.time = time;
|
||||
|
||||
this.before = before;
|
||||
this.after = after;
|
||||
}
|
||||
|
||||
public Task getAfter() {
|
||||
return this.after;
|
||||
}
|
||||
|
||||
public Task getBefore() {
|
||||
return this.before;
|
||||
}
|
||||
|
||||
public Task getTask() {
|
||||
|
||||
+23
@@ -230,4 +230,27 @@ public class ResultHandler {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cpuBefore
|
||||
* @param gpuTask
|
||||
* @param time
|
||||
* @param b
|
||||
* @param task
|
||||
*/
|
||||
public static void newResultCpuToGpu(Task cpuBefore, Task gpuTask, TimeDto time, boolean b, Task task) {
|
||||
System.out.println("AAAAA");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gpuBefore
|
||||
* @param cpuTask
|
||||
* @param time
|
||||
* @param b
|
||||
* @param task
|
||||
*/
|
||||
public static void newResultGpuToCpu(Task gpuBefore, Task cpuTask, TimeDto time, boolean b, Task task) {
|
||||
System.out.println("BBBBB");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user