Skip to content

Commit 9a81e25

Browse files
committed
revert to classic mpi
1 parent 996f688 commit 9a81e25

File tree

12 files changed

+99
-101
lines changed

12 files changed

+99
-101
lines changed

cmake/boost.cmake

Lines changed: 0 additions & 24 deletions
This file was deleted.

cmake/mpi.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ if( USE_MPI )
66
else( MPI_FOUND )
77
set( USE_MPI OFF )
88
endif( MPI_FOUND )
9-
include(cmake/boost.cmake)
109
endif( USE_MPI )

modules/core/task/src/task.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ void ppc::core::Task::InternalOrderTest(const std::string& str) {
6060
auto end = std::chrono::high_resolution_clock::now();
6161
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(end - tmp_time_point_).count();
6262
auto current_time = static_cast<double>(duration) * 1e-9;
63+
std::stringstream err_msg;
6364
if (current_time < max_test_time_) {
64-
std::cout << "Test time:" << std::fixed << std::setprecision(10) << current_time;
65+
err_msg << "Test time:" << std::fixed << std::setprecision(10) << current_time;
6566
} else {
66-
std::stringstream err_msg;
6767
err_msg << "\nTask execute time need to be: ";
6868
err_msg << "time < " << max_test_time_ << " secs.\n";
6969
err_msg << "Original time in secs: " << current_time << '\n';

tasks/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ foreach(TASK_TYPE ${LIST_OF_TASKS})
105105
set_target_properties(${EXEC_FUNC} PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
106106
endif( MPI_LINK_FLAGS )
107107
target_link_libraries(${EXEC_FUNC} PUBLIC ${MPI_LIBRARIES})
108-
109-
add_dependencies(${EXEC_FUNC} ppc_boost)
110-
target_link_directories(${EXEC_FUNC} PUBLIC ${CMAKE_BINARY_DIR}/ppc_boost/install/lib)
111-
if (NOT MSVC)
112-
target_link_libraries(${EXEC_FUNC} PUBLIC boost_mpi boost_serialization)
113-
endif ()
114108
elseif ("${MODULE_NAME}" STREQUAL "tbb")
115109
add_dependencies(${EXEC_FUNC} ppc_onetbb)
116110
target_link_directories(${EXEC_FUNC} PUBLIC ${CMAKE_BINARY_DIR}/ppc_onetbb/install/lib)
@@ -129,12 +123,6 @@ foreach(TASK_TYPE ${LIST_OF_TASKS})
129123
endif( MPI_LINK_FLAGS )
130124
target_link_libraries(${EXEC_FUNC} PUBLIC ${MPI_LIBRARIES})
131125

132-
add_dependencies(${EXEC_FUNC} ppc_boost)
133-
target_link_directories(${EXEC_FUNC} PUBLIC ${CMAKE_BINARY_DIR}/ppc_boost/install/lib)
134-
if (NOT MSVC)
135-
target_link_libraries(${EXEC_FUNC} PUBLIC boost_mpi boost_serialization)
136-
endif ()
137-
138126
add_dependencies(${EXEC_FUNC} ppc_onetbb)
139127
target_link_directories(${EXEC_FUNC} PUBLIC ${CMAKE_BINARY_DIR}/ppc_onetbb/install/lib)
140128
if(NOT MSVC)

tasks/all/example/include/ops_all.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include <boost/mpi/collectives.hpp>
4-
#include <boost/mpi/communicator.hpp>
53
#include <utility>
64
#include <vector>
75

@@ -20,7 +18,6 @@ class TestTaskALL : public ppc::core::Task {
2018
private:
2119
std::vector<int> input_, output_;
2220
int rc_size_{};
23-
boost::mpi::communicator world_;
2421
};
2522

26-
} // namespace nesterov_a_test_task_all
23+
} // namespace nesterov_a_test_task_all

tasks/all/example/perf_tests/perf_all.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include <cstddef>
55
#include <cstdint>
66
#include <memory>
7+
#include <mpi.h>
78
#include <vector>
89

910
#include "all/example/include/ops_all.hpp"
10-
#include "boost/mpi/communicator.hpp"
1111
#include "core/perf/include/perf.hpp"
1212
#include "core/task/include/task.hpp"
1313

@@ -48,8 +48,9 @@ TEST(nesterov_a_test_task_all, test_pipeline_run) {
4848
auto perf_analyzer = std::make_shared<ppc::core::Perf>(test_task_all);
4949
perf_analyzer->PipelineRun(perf_attr, perf_results);
5050
// Create Perf analyzer
51-
boost::mpi::communicator world;
52-
if (world.rank() == 0) {
51+
int rank = -1;
52+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
53+
if (rank == 0) {
5354
ppc::core::Perf::PrintPerfStatistic(perf_results);
5455
}
5556

@@ -94,8 +95,9 @@ TEST(nesterov_a_test_task_all, test_task_run) {
9495
auto perf_analyzer = std::make_shared<ppc::core::Perf>(test_task_all);
9596
perf_analyzer->TaskRun(perf_attr, perf_results);
9697
// Create Perf analyzer
97-
boost::mpi::communicator world;
98-
if (world.rank() == 0) {
98+
int rank = -1;
99+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
100+
if (rank == 0) {
99101
ppc::core::Perf::PrintPerfStatistic(perf_results);
100102
}
101103

tasks/all/example/src/ops_all.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
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"
36
#include <cmath>
47
#include <cstddef>
58
#include <functional>
9+
#include <mpi.h>
610
#include <thread>
711
#include <vector>
812

9-
#include "core/util/include/util.hpp"
10-
#include "oneapi/tbb/task_arena.h"
11-
#include "oneapi/tbb/task_group.h"
12-
1313
namespace {
1414
void MatMul(const std::vector<int> &in_vec, int rc_size, std::vector<int> &out_vec) {
1515
for (int i = 0; i < rc_size; ++i) {
@@ -42,7 +42,9 @@ bool nesterov_a_test_task_all::TestTaskALL::ValidationImpl() {
4242
}
4343

4444
bool nesterov_a_test_task_all::TestTaskALL::RunImpl() {
45-
if (world_.rank() == 0) {
45+
int rank = -1;
46+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
47+
if (rank == 0) {
4648
#pragma omp parallel default(none)
4749
{
4850
#pragma omp critical
@@ -66,7 +68,7 @@ bool nesterov_a_test_task_all::TestTaskALL::RunImpl() {
6668
threads[i].join();
6769
}
6870

69-
world_.barrier();
71+
MPI_Barrier(MPI_COMM_WORLD);
7072
return true;
7173
}
7274

tasks/all/runner.cpp

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#include <gtest/gtest.h>
22
#include <tbb/global_control.h>
33

4-
#include <boost/mpi/communicator.hpp>
5-
#include <boost/mpi/environment.hpp>
64
#include <cstdio>
75
#include <cstdlib>
86
#include <memory>
7+
#include <mpi.h>
98
#include <string>
109
#include <utility>
1110

@@ -14,28 +13,39 @@
1413

1514
class UnreadMessagesDetector : public ::testing::EmptyTestEventListener {
1615
public:
17-
UnreadMessagesDetector(boost::mpi::communicator com) : com_(std::move(com)) {}
16+
UnreadMessagesDetector() = default;
1817

1918
void OnTestEnd(const ::testing::TestInfo& test_info) override {
20-
com_.barrier();
21-
if (const auto msg = com_.iprobe(boost::mpi::any_source, boost::mpi::any_tag)) {
19+
int rank = -1;
20+
int size = -1;
21+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22+
MPI_Comm_size(MPI_COMM_WORLD, &size);
23+
24+
MPI_Barrier(MPI_COMM_WORLD);
25+
26+
int flag = -1;
27+
MPI_Status status;
28+
29+
MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, &status);
30+
31+
if (flag != 0) {
2232
fprintf(
2333
stderr,
2434
"[ PROCESS %d ] [ FAILED ] %s.%s: MPI message queue has an unread message from process %d with tag %d\n",
25-
com_.rank(), test_info.test_suite_name(), test_info.name(), msg->source(), msg->tag());
35+
rank, "test_suite_name", "test_name", status.MPI_SOURCE, status.MPI_TAG);
36+
MPI_Finalize();
2637
exit(2);
2738
}
28-
com_.barrier();
39+
40+
MPI_Barrier(MPI_COMM_WORLD);
2941
}
3042

3143
private:
32-
boost::mpi::communicator com_;
3344
};
3445

3546
class WorkerTestFailurePrinter : public ::testing::EmptyTestEventListener {
3647
public:
37-
WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener> base, boost::mpi::communicator com)
38-
: base_(std::move(base)), com_(std::move(com)) {}
48+
explicit WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener> base) : base_(std::move(base)) {}
3949

4050
void OnTestEnd(const ::testing::TestInfo& test_info) override {
4151
if (test_info.result()->Passed()) {
@@ -54,27 +64,33 @@ class WorkerTestFailurePrinter : public ::testing::EmptyTestEventListener {
5464
}
5565

5666
private:
57-
void PrintProcessRank() const { printf(" [ PROCESS %d ] ", com_.rank()); }
67+
static void PrintProcessRank() {
68+
int rank = -1;
69+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
70+
printf(" [ PROCESS %d ] ", rank);
71+
}
5872

5973
std::shared_ptr<::testing::TestEventListener> base_;
60-
boost::mpi::communicator com_;
6174
};
6275

6376
int main(int argc, char** argv) {
64-
boost::mpi::environment env(argc, argv);
65-
boost::mpi::communicator world;
77+
MPI_Init(&argc, &argv);
6678

6779
// Limit the number of threads in TBB
6880
tbb::global_control control(tbb::global_control::max_allowed_parallelism, ppc::util::GetPPCNumThreads());
6981

7082
::testing::InitGoogleTest(&argc, argv);
7183

7284
auto& listeners = ::testing::UnitTest::GetInstance()->listeners();
73-
if (world.rank() != 0 && (argc < 2 || argv[1] != std::string("--print-workers"))) {
85+
int rank = -1;
86+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
87+
if (rank != 0 && (argc < 2 || argv[1] != std::string("--print-workers"))) {
7488
auto* listener = listeners.Release(listeners.default_result_printer());
75-
listeners.Append(new WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener>(listener), world));
89+
listeners.Append(new WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener>(listener)));
7690
}
77-
listeners.Append(new UnreadMessagesDetector(world));
91+
listeners.Append(new UnreadMessagesDetector());
92+
auto status = RUN_ALL_TESTS();
7893

79-
return RUN_ALL_TESTS();
94+
MPI_Finalize();
95+
return status;
8096
}

tasks/mpi/example/include/ops_mpi.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include <boost/mpi/collectives.hpp>
4-
#include <boost/mpi/communicator.hpp>
53
#include <utility>
64
#include <vector>
75

@@ -20,7 +18,6 @@ class TestTaskMPI : public ppc::core::Task {
2018
private:
2119
std::vector<int> input_, output_;
2220
int rc_size_{};
23-
boost::mpi::communicator world_;
2421
};
2522

26-
} // namespace nesterov_a_test_task_mpi
23+
} // namespace nesterov_a_test_task_mpi

tasks/mpi/example/perf_tests/main.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include <cstddef>
55
#include <cstdint>
66
#include <memory>
7+
#include <mpi.h>
78
#include <vector>
89

9-
#include "boost/mpi/communicator.hpp"
1010
#include "core/perf/include/perf.hpp"
1111
#include "core/task/include/task.hpp"
1212
#include "mpi/example/include/ops_mpi.hpp"
@@ -48,8 +48,9 @@ TEST(nesterov_a_test_task_mpi, test_pipeline_run) {
4848
auto perf_analyzer = std::make_shared<ppc::core::Perf>(test_task_mpi);
4949
perf_analyzer->PipelineRun(perf_attr, perf_results);
5050
// Create Perf analyzer
51-
boost::mpi::communicator world;
52-
if (world.rank() == 0) {
51+
int rank = -1;
52+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
53+
if (rank == 0) {
5354
ppc::core::Perf::PrintPerfStatistic(perf_results);
5455
}
5556

@@ -94,8 +95,9 @@ TEST(nesterov_a_test_task_mpi, test_task_run) {
9495
auto perf_analyzer = std::make_shared<ppc::core::Perf>(test_task_mpi);
9596
perf_analyzer->TaskRun(perf_attr, perf_results);
9697
// Create Perf analyzer
97-
boost::mpi::communicator world;
98-
if (world.rank() == 0) {
98+
int rank = -1;
99+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
100+
if (rank == 0) {
99101
ppc::core::Perf::PrintPerfStatistic(perf_results);
100102
}
101103

0 commit comments

Comments
 (0)