Skip to content

Commit bb8a044

Browse files
committed
Refactor runners directory and add ASAN-specific handling
Moved runner files from 'tasks/runners' to 'tasks/common/runners' for better organization. Added conditional handling for AddressSanitizer (ASAN) runs by defining `USE_ASAN` based on environment configuration. Adjusted MPI initialization and threading controls accordingly for improved flexibility.
1 parent 198cea9 commit bb8a044

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

cmake/configure.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ if (APPLE)
66
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG TRUE)
77
endif(APPLE)
88

9+
if(DEFINED ENV{PPC_ASAN_RUN} AND "$ENV{PPC_ASAN_RUN}" STREQUAL "1")
10+
add_compile_definitions(USE_ASAN)
11+
endif()
12+
913
if (NOT CMAKE_BUILD_TYPE)
1014
set(CMAKE_BUILD_TYPE "Release")
1115
endif(NOT CMAKE_BUILD_TYPE)

tasks/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ set(exec_perf_tests "ppc_perf_tests")
77
# Init func tests executable files
88
set(list_of_exec_tests "")
99
if (USE_FUNC_TESTS)
10-
add_executable(${exec_func_tests} "${CMAKE_CURRENT_SOURCE_DIR}/runners/functional.cpp")
10+
add_executable(${exec_func_tests} "${CMAKE_CURRENT_SOURCE_DIR}/common/runners/functional.cpp")
1111
list(APPEND list_of_exec_tests ${exec_func_tests})
1212
endif (USE_FUNC_TESTS)
1313

1414
# Init perf tests executable files
1515
if (USE_PERF_TESTS)
16-
add_executable(${exec_perf_tests} "${CMAKE_CURRENT_SOURCE_DIR}/runners/performance.cpp")
16+
add_executable(${exec_perf_tests} "${CMAKE_CURRENT_SOURCE_DIR}/common/runners/performance.cpp")
1717
list(APPEND list_of_exec_tests ${exec_perf_tests})
1818
endif (USE_PERF_TESTS)
1919

2020
SUBDIRLIST(subdirs ${CMAKE_CURRENT_LIST_DIR})
2121
foreach(subd ${subdirs})
22-
if (subd STREQUAL "runners")
22+
if (subd STREQUAL "common")
2323
continue()
2424
endif ()
2525
add_subdirectory(${subd})
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class WorkerTestFailurePrinter : public ::testing::EmptyTestEventListener {
7171
};
7272

7373
int main(int argc, char** argv) {
74+
#ifndef USE_ASAN
7475
MPI_Init(&argc, &argv);
7576

7677
// Limit the number of threads in TBB
@@ -92,4 +93,13 @@ int main(int argc, char** argv) {
9293

9394
MPI_Finalize();
9495
return status;
96+
#else
97+
// Limit the number of threads in TBB
98+
tbb::global_control control(tbb::global_control::max_allowed_parallelism, ppc::util::GetNumThreads());
99+
// Limit the number of threads in OMP
100+
omp_set_num_threads(ppc::util::GetNumThreads());
101+
102+
::testing::InitGoogleTest(&argc, argv);
103+
return RUN_ALL_TESTS();
104+
#endif
95105
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class WorkerTestFailurePrinter : public ::testing::EmptyTestEventListener {
7171
};
7272

7373
int main(int argc, char** argv) {
74+
#ifndef USE_ASAN
7475
MPI_Init(&argc, &argv);
7576

7677
// Limit the number of threads in TBB
@@ -92,4 +93,13 @@ int main(int argc, char** argv) {
9293

9394
MPI_Finalize();
9495
return status;
96+
#else
97+
// Limit the number of threads in TBB
98+
tbb::global_control control(tbb::global_control::max_allowed_parallelism, ppc::util::GetNumThreads());
99+
// Limit the number of threads in OMP
100+
omp_set_num_threads(ppc::util::GetNumThreads());
101+
102+
::testing::InitGoogleTest(&argc, argv);
103+
return RUN_ALL_TESTS();
104+
#endif
95105
}

0 commit comments

Comments
 (0)