Commit c7c774c3 authored by Paal Kvamme's avatar Paal Kvamme
Browse files

Add -T, --uthreads option to zgycopyc. As -t, --threads but sacrifice optimal...

Add -T, --uthreads option to zgycopyc. As -t, --threads but sacrifice optimal ordering for increased parallelization. This makes OpenZGY zgycopyc more similar to ZGY-Public zgycopy.
parent 9871ea33
...@@ -91,6 +91,7 @@ public: ...@@ -91,6 +91,7 @@ public:
bool dumpsqnr; // Still unused. bool dumpsqnr; // Still unused.
bool native; bool native;
bool dropcache; bool dropcache;
bool ordered_write;
std::string sigpipe; std::string sigpipe;
std::string input; std::string input;
std::string output; std::string output;
...@@ -122,6 +123,7 @@ public: ...@@ -122,6 +123,7 @@ public:
, dumpsqnr(false) , dumpsqnr(false)
, native(true) , native(true)
, dropcache(false) , dropcache(false)
, ordered_write(false)
, sigpipe() , sigpipe()
, input() , input()
, output() , output()
...@@ -184,6 +186,7 @@ public: ...@@ -184,6 +186,7 @@ public:
"-f, --finalize type full, incremental, keep, etc.", "-f, --finalize type full, incremental, keep, etc.",
//"-l, --lod N: *Level of detail, 0 = full resolution.", //"-l, --lod N: *Level of detail, 0 = full resolution.",
"-t, --threads N: Number of threads to use for reading.", "-t, --threads N: Number of threads to use for reading.",
"-T, --uthreads N: As -t but writes may be unordered",
"-n, --brickcount N: Only copy the first N bricks.", "-n, --brickcount N: Only copy the first N bricks.",
"-Q, --sqnr QUALITY: Compression quality. Uncompressed if absent.", "-Q, --sqnr QUALITY: Compression quality. Uncompressed if absent.",
"-z, --omp-nest N: Levels of OpenMP nesting.", "-z, --omp-nest N: Levels of OpenMP nesting.",
...@@ -272,7 +275,7 @@ public: ...@@ -272,7 +275,7 @@ public:
if (lod != 0) if (lod != 0)
os << "--lod=" << lod << " "; os << "--lod=" << lod << " ";
if (threads != 1) if (threads != 1)
os << "--threads=" << threads << " "; os << (ordered_write ? "--threads=" : "--uthreads=") << threads << " ";
if (brickcount >= 0) if (brickcount >= 0)
os << "--brickcount=" << brickcount << " "; os << "--brickcount=" << brickcount << " ";
if (sqnr > 0) if (sqnr > 0)
...@@ -414,7 +417,7 @@ public: ...@@ -414,7 +417,7 @@ public:
static const char* short_options() static const char* short_options()
{ {
return "hvqGuraDNFUp:i:o:s:l:b:B:O:g:t:n:Q:"; return "hvqGuraDNFUp:i:o:s:l:b:B:O:g:t:T:n:Q:";
} }
static const struct option *long_options() static const struct option *long_options()
...@@ -441,6 +444,7 @@ public: ...@@ -441,6 +444,7 @@ public:
{"algorithm", required_argument, 0, 'g' }, {"algorithm", required_argument, 0, 'g' },
{"finalize" , required_argument, 0, 'f' }, {"finalize" , required_argument, 0, 'f' },
{"threads", required_argument, 0, 't' }, {"threads", required_argument, 0, 't' },
{"uthreads", required_argument, 0, 'T' },
{"brickcount", required_argument, 0, 'n' }, {"brickcount", required_argument, 0, 'n' },
{"lod", required_argument, 0, 'l' }, {"lod", required_argument, 0, 'l' },
{"sqnr", required_argument, 0, 'Q' }, {"sqnr", required_argument, 0, 'Q' },
...@@ -543,7 +547,8 @@ public: ...@@ -543,7 +547,8 @@ public:
case 'g': algorithm = getDecimationTypes(optarg); break; case 'g': algorithm = getDecimationTypes(optarg); break;
case 'f': finalize = getFinalizeAction(optarg); break; case 'f': finalize = getFinalizeAction(optarg); break;
case 'l': throw std::runtime_error("--lod not supported"); //lod = geti(optarg); break; case 'l': throw std::runtime_error("--lod not supported"); //lod = geti(optarg); break;
case 't': threads = geti(optarg); break; case 't': threads = geti(optarg); ordered_write = true; break;
case 'T': threads = geti(optarg); ordered_write = false; break;
case 'n': brickcount = geti(optarg); break; case 'n': brickcount = geti(optarg); break;
case 'Q': sqnr = geti(optarg); break; case 'Q': sqnr = geti(optarg); break;
case 'z': omp_nest = geti(optarg); break; case 'z': omp_nest = geti(optarg); break;
...@@ -1226,20 +1231,38 @@ copy(const Options& opt, SummaryPrintingTimerEx& rtimer, SummaryPrintingTimerEx& ...@@ -1226,20 +1231,38 @@ copy(const Options& opt, SummaryPrintingTimerEx& rtimer, SummaryPrintingTimerEx&
std::cerr << outstring.str() << std::flush; std::cerr << outstring.str() << std::flush;
} }
std::shared_ptr<void> buf(malloc(bufbytes), [](void *d){::free(d);}); std::shared_ptr<void> buf(malloc(bufbytes), [](void *d){::free(d);});
if (opt.ordered_write) {
#pragma omp for ordered schedule(dynamic,1) #pragma omp for ordered schedule(dynamic,1)
for (std::int64_t task = 0; task < total; ++task) { for (std::int64_t task = 0; task < total; ++task) {
guard.run([&]() guard.run([&]()
{ {
readchunk(r, w, tasklist[task], bs, surveysize, readchunk(r, w, tasklist[task], bs, surveysize,
buf.get(), dt, rtimer, opt.noisefactor); buf.get(), dt, rtimer, opt.noisefactor);
}); });
#pragma omp ordered #pragma omp ordered
guard.run([&]() guard.run([&]()
{ {
writechunk(r, w, tasklist[task], bs, surveysize, writechunk(r, w, tasklist[task], bs, surveysize,
buf.get(), dt, wtimer); buf.get(), dt, wtimer);
}); });
guard.progress(); guard.progress();
}
}
else {
#pragma omp for schedule(dynamic,1)
for (std::int64_t task = 0; task < total; ++task) {
guard.run([&]()
{
readchunk(r, w, tasklist[task], bs, surveysize,
buf.get(), dt, rtimer, opt.noisefactor);
});
guard.run([&]()
{
writechunk(r, w, tasklist[task], bs, surveysize,
buf.get(), dt, wtimer);
});
guard.progress();
}
} }
} }
rwt.stop(); rwt.stop();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment