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:
bool dumpsqnr; // Still unused.
bool native;
bool dropcache;
bool ordered_write;
std::string sigpipe;
std::string input;
std::string output;
......@@ -122,6 +123,7 @@ public:
, dumpsqnr(false)
, native(true)
, dropcache(false)
, ordered_write(false)
, sigpipe()
, input()
, output()
......@@ -184,6 +186,7 @@ public:
"-f, --finalize type full, incremental, keep, etc.",
//"-l, --lod N: *Level of detail, 0 = full resolution.",
"-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.",
"-Q, --sqnr QUALITY: Compression quality. Uncompressed if absent.",
"-z, --omp-nest N: Levels of OpenMP nesting.",
......@@ -272,7 +275,7 @@ public:
if (lod != 0)
os << "--lod=" << lod << " ";
if (threads != 1)
os << "--threads=" << threads << " ";
os << (ordered_write ? "--threads=" : "--uthreads=") << threads << " ";
if (brickcount >= 0)
os << "--brickcount=" << brickcount << " ";
if (sqnr > 0)
......@@ -414,7 +417,7 @@ public:
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()
......@@ -441,6 +444,7 @@ public:
{"algorithm", required_argument, 0, 'g' },
{"finalize" , required_argument, 0, 'f' },
{"threads", required_argument, 0, 't' },
{"uthreads", required_argument, 0, 'T' },
{"brickcount", required_argument, 0, 'n' },
{"lod", required_argument, 0, 'l' },
{"sqnr", required_argument, 0, 'Q' },
......@@ -543,7 +547,8 @@ public:
case 'g': algorithm = getDecimationTypes(optarg); break;
case 'f': finalize = getFinalizeAction(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 'Q': sqnr = geti(optarg); break;
case 'z': omp_nest = geti(optarg); break;
......@@ -1226,20 +1231,38 @@ copy(const Options& opt, SummaryPrintingTimerEx& rtimer, SummaryPrintingTimerEx&
std::cerr << outstring.str() << std::flush;
}
std::shared_ptr<void> buf(malloc(bufbytes), [](void *d){::free(d);});
if (opt.ordered_write) {
#pragma omp for ordered schedule(dynamic,1)
for (std::int64_t task = 0; task < total; ++task) {
guard.run([&]()
for (std::int64_t task = 0; task < total; ++task) {
guard.run([&]()
{
readchunk(r, w, tasklist[task], bs, surveysize,
buf.get(), dt, rtimer, opt.noisefactor);
});
#pragma omp ordered
guard.run([&]()
guard.run([&]()
{
writechunk(r, w, tasklist[task], bs, surveysize,
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();
......
Markdown is supported
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