Skip to content

Commit 6c7fcc7

Browse files
committed
Merge branch 'master' into an/remove_boost
2 parents 9a81e25 + d48543e commit 6c7fcc7

File tree

7 files changed

+71
-42
lines changed

7 files changed

+71
-42
lines changed

scripts/variants_generation.py

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,63 @@
11
import csv
22
import numpy as np
33
from xlsxwriter.workbook import Workbook
4+
from pathlib import Path
45

5-
NUM_TASKS = 3
6-
NUM_STUDENTS = 29
7-
NUM_VARIANTS = 27
8-
csv_file = 'variants.csv'
9-
10-
list_of_tasks = []
11-
str_of_print = ""
12-
str_of_headers = ""
13-
for i in range(NUM_TASKS):
14-
list_of_variants = []
15-
shuffled_list_of_variants = []
16-
for j in range(int(NUM_STUDENTS / NUM_VARIANTS) + 1):
17-
list_of_variants.append(np.arange(NUM_VARIANTS) + 1)
18-
for variant in list_of_variants:
19-
np.random.shuffle(variant)
20-
shuffled_list_of_variants.append(variant)
21-
result_variants = np.concatenate(shuffled_list_of_variants)
22-
list_of_tasks.append(result_variants[:NUM_STUDENTS])
23-
str_of_print += '%d,'
24-
str_of_headers += 'Task ' + str(i + 1) + ','
25-
str_of_print = str_of_print[:-1]
26-
str_of_headers = str_of_headers[:-1]
27-
28-
np.savetxt(csv_file, np.dstack(list_of_tasks)[0], str_of_print, header=str_of_headers)
29-
30-
workbook = Workbook(csv_file[:-4] + '.xlsx')
31-
worksheet = workbook.add_worksheet()
32-
with open(csv_file, 'rt') as f:
33-
reader = csv.reader(f)
34-
for r, row in enumerate(reader):
35-
for c, col in enumerate(row):
36-
worksheet.write(r, c, col)
37-
workbook.close()
6+
7+
def get_project_path():
8+
script_path = Path(__file__).resolve() # Absolute path of the script
9+
script_dir = script_path.parent # Directory containing the script
10+
return script_dir.parent
11+
12+
13+
def generate_group_table(_num_tasks, _num_students, _num_variants, _csv_file):
14+
if _num_tasks != len(_num_variants):
15+
raise Exception(f"Count of students: {_num_tasks} != count of list of variants: {len(_num_variants)}")
16+
17+
list_of_tasks = []
18+
str_of_print = ""
19+
str_of_headers = ""
20+
for i, num_v in zip(range(_num_tasks), _num_variants):
21+
list_of_variants = []
22+
shuffled_list_of_variants = []
23+
for j in range(int(_num_students / num_v) + 1):
24+
list_of_variants.append(np.arange(num_v) + 1)
25+
for variant in list_of_variants:
26+
np.random.shuffle(variant)
27+
shuffled_list_of_variants.append(variant)
28+
result_variants = np.concatenate(shuffled_list_of_variants)
29+
list_of_tasks.append(result_variants[:_num_students])
30+
str_of_print += '%d,'
31+
str_of_headers += 'Task ' + str(i + 1) + ','
32+
str_of_print = str_of_print[:-1]
33+
str_of_headers = str_of_headers[:-1]
34+
35+
np.savetxt(_csv_file, np.dstack(list_of_tasks)[0], str_of_print, header=str_of_headers)
36+
37+
workbook = Workbook(_csv_file[:-4] + '.xlsx')
38+
worksheet = workbook.add_worksheet()
39+
with open(_csv_file, 'rt') as f:
40+
reader = csv.reader(f)
41+
for r, row in enumerate(reader):
42+
for c, col in enumerate(row):
43+
worksheet.write(r, c, col)
44+
workbook.close()
45+
46+
47+
if __name__ == "__main__":
48+
# Define the number of tasks
49+
num_tasks = 3
50+
51+
# List containing the number of students for each task
52+
list_students = [29, 10, 40]
53+
54+
# List containing the number of variants (versions) for each task
55+
num_variants = [27, 2, 9]
56+
57+
# Overall, `path_to_results` represents the file path leading to a csv's and xlsx's directory
58+
path_to_results = Path(get_project_path()) / "build" / "variants_results"
59+
path_to_results.mkdir(parents=True, exist_ok=True)
60+
61+
for num_students, index in zip(list_students, range(len(list_students))):
62+
csv_path = path_to_results / f'variants_group_{index + 1}.csv'
63+
generate_group_table(num_tasks, num_students, num_variants, csv_path.as_posix())

tasks/all/example/perf_tests/perf_all.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <gtest/gtest.h>
2+
#include <mpi.h>
23

34
#include <chrono>
45
#include <cstddef>
56
#include <cstdint>
67
#include <memory>
7-
#include <mpi.h>
88
#include <vector>
99

1010
#include "all/example/include/ops_all.hpp"

tasks/all/example/src/ops_all.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#include "all/example/include/ops_all.hpp"
22

3-
#include "core/util/include/util.hpp"
4-
#include "oneapi/tbb/task_arena.h"
5-
#include "oneapi/tbb/task_group.h"
3+
#include <mpi.h>
4+
65
#include <cmath>
76
#include <cstddef>
87
#include <functional>
9-
#include <mpi.h>
108
#include <thread>
119
#include <vector>
1210

11+
#include "core/util/include/util.hpp"
12+
#include "oneapi/tbb/task_arena.h"
13+
#include "oneapi/tbb/task_group.h"
14+
1315
namespace {
1416
void MatMul(const std::vector<int> &in_vec, int rc_size, std::vector<int> &out_vec) {
1517
for (int i = 0; i < rc_size; ++i) {

tasks/all/runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <gtest/gtest.h>
2+
#include <mpi.h>
23
#include <tbb/global_control.h>
34

45
#include <cstdio>
56
#include <cstdlib>
67
#include <memory>
7-
#include <mpi.h>
88
#include <string>
99
#include <utility>
1010

tasks/mpi/example/perf_tests/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <gtest/gtest.h>
2+
#include <mpi.h>
23

34
#include <chrono>
45
#include <cstddef>
56
#include <cstdint>
67
#include <memory>
7-
#include <mpi.h>
88
#include <vector>
99

1010
#include "core/perf/include/perf.hpp"

tasks/mpi/example/src/ops_mpi.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "mpi/example/include/ops_mpi.hpp"
22

3+
#include <mpi.h>
4+
35
#include <cmath>
46
#include <cstddef>
5-
#include <mpi.h>
67
#include <vector>
78

89
bool nesterov_a_test_task_mpi::TestTaskMPI::PreProcessingImpl() {

tasks/mpi/runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <gtest/gtest.h>
2+
#include <mpi.h>
23

34
#include <cstdio>
45
#include <cstdlib>
56
#include <memory>
6-
#include <mpi.h>
77
#include <string>
88
#include <utility>
99

0 commit comments

Comments
 (0)