Skip to content

Commit

Permalink
benchmark updates
Browse files Browse the repository at this point in the history
  • Loading branch information
potree committed Jan 26, 2020
1 parent 9e967ca commit 6f11c82
Show file tree
Hide file tree
Showing 13 changed files with 508 additions and 51 deletions.
1 change: 1 addition & 0 deletions Skye.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ copy /Y "$(SolutionDir)libs\openvr\openvr_api.dll" "$(OutDir)"</Command>
<ClInclude Include="include\GLTimerQueries.h" />
<ClInclude Include="include\OpenVRHelper.h" />
<ClInclude Include="include\Shader.h" />
<ClInclude Include="include\TaskPool.h" />
<ClInclude Include="include\utils.h" />
<ClInclude Include="include\V8ComputeShader.h" />
<ClInclude Include="include\v8File.h" />
Expand Down
3 changes: 3 additions & 0 deletions Skye.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,8 @@
<ClInclude Include="modules\progressive\ProgressiveBINLoader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\TaskPool.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
105 changes: 105 additions & 0 deletions include/TaskPool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

#pragma once

#include <thread>
#include <mutex>
#include <atomic>
#include <deque>
#include <vector>

using namespace std;

// might be better off using https://github.com/progschj/ThreadPool
template<class Task>
class TaskPool {
public:
int numThreads = 0;
deque<shared_ptr<Task>> tasks;
using TaskProcessorType = function<void(shared_ptr<Task>)>;
TaskProcessorType processor;

vector<thread> threads;

atomic<bool> isClosed = false;

mutex mtx_task;

TaskPool(int numThreads, TaskProcessorType processor) {
this->numThreads = numThreads;
this->processor = processor;

for (int i = 0; i < numThreads; i++) {

threads.emplace_back([this]() {

while (true) {

shared_ptr<Task> task = nullptr;

{ // retrieve task or leave thread if done
lock_guard<mutex> lock(mtx_task);

bool allDone = tasks.size() == 0 && isClosed;
bool waitingForWork = tasks.size() == 0 && !allDone;
bool workAvailable = tasks.size() > 0;

if (allDone) {
break;
} else if (workAvailable) {
task = tasks.front();
tasks.pop_front();
}


}

if (task != nullptr) {
this->processor(task);
}

std::this_thread::sleep_for(std::chrono::milliseconds(10));
}

});
}

}

void addTask(shared_ptr<Task> t) {
lock_guard<mutex> lock(mtx_task);

tasks.push_back(t);
}

void close() {
isClosed = true;

for (thread& t : threads) {
t.join();
}
}

void waitTillEmpty() {

while (true) {

int size = 0;

{
lock_guard<mutex> lock(mtx_task);

size = tasks.size();
}

if (size == 0) {
return;
} else {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}

}

}

};

11 changes: 11 additions & 0 deletions modules/progressive/ProgressiveBINLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "GLFW\glfw3.h"

#include "ComputeShader.h"
#include "V8Helper.h"
#include "BArray.h"

#include <Windows.h>
Expand Down Expand Up @@ -132,6 +133,13 @@ class BINLoader {
pointsLoaded += chunkSizePoints;
numLoaded = pointsLoaded;

{
double progress = double(pointsLoaded) / double(numPoints);
string strProgress = std::to_string(int(progress * 100));
V8Helper::instance()->debugValue["pointcloud_progress"] = strProgress + "%";
}


if (pointsLoaded >= numPoints) {
break;
}
Expand All @@ -142,6 +150,9 @@ class BINLoader {
auto duration = end - start;
cout << "finished loading file: " << duration << "s" << endl;

//V8Helper::instance()->debugValue["pointcloud_loaded"] = "true";
V8Helper::instance()->debugValue["pointcloud_progress"] = "100%";


});
t.detach();
Expand Down
191 changes: 181 additions & 10 deletions modules/progressive/eval/benchmark_morro_bay_1billion.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

if(!$("testcloud")){

//let las = loadLASProgressive("D:/dev/pointclouds/open_topography/ca13/morro_bay.bin");
let las = loadBINProgressive("D:/dev/pointclouds/open_topography/ca13/morro_bay_1billion.bin");
//let las = loadBINProgressive("../../morro_bay.bin");
//let las = loadBINProgressive("../../morro_bay_1billion.bin");
let las = loadBINProgressive("D:/dev/pointclouds/open_topography/ca13/morro_bay.bin");
// let las = loadBINProgressive("D:/dev/pointclouds/open_topography/ca13/morro_bay_1billion.bin");

let pc = new PointCloudProgressive("testcloud", "blabla");

Expand Down Expand Up @@ -59,13 +61,13 @@ if(!$("testcloud")){
0, 0, 0, 1,
]);


pc.numPoints = las.numPoints;

scene.root.add(pc);

listeners.update.push(() => {
pc.numPoints = las.numPoints;
});
// listeners.update.push(() => {
// pc.numPoints = las.numPoints;
// });

}

Expand All @@ -81,10 +83,179 @@ window.height = 1080;
// window.width = 2560;
// window.height = 1440;

MSAA_SAMPLES = 4;
EDL_ENABLED = true;
MSAA_SAMPLES = 1;
EDL_ENABLED = false;

renderDebug = renderPointCloudProgressive;
//renderDebug = renderPointCloudBasic;
// renderDebug = renderPointCloudBasic;
// renderDebug = renderPointCloudProgressive;

camera.near = 10;

function measurePerformance(label){
let vProgressive = getDebugValue("gl.render.progressive");
let vPass1 = getDebugValue("gl.render.progressive.p1_reproject");
let vPass2 = getDebugValue("gl.render.progressive.p2_fill.render_fixed");
let vPass3 = getDebugValue("gl.render.progressive.p3_vbo");
let vBruteforce = getDebugValue("gl.render.basic");

let algorithm = null;
if(renderDebug === renderPointCloudBasic){
algorithm = "bruteforce";
}else if(renderDebug === renderPointCloudProgressive){
algorithm = "progressive";
}

let content = `
##
## ${label}
##
EDL_ENABLED: ${EDL_ENABLED},
MSAA_SAMPLES: ${MSAA_SAMPLES},
PROGRESSIVE_BUDGET: ${PROGRESSIVE_BUDGET},
algorithm: ${algorithm}
measurements:
`;

if(algorithm === "bruteforce"){

lines = [`bruteforce: ${vBruteforce}`];

content += lines.join("\n");
}else if(algorithm === "progressive"){

lines = [
`progressive: ${vProgressive}`,
`pass1: ${vPass1}`,
`pass2: ${vPass2}`,
`pass3: ${vPass3}`,
];

content += lines.join("\n");
}


fsFileAppendText("./benchmark.txt", content);
}

async function runTest(){
GLTimerQueries.enabled = true;

for(let i = 0; i < 1000; i++){

await sleep(1);

let progress = getDebugValue("pointcloud_progress");
log(`load progress: ${progress}`);

if(progress === "100%"){
break;
}
}

log("start benchmarks");

fsFileDelete("./benchmark.txt");

await sleep(1);

{ // TEST 1
log("EXECUTING TEST 1");

EDL_ENABLED = false;
MSAA_SAMPLES = 1;
PROGRESSIVE_BUDGET = 1 * 1000 * 1000;
renderDebug = renderPointCloudProgressive;

// let state settle for a bit
await sleep(2);

measurePerformance("TEST 1");
}

{ // TEST 2
log("EXECUTING TEST 2");

EDL_ENABLED = false;
MSAA_SAMPLES = 1;
PROGRESSIVE_BUDGET = 1 * 1000 * 1000;
renderDebug = renderPointCloudProgressive;

// let state settle for a bit
await sleep(2);

measurePerformance("TEST 2");
}

{ // TEST 3
log("EXECUTING TEST 3");

EDL_ENABLED = false;
MSAA_SAMPLES = 1;
PROGRESSIVE_BUDGET = 10 * 1000 * 1000;
renderDebug = renderPointCloudProgressive;

// let state settle for a bit
await sleep(2);

measurePerformance("TEST 3");
}

{ // TEST 4
log("EXECUTING TEST 4");

EDL_ENABLED = false;
MSAA_SAMPLES = 1;
PROGRESSIVE_BUDGET = 10 * 1000 * 1000;
renderDebug = renderPointCloudProgressive;

// let state settle for a bit
await sleep(2);

measurePerformance("TEST 4");
}

{ // TEST 5 - NOW TESTING BRUTEFORCE!!!
log("EXECUTING TEST 5");

EDL_ENABLED = false;
MSAA_SAMPLES = 1;
PROGRESSIVE_BUDGET = 1 * 1000 * 1000;
renderDebug = renderPointCloudBasic;

// let state settle for a bit
await sleep(2);

measurePerformance("TEST 5");
await sleep(1);
measurePerformance("TEST 5.1");
}

// back to progressive
PROGRESSIVE_BUDGET = 1 * 1000 * 1000;
renderDebug = renderPointCloudProgressive;

log("Benchmark finished.");
log("results at './bin/Release_x64/benchmark.txt'");


};

runTest();















Loading

0 comments on commit 6f11c82

Please sign in to comment.