Skip to content

Commit 6194d70

Browse files
BspSchedule, cost function revision (#52)
* clang-format * bsp cost models update added isValid revised schedules metagreedy unit test unit tests * documentation * renaming methods * small edits * moved compute_lazy_communication_costs * algorithm updates to new cost model (+sync & other fixes) --------- Co-authored-by: ppapp <[email protected]>
1 parent 82c972f commit 6194d70

27 files changed

+1471
-1146
lines changed

.clang-format

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ BreakConstructorInitializersBeforeComma: false
5050
BreakConstructorInitializers: BeforeColon
5151
BreakAfterJavaFieldAnnotations: false
5252
BreakStringLiterals: true
53-
ColumnLimit: 120
53+
ColumnLimit: 0
5454
CommentPragmas: '^ IWYU pragma:'
5555
CompactNamespaces: true
5656
ConstructorInitializerAllOnOneLineOrOnePerLine: false
@@ -134,4 +134,3 @@ TabWidth: 8
134134
UseCRLF: false
135135
UseTab: Never
136136
...
137-

.githooks/pre-commit

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,24 @@ fi
4747

4848

4949
# Format all .cpp and .hpp files
50-
for file in $(git diff --cached --name-only | grep -E '\.cpp$|\.hpp$'); do
51-
# Check if the file exists
52-
if [ ! -f $file ]; then
53-
continue
50+
# We use 'git diff-index' to avoid issues with spaces in filenames
51+
git diff --cached --name-only --diff-filter=ACM $against | grep -E '\.(cpp|hpp)$' | while read -r file; do
52+
if [ -f "$file" ]; then
53+
# Apply clang-format in-place
54+
clang-format -i "$file"
55+
# Re-add the file to the commit to include the formatting changes
56+
git add "$file"
5457
fi
55-
git add $file
5658
done
5759

58-
# Remove trailing whitespace from all files (except .so)
59-
for file in $(git diff --cached --name-only | grep -vE '\.so$'); do
60-
# Check if the file exists
61-
if [ ! -f $file ]; then
62-
continue
60+
# Remove trailing whitespace from all files (except .so and binary files)
61+
# Using sed to remove trailing whitespace
62+
git diff --cached --name-only --diff-filter=ACM $against | grep -vE '\.so$' | while read -r file; do
63+
if [ -f "$file" ]; then
64+
# Check if file is text to avoid corrupting binaries
65+
if file "$file" | grep -q "text"; then
66+
sed -i 's/[[:space:]]*$//' "$file"
67+
git add "$file"
68+
fi
6369
fi
64-
git add $file
6570
done
66-
67-
for file in $(git diff --cached --name-only); do
68-
# Check if the file exists
69-
if [ ! -f $file ]; then
70-
continue
71-
fi
72-
git add $file
73-
done
74-

apps/test_suite_runner/StatsModules/BspCommStatsModule.hpp

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

1919
#pragma once
2020

21-
#include <string>
22-
#include <vector>
23-
#include <map>
2421
#include "IStatsModule.hpp"
2522
#include "osp/bsp/model/BspSchedule.hpp" // Still needed
23+
#include "osp/bsp/model/cost/BufferedSendingCost.hpp"
24+
#include "osp/bsp/model/cost/TotalCommunicationCost.hpp"
25+
#include "osp/bsp/model/cost/TotalLambdaCommunicationCost.hpp"
26+
#include <map>
27+
#include <string>
28+
#include <vector>
2629

2730
namespace osp {
2831

2932
template<typename Graph_t>
30-
class BspCommStatsModule : public IStatisticModule<BspSchedule<Graph_t>> {
31-
public:
32-
33-
private:
33+
class BspCommStatsModule : public IStatisticModule<BspSchedule<Graph_t>> {
34+
public:
35+
private:
3436
const std::vector<std::string> metric_headers = {
35-
"TotalCommCost", "TotalLambdaCommCost", "BufferedSendingCosts"
36-
};
37-
38-
public:
37+
"TotalCommCost", "TotalLambdaCommCost", "BufferedSendingCosts"};
3938

39+
public:
4040
std::vector<std::string> get_metric_headers() const override {
4141
return metric_headers;
4242
}
4343

4444
std::map<std::string, std::string> record_statistics(
45-
const BspSchedule<Graph_t>& schedule,
46-
std::ofstream& /*log_stream*/) const override {
45+
const BspSchedule<Graph_t> &schedule,
46+
std::ofstream & /*log_stream*/) const override {
4747
std::map<std::string, std::string> stats;
48-
stats["TotalCommCost"] = std::to_string(schedule.computeTotalCosts());
49-
stats["TotalLambdaCommCost"] = std::to_string(schedule.computeTotalLambdaCosts());
50-
stats["BufferedSendingCosts"] = std::to_string(schedule.computeBufferedSendingCosts());
48+
stats["TotalCommCost"] = std::to_string(TotalCommunicationCost<Graph_t>()(schedule));
49+
stats["TotalLambdaCommCost"] = std::to_string(TotalLambdaCommunicationCost<Graph_t>()(schedule));
50+
stats["BufferedSendingCosts"] = std::to_string(BufferedSendingCost<Graph_t>()(schedule));
5151
return stats;
5252
}
5353
};

0 commit comments

Comments
 (0)