HW2: RC1 - Model version
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "utils.hpp"
|
||||
#include "distsort.hpp"
|
||||
|
||||
Timing TfullSort, Texchange, Tminmax, TelbowSort;
|
||||
|
||||
bool isActive(mpi_id_t node, size_t nodes) {
|
||||
if (!((nodes > 0) &&
|
||||
|
||||
+25
-16
@@ -17,12 +17,12 @@
|
||||
#include "distsort.hpp"
|
||||
|
||||
|
||||
// Global session data
|
||||
session_t session;
|
||||
// Global config data
|
||||
config_t config;
|
||||
MPI_t<> mpi;
|
||||
distBuffer_t Data;
|
||||
Log logger;
|
||||
Timing timer;
|
||||
Timing Ttotal;
|
||||
|
||||
/*!
|
||||
* A small command line argument parser
|
||||
@@ -37,23 +37,23 @@ bool get_options(int argc, char* argv[]){
|
||||
|
||||
if (arg == "-q" || arg == "--array-size") {
|
||||
if (i+1 < argc) {
|
||||
session.arraySize = 1 << atoi(argv[++i]);
|
||||
config.arraySize = 1 << atoi(argv[++i]);
|
||||
}
|
||||
else {
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
else if (arg == "--validation") {
|
||||
session.validation = true;
|
||||
config.validation = true;
|
||||
}
|
||||
else if (arg == "--ndebug") {
|
||||
session.ndebug = true;
|
||||
config.ndebug = true;
|
||||
}
|
||||
else if (arg == "-t" || arg == "--timing") {
|
||||
session.timing = true;
|
||||
else if (arg == "--perf") {
|
||||
config.perf = true;
|
||||
}
|
||||
else if (arg == "-v" || arg == "--verbose") {
|
||||
session.verbose = true;
|
||||
config.verbose = true;
|
||||
}
|
||||
else if (arg == "-h" || arg == "--help") {
|
||||
std::cout << "distbitonic/distbubbletonic - A distributed bitonic sort\n\n";
|
||||
@@ -65,6 +65,8 @@ bool get_options(int argc, char* argv[]){
|
||||
std::cout << "Options:\n\n";
|
||||
std::cout << " -q | --array-size <N>\n";
|
||||
std::cout << " Selects the array size according to size = 2^N\n\n";
|
||||
std::cout << " --par-sort\n";
|
||||
std::cout << " Request a parallel full sorting algorithm\n\n";
|
||||
std::cout << " --validation\n";
|
||||
std::cout << " Request a full validation at the end, performed by process rank 0\n\n";
|
||||
std::cout << " --ndebug\n";
|
||||
@@ -164,11 +166,11 @@ int main(int argc, char* argv[]) try {
|
||||
#else
|
||||
volatile bool sleep_wait = true;
|
||||
#endif
|
||||
while (sleep_wait && !session.ndebug)
|
||||
while (sleep_wait && !config.ndebug)
|
||||
sleep(1);
|
||||
#endif
|
||||
|
||||
logger << "Initialize local array of " << session.arraySize << " elements" << logger.endl;
|
||||
logger << "Initialize local array of " << config.arraySize << " elements" << logger.endl;
|
||||
std::random_device rd; // Mersenne seeded from hw if possible. range: [type_min, type_max]
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<distValue_t > dis(
|
||||
@@ -176,24 +178,31 @@ int main(int argc, char* argv[]) try {
|
||||
std::numeric_limits<distValue_t>::max()
|
||||
);
|
||||
// Fill vector
|
||||
Data.resize(session.arraySize);
|
||||
Data.resize(config.arraySize);
|
||||
std::generate(Data.begin(), Data.end(), [&]() { return dis(gen); });
|
||||
|
||||
if (mpi.rank() == 0)
|
||||
logger << "Starting distributed sorting ... ";
|
||||
timer.start();
|
||||
Ttotal.start();
|
||||
#if CODE_VERSION == BUBBLETONIC
|
||||
distBubbletonic(Data, mpi.size(), mpi.rank());
|
||||
#else
|
||||
distBitonic (Data, mpi.size(), mpi.rank());
|
||||
#endif
|
||||
timer.stop();
|
||||
Ttotal.stop();
|
||||
if (mpi.rank() == 0)
|
||||
logger << " Done." << logger.endl;
|
||||
std::string timeMsg = "rank " + std::to_string(mpi.rank());
|
||||
timer.print_dt(timeMsg.c_str());
|
||||
|
||||
if (session.validation) {
|
||||
|
||||
if (config.perf) {
|
||||
Ttotal.print_duration("Total ", mpi.rank());
|
||||
TfullSort.print_duration("Full-Sort ", mpi.rank());
|
||||
Texchange.print_duration("Exchange ", mpi.rank());
|
||||
Tminmax.print_duration("Min-Max ", mpi.rank());
|
||||
TelbowSort.print_duration("Elbow-Sort", mpi.rank());
|
||||
}
|
||||
if (config.validation) {
|
||||
// If requested, we have the chance to fail!
|
||||
if (mpi.rank() == 0)
|
||||
std::cout << "Results validation ...";
|
||||
|
||||
Reference in New Issue
Block a user