Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--deterministic option added #632

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Converter/include/converter_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,4 @@ struct Options {
bool noChunking = false;
bool noIndexing = false;

};
};
4 changes: 3 additions & 1 deletion Converter/include/sampler_random.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ struct SamplerRandom : public Sampler {
}

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();

if (deterministicOperation) {
seed = 20;
}
shuffle(indices.begin(), indices.end(), std::default_random_engine(seed));

auto buffer = make_shared<Buffer>(node->points->size);
Expand Down
1 change: 1 addition & 0 deletions Converter/modules/unsuck/unsuck.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static long long unsuck_start_time = high_resolution_clock::now().time_since_epo

static double Infinity = std::numeric_limits<double>::infinity();

inline bool deterministicOperation = false;

#if defined(__linux__)
constexpr auto fseek_64_all_platforms = fseeko64;
Expand Down
9 changes: 3 additions & 6 deletions Converter/src/chunker_countsort_laszip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ namespace chunker_countsort_laszip {
auto numChunkerThreads = getCpuData().numProcessors;
auto numFlushThreads = getCpuData().numProcessors;

// auto numChunkerThreads = 1;
// auto numFlushThreads = 1;

int maxPointsPerChunk = 5'000'000;
int gridSize = 128;
mutex mtx_attributes;
Expand Down Expand Up @@ -274,7 +271,7 @@ namespace chunker_countsort_laszip {
//cout << ("end: " + formatNumber(dbgCurr)) << endl;
};

TaskPool<Task> pool(numChunkerThreads, processor);
TaskPool<Task> pool((deterministicOperation ? 1 : numChunkerThreads), processor);

auto tStartTaskAssembly = now();

Expand Down Expand Up @@ -670,7 +667,7 @@ namespace chunker_countsort_laszip {
state.bytesProcessed = 0;
state.duration = 0;

writer = new ConcurrentWriter(numFlushThreads, state);
writer = new ConcurrentWriter((deterministicOperation ? 1 : numFlushThreads), state);

printElapsedTime("distributePoints0", tStart);

Expand Down Expand Up @@ -934,7 +931,7 @@ namespace chunker_countsort_laszip {

};

TaskPool<Task> pool(numChunkerThreads, processor);
TaskPool<Task> pool((deterministicOperation ? 1 : numChunkerThreads), processor);

for (auto source: sources) {

Expand Down
5 changes: 5 additions & 0 deletions Converter/src/indexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,11 @@ void doIndexing(string targetDir, State& state, Options& options, Sampler& sampl
mutex mtx_nodes;
vector<shared_ptr<Node>> nodes;
int numThreads = numSampleThreads() + 4;
if (deterministicOperation) {
numThreads = 1;
}


TaskPool<Task> pool(numThreads, [&onNodeCompleted, &onNodeDiscarded, &writeAndUnload, &state, &options, &activeThreads, tStart, &lastReport, &totalPoints, totalBytes, &pointsProcessed, chunks, &indexer, &nodes, &mtx_nodes, &sampler](auto task) {

auto chunk = task->chunk;
Expand Down
7 changes: 6 additions & 1 deletion Converter/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Options parseArguments(int argc, char** argv) {
args.addArgument("keep-chunks", "Skip deleting temporary chunks during conversion");
args.addArgument("no-chunking", "Disable chunking phase");
args.addArgument("no-indexing", "Disable indexing phase");
args.addArgument("deterministic", "Same output files for same input");
args.addArgument("attributes", "Attributes in output file");
args.addArgument("projection", "Add the projection of the pointcloud to the metadata");
args.addArgument("generate-page,p", "Generate a ready to use web page with the given name");
Expand Down Expand Up @@ -117,6 +118,7 @@ Options parseArguments(int argc, char** argv) {
bool keepChunks = args.has("keep-chunks");
bool noChunking = args.has("no-chunking");
bool noIndexing = args.has("no-indexing");
deterministicOperation = args.has("deterministic");

Options options;
options.source = source;
Expand Down Expand Up @@ -520,6 +522,9 @@ int main(int argc, char** argv) {
cout << "#threads: " << cpuData.numProcessors << endl;

auto options = parseArguments(argc, argv);
if (deterministicOperation) {
cout << "Deterministic Operation locks everything to single threading\n";
}

auto [name, sources] = curateSources(options.source);
if (options.name.size() == 0) {
Expand Down Expand Up @@ -566,4 +571,4 @@ int main(int argc, char** argv) {


return 0;
}
}