HW2: Add the rest of the report (w/o the prof)
This commit is contained in:
@@ -12,6 +12,17 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/*
|
||||
* Versioning:
|
||||
* - RC1: Model version
|
||||
* - RC2: Parallel full sort
|
||||
* - RC3: Vanila
|
||||
* - RC3a: Exchange optimization
|
||||
* - RC3b: MPI Pipeline
|
||||
* - RC4: Include all version
|
||||
*/
|
||||
static constexpr char version[] = "0.4";
|
||||
|
||||
/*
|
||||
* Defines for different version of the exercise
|
||||
*/
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
/*
|
||||
* Exported timers
|
||||
*/
|
||||
extern Timing Ttotal;
|
||||
extern Timing TfullSort;
|
||||
extern Timing Texchange;
|
||||
extern Timing Tminmax;
|
||||
extern Timing TelbowSort;
|
||||
extern Timing Timer_total;
|
||||
extern Timing Timer_fullSort;
|
||||
extern Timing Timer_exchange;
|
||||
extern Timing Timer_minmax;
|
||||
extern Timing Timer_elbowSort;
|
||||
|
||||
|
||||
/*!
|
||||
@@ -257,7 +257,7 @@ void elbowSort(ShadowedDataT& data, bool ascending) noexcept {
|
||||
*/
|
||||
template<typename StatT>
|
||||
bool needsExchange(const StatT& lstat, StatT& rstat, mpi_id_t part, int tag, bool keepSmall) {
|
||||
timeCall(Texchange, mpi.exchange_it, lstat, rstat, part, tag);
|
||||
timeCall(Timer_exchange, mpi.exchange_it, lstat, rstat, part, tag);
|
||||
return (keepSmall) ?
|
||||
rstat.min < lstat.max // Lmin: rstat.min - Smax: lstat.max
|
||||
: lstat.min < rstat.max; // Lmin: lstat.min - Smax: rstat.max
|
||||
@@ -351,25 +351,25 @@ void exchange(ShadowedDataT& data, mpi_id_t partner, bool keepSmall, int tag) {
|
||||
|
||||
if (config.pipeline > 1) {
|
||||
// Pipeline case - use async MPI
|
||||
Texchange.start();
|
||||
Timer_exchange.start();
|
||||
mpi.exchange_start(active, shadow, count, partner, tag);
|
||||
for (size_t stage = 0; stage < config.pipeline; active += count, shadow += count) {
|
||||
// Wait previous chunk
|
||||
mpi.exchange_wait();
|
||||
Texchange.stop();
|
||||
Timer_exchange.stop();
|
||||
if (++stage < config.pipeline) {
|
||||
// Start next chunk if there is a next one
|
||||
Texchange.start();
|
||||
Timer_exchange.start();
|
||||
mpi.exchange_start(active + count, shadow + count, count, partner, ++tag);
|
||||
}
|
||||
// process the arrived data
|
||||
timeCall(Tminmax, keepMinOrMax, active, shadow, count, keepSmall);
|
||||
timeCall(Timer_minmax, keepMinOrMax, active, shadow, count, keepSmall);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No pipeline - use blocking MPI
|
||||
timeCall(Texchange, mpi.exchange, active, shadow, count, partner, tag);
|
||||
timeCall(Tminmax, keepMinOrMax, active, shadow, count, keepSmall);
|
||||
timeCall(Timer_exchange, mpi.exchange, active, shadow, count, partner, tag);
|
||||
timeCall(Timer_minmax, keepMinOrMax, active, shadow, count, keepSmall);
|
||||
}
|
||||
if (config.exchangeOpt)
|
||||
updateMinMax(localStat, data);
|
||||
@@ -390,7 +390,7 @@ void exchange(ShadowedDataT& data, mpi_id_t partner, bool keepSmall, int tag) {
|
||||
template<typename ShadowedDataT>
|
||||
void distBubbletonic(ShadowedDataT& data, mpi_id_t Processes, mpi_id_t rank) {
|
||||
// Initially sort to create a half part of a bitonic sequence
|
||||
timeCall(TfullSort, fullSort, data, ascending<SortMode::Bubbletonic>(rank, 0));
|
||||
timeCall(Timer_fullSort, fullSort, data, ascending<SortMode::Bubbletonic>(rank, 0));
|
||||
|
||||
// Sort network (O(N) iterations)
|
||||
for (size_t step = 0; step < static_cast<size_t>(Processes); ++step) {
|
||||
@@ -403,7 +403,7 @@ void distBubbletonic(ShadowedDataT& data, mpi_id_t Processes, mpi_id_t rank) {
|
||||
int tag = static_cast<int>(tagGenerator(0, step));
|
||||
if (!config.exchangeOpt || needsExchange(localStat, remoteStat, part, tag++, ks)) {
|
||||
exchange(data, part, ks, tag);
|
||||
timeCall(TelbowSort, elbowSort, data, ascending<SortMode::Bubbletonic>(rank, Processes));
|
||||
timeCall(Timer_elbowSort, elbowSort, data, ascending<SortMode::Bubbletonic>(rank, Processes));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -430,7 +430,7 @@ void distBubbletonic(ShadowedDataT& data, mpi_id_t Processes, mpi_id_t rank) {
|
||||
template<typename ShadowedDataT>
|
||||
void distBitonic(ShadowedDataT& data, mpi_id_t Processes, mpi_id_t rank) {
|
||||
// Initially sort to create a half part of a bitonic sequence
|
||||
timeCall(TfullSort, fullSort, data, ascending<SortMode::Bitonic>(rank, 0));
|
||||
timeCall(Timer_fullSort, fullSort, data, ascending<SortMode::Bitonic>(rank, 0));
|
||||
|
||||
// Run through sort network using elbow-sort ( O(LogN * LogN) iterations )
|
||||
auto p = static_cast<uint32_t>(std::log2(Processes));
|
||||
@@ -447,7 +447,7 @@ void distBitonic(ShadowedDataT& data, mpi_id_t Processes, mpi_id_t rank) {
|
||||
}
|
||||
}
|
||||
// sort - O(N)
|
||||
timeCall(TelbowSort, elbowSort, data, ascending<SortMode::Bitonic>(rank, depth));
|
||||
timeCall(Timer_elbowSort, elbowSort, data, ascending<SortMode::Bitonic>(rank, depth));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user