Skip to content

Commit 2e4e052

Browse files
committed
architecture
1 parent 8ad7dae commit 2e4e052

18 files changed

+1014
-1459
lines changed

include/osp/auxiliary/io/arch_file_reader.hpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ limitations under the License.
1818

1919
#pragma once
2020

21+
#include "osp/bsp/model/BspArchitecture.hpp"
2122
#include <fstream>
2223
#include <iostream>
2324
#include <sstream>
24-
#include "osp/bsp/model/BspArchitecture.hpp"
2525

2626
namespace osp { namespace file_reader {
2727

@@ -31,7 +31,8 @@ bool readBspArchitecture(std::ifstream &infile, BspArchitecture<Graph_t> &archit
3131

3232
// Skip comment lines
3333
while (std::getline(infile, line)) {
34-
if (!line.empty() && line[0] != '%') break;
34+
if (!line.empty() && line[0] != '%')
35+
break;
3536
}
3637

3738
// Parse architecture parameters
@@ -58,24 +59,24 @@ bool readBspArchitecture(std::ifstream &infile, BspArchitecture<Graph_t> &archit
5859
if (0 <= mem_type && mem_type <= 3) {
5960
using memw_t = v_memw_t<Graph_t>;
6061
switch (mem_type) {
61-
case 0:
62-
architecture.setMemoryConstraintType(MEMORY_CONSTRAINT_TYPE::NONE);
63-
break;
64-
case 1:
65-
architecture.setMemoryConstraintType(MEMORY_CONSTRAINT_TYPE::LOCAL);
66-
architecture.setMemoryBound(static_cast<memw_t>(M));
67-
break;
68-
case 2:
69-
architecture.setMemoryConstraintType(MEMORY_CONSTRAINT_TYPE::GLOBAL);
70-
architecture.setMemoryBound(static_cast<memw_t>(M));
71-
break;
72-
case 3:
73-
architecture.setMemoryConstraintType(MEMORY_CONSTRAINT_TYPE::PERSISTENT_AND_TRANSIENT);
74-
architecture.setMemoryBound(static_cast<memw_t>(M));
75-
break;
76-
default:
77-
std::cerr << "Invalid memory type.\n";
78-
return false;
62+
case 0:
63+
architecture.setMemoryConstraintType(MEMORY_CONSTRAINT_TYPE::NONE);
64+
break;
65+
case 1:
66+
architecture.setMemoryConstraintType(MEMORY_CONSTRAINT_TYPE::LOCAL);
67+
architecture.setMemoryBound(static_cast<memw_t>(M));
68+
break;
69+
case 2:
70+
architecture.setMemoryConstraintType(MEMORY_CONSTRAINT_TYPE::GLOBAL);
71+
architecture.setMemoryBound(static_cast<memw_t>(M));
72+
break;
73+
case 3:
74+
architecture.setMemoryConstraintType(MEMORY_CONSTRAINT_TYPE::PERSISTENT_AND_TRANSIENT);
75+
architecture.setMemoryBound(static_cast<memw_t>(M));
76+
break;
77+
default:
78+
std::cerr << "Invalid memory type.\n";
79+
return false;
7980
}
8081
} else if (mem_type == -1) {
8182
std::cout << "No memory type specified. Assuming \"NONE\".\n";
@@ -116,7 +117,7 @@ bool readBspArchitecture(std::ifstream &infile, BspArchitecture<Graph_t> &archit
116117
return false;
117118
}
118119

119-
architecture.setSendCosts(fromProc, toProc, static_cast<v_commw_t<Graph_t>>(value));
120+
architecture.SetSendCosts(fromProc, toProc, static_cast<v_commw_t<Graph_t>>(value));
120121
}
121122

122123
// Ensure there are no remaining non-comment lines
@@ -127,7 +128,6 @@ bool readBspArchitecture(std::ifstream &infile, BspArchitecture<Graph_t> &archit
127128
}
128129
}
129130

130-
architecture.computeCommAverage();
131131
return true;
132132
}
133133

include/osp/bsp/model/BspArchitecture.hpp

Lines changed: 346 additions & 317 deletions
Large diffs are not rendered by default.

include/osp/bsp/model/BspInstance.hpp

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ limitations under the License.
2727

2828
namespace osp {
2929

30-
enum class RETURN_STATUS { OSP_SUCCESS, BEST_FOUND, TIMEOUT, ERROR };
30+
enum class RETURN_STATUS { OSP_SUCCESS,
31+
BEST_FOUND,
32+
TIMEOUT,
33+
ERROR };
3134

3235
inline std::string to_string(const RETURN_STATUS status) {
3336
switch (status) {
@@ -44,13 +47,23 @@ inline std::string to_string(const RETURN_STATUS status) {
4447
}
4548
}
4649

47-
inline std::ostream& operator<<(std::ostream& os, RETURN_STATUS status) {
50+
inline std::ostream &operator<<(std::ostream &os, RETURN_STATUS status) {
4851
switch (status) {
49-
case RETURN_STATUS::OSP_SUCCESS: os << "SUCCESS"; break;
50-
case RETURN_STATUS::BEST_FOUND: os << "BEST_FOUND"; break;
51-
case RETURN_STATUS::TIMEOUT: os << "TIMEOUT"; break;
52-
case RETURN_STATUS::ERROR: os << "ERROR"; break;
53-
default: os << "UNKNOWN"; break;
52+
case RETURN_STATUS::OSP_SUCCESS:
53+
os << "SUCCESS";
54+
break;
55+
case RETURN_STATUS::BEST_FOUND:
56+
os << "BEST_FOUND";
57+
break;
58+
case RETURN_STATUS::TIMEOUT:
59+
os << "TIMEOUT";
60+
break;
61+
case RETURN_STATUS::ERROR:
62+
os << "ERROR";
63+
break;
64+
default:
65+
os << "UNKNOWN";
66+
break;
5467
}
5568
return os;
5669
}
@@ -389,53 +402,48 @@ class BspInstance {
389402
};
390403

391404
template<typename Graph_t>
392-
class compatible_processor_range {
405+
class CompatibleProcessorRange {
393406

394407
std::vector<std::vector<unsigned>> type_processor_idx;
395408
const BspInstance<Graph_t> *instance = nullptr;
396409

397-
public:
410+
public:
411+
CompatibleProcessorRange() = default;
398412

399-
compatible_processor_range() = default;
400-
401-
compatible_processor_range(const BspInstance<Graph_t> &inst) {
413+
CompatibleProcessorRange(const BspInstance<Graph_t> &inst) {
402414
initialize(inst);
403415
}
404-
416+
405417
inline void initialize(const BspInstance<Graph_t> &inst) {
406418

407419
instance = &inst;
408420

409-
if constexpr (has_typed_vertices_v<Graph_t>) {
410-
421+
if constexpr (has_typed_vertices_v<Graph_t>) {
422+
411423
type_processor_idx = std::vector<std::vector<unsigned>>(inst.getComputationalDag().num_vertex_types());
412424

413425
for (v_type_t<Graph_t> v_type = 0; v_type < inst.getComputationalDag().num_vertex_types(); v_type++) {
414-
for (unsigned proc = 0; proc < inst.numberOfProcessors(); proc++)
415-
if (inst.isCompatibleType(v_type, inst.processorType(proc)))
416-
type_processor_idx[v_type].push_back(proc);
417-
426+
for (unsigned proc = 0; proc < inst.numberOfProcessors(); proc++)
427+
if (inst.isCompatibleType(v_type, inst.processorType(proc)))
428+
type_processor_idx[v_type].push_back(proc);
418429
}
419-
}
430+
}
420431
}
421432

422-
inline const auto & compatible_processors_type(v_type_t<Graph_t> type) const {
433+
inline const auto &compatible_processors_type(v_type_t<Graph_t> type) const {
423434

424435
assert(instance != nullptr);
425436

426437
if constexpr (has_typed_vertices_v<Graph_t>) {
427-
return type_processor_idx[type];
438+
return type_processor_idx[type];
428439
} else {
429440
return instance->processors();
430441
}
431442
}
432443

433-
inline const auto & compatible_processors_vertex(vertex_idx_t<Graph_t> vertex) const {
444+
inline const auto &compatible_processors_vertex(vertex_idx_t<Graph_t> vertex) const {
434445
return compatible_processors_type(instance->getComputationalDag().vertex_type(vertex));
435446
}
436-
437-
438447
};
439448

440-
441449
} // namespace osp

include/osp/bsp/scheduler/GreedySchedulers/GrowLocalAutoCoresParallel.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ limitations under the License.
3939

4040
namespace osp {
4141

42+
static constexpr unsigned CacheLineSize = 64;
43+
4244
template<typename vert_t, typename weight_t>
4345
struct GrowLocalAutoCoresParallel_Params {
4446
vert_t minSuperstepSize = 20;

include/osp/bsp/scheduler/LocalSearch/KernighanLin_v2/comm_cost_modules/kl_bsp_comm_cost.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct kl_bsp_comm_cost_function {
9797
constexpr static bool is_max_comm_cost_function = true;
9898

9999
kl_active_schedule<Graph_t, cost_t, MemoryConstraint_t> *active_schedule;
100-
compatible_processor_range<Graph_t> *proc_range;
100+
CompatibleProcessorRange<Graph_t> *proc_range;
101101
const Graph_t *graph;
102102
const BspInstance<Graph_t> *instance;
103103

@@ -119,7 +119,7 @@ struct kl_bsp_comm_cost_function {
119119
}
120120

121121
void initialize(kl_active_schedule<Graph_t, cost_t, MemoryConstraint_t> &sched,
122-
compatible_processor_range<Graph_t> &p_range) {
122+
CompatibleProcessorRange<Graph_t> &p_range) {
123123
active_schedule = &sched;
124124
proc_range = &p_range;
125125
instance = &sched.getInstance();

0 commit comments

Comments
 (0)