HW2: RC3 - A small exchange optimization

This commit is contained in:
2025-01-04 16:56:34 +02:00
parent bc98ef4e9f
commit 4e7237bd4d
12 changed files with 249 additions and 46 deletions
+6 -1
View File
@@ -1,6 +1,6 @@
/*!
* \file
* \brief Distributed sort implementation.
* \brief Distributed sort implementation
*
* \author
* Christos Choutouridis AEM:8997
@@ -9,8 +9,13 @@
#include "utils.hpp"
#include "distsort.hpp"
//! Statistic variables for exchange optimization
distStat_t localStat, remoteStat;
//! Performance timers for each one of the "costly" functions
Timing TfullSort, Texchange, Tminmax, TelbowSort;
bool isActive(mpi_id_t node, size_t nodes) {
if (!((nodes > 0) &&
(nodes <= std::numeric_limits<mpi_id_t>::max()) ))
+9 -1
View File
@@ -138,6 +138,9 @@ bool validator(ShadowedDataT& data, mpi_id_t Processes, mpi_id_t rank) {
}
#if !defined TESTING
/*!
* @return Returns 0, but.... we may throw or exit(1)
*/
int main(int argc, char* argv[]) try {
// Initialize MPI environment
mpi.init(&argc, &argv);
@@ -170,6 +173,7 @@ int main(int argc, char* argv[]) try {
sleep(1);
#endif
// Initialize local data
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());
@@ -181,6 +185,7 @@ int main(int argc, char* argv[]) try {
Data.resize(config.arraySize);
std::generate(Data.begin(), Data.end(), [&]() { return dis(gen); });
// Run distributed sort
if (mpi.rank() == 0)
logger << "Starting distributed sorting ... ";
Ttotal.start();
@@ -192,9 +197,9 @@ int main(int argc, char* argv[]) try {
Ttotal.stop();
if (mpi.rank() == 0)
logger << " Done." << logger.endl;
std::string timeMsg = "rank " + std::to_string(mpi.rank());
// Print-outs and validation
if (config.perf) {
Ttotal.print_duration("Total ", mpi.rank());
TfullSort.print_duration("Full-Sort ", mpi.rank());
@@ -224,6 +229,9 @@ catch (std::exception& e) {
#include <gtest/gtest.h>
#include <exception>
/*!
* The testing version of our program
*/
GTEST_API_ int main(int argc, char **argv) try {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();