Skip to content

Commit 982225b

Browse files
allnesclaude
andauthored
An/fix win (#316)
<!-- Solution for PR template choice: https://stackoverflow.com/a/75030350/24543008 --> Please go to the `Preview` tab and select the appropriate template: * [Submit Student task (English)](?expand=1&template=task_submission_en.md) * [Submit Student task (Russian)](?expand=1&template=task_submission_ru.md) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f361bfa commit 982225b

10 files changed

Lines changed: 123 additions & 18 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ endif()
77
message( STATUS "Parallel Programming Course (PPC)" )
88
project(parallel_programming_course)
99

10+
if(WIN32)
11+
set(CMAKE_NINJA_FORCE_RESPONSE_FILE ON CACHE BOOL "Force Ninja to use response files.")
12+
endif()
13+
1014
############################ Scoreboard #############################
1115

1216
message( STATUS "PPC step: Setup scoreboard generator" )

cmake/functions.cmake

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,93 @@ function(ppc_configure_subproject SUBDIR)
9595
"${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}")
9696
endforeach()
9797
endfunction()
98+
99+
# Function to configure single subproject as static library
100+
function(ppc_configure_single_subproject SUBDIR)
101+
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}"
102+
OR SUBDIR STREQUAL "common")
103+
return()
104+
endif()
105+
106+
message(STATUS " ${SUBDIR}")
107+
108+
# Create individual library for this task
109+
set(TASK_LIB_NAME "ppc_task_${SUBDIR}")
110+
set(TASK_HAS_SOURCES FALSE)
111+
set(ALL_TASK_SOURCES)
112+
set(ALL_TASK_INCLUDE_DIRS)
113+
114+
# Module-specific compile-time definitions
115+
add_compile_definitions(
116+
PPC_SETTINGS_${SUBDIR}="${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/settings.json"
117+
PPC_ID_${SUBDIR}="${SUBDIR}")
118+
119+
# Switch project context to the subproject
120+
project(${SUBDIR})
121+
122+
# Register functional and performance test runners
123+
set(TEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/tests")
124+
set(TEST_EXECUTABLES "")
125+
add_tests(USE_FUNC_TESTS ${FUNC_TEST_EXEC} functional)
126+
add_tests(USE_PERF_TESTS ${PERF_TEST_EXEC} performance)
127+
128+
# Collect test sources
129+
if(EXISTS "${TEST_DIR}/functional")
130+
file(GLOB_RECURSE FUNC_TEST_SOURCES "${TEST_DIR}/functional/*.cpp")
131+
if(FUNC_TEST_SOURCES)
132+
list(APPEND ALL_TASK_SOURCES ${FUNC_TEST_SOURCES})
133+
set(TASK_HAS_SOURCES TRUE)
134+
endif()
135+
endif()
136+
137+
if(EXISTS "${TEST_DIR}/performance")
138+
file(GLOB_RECURSE PERF_TEST_SOURCES "${TEST_DIR}/performance/*.cpp")
139+
if(PERF_TEST_SOURCES)
140+
list(APPEND ALL_TASK_SOURCES ${PERF_TEST_SOURCES})
141+
set(TASK_HAS_SOURCES TRUE)
142+
endif()
143+
endif()
144+
145+
# Collect implementation sources
146+
foreach(IMPL IN LISTS PPC_IMPLEMENTATIONS)
147+
set(IMP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/${IMPL}")
148+
if(EXISTS "${IMP_DIR}")
149+
file(GLOB_RECURSE IMPL_SOURCES "${IMP_DIR}/src/*.cpp")
150+
if(IMPL_SOURCES)
151+
list(APPEND ALL_TASK_SOURCES ${IMPL_SOURCES})
152+
list(APPEND ALL_TASK_INCLUDE_DIRS "${IMP_DIR}/include")
153+
set(TASK_HAS_SOURCES TRUE)
154+
endif()
155+
endif()
156+
endforeach()
157+
158+
# Create library only if we have sources
159+
if(TASK_HAS_SOURCES)
160+
add_library(${TASK_LIB_NAME} STATIC ${ALL_TASK_SOURCES})
161+
162+
# Set include directories
163+
if(ALL_TASK_INCLUDE_DIRS)
164+
list(REMOVE_DUPLICATES ALL_TASK_INCLUDE_DIRS)
165+
target_include_directories(${TASK_LIB_NAME}
166+
PUBLIC ${ALL_TASK_INCLUDE_DIRS})
167+
endif()
168+
169+
# Set task-specific definitions
170+
target_compile_definitions(
171+
${TASK_LIB_NAME}
172+
PRIVATE
173+
PPC_SETTINGS_${SUBDIR}="${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/settings.json"
174+
PPC_ID_${SUBDIR}="${SUBDIR}")
175+
176+
# Link core module
177+
target_link_libraries(${TASK_LIB_NAME} PUBLIC core_module_lib)
178+
179+
# Link to main executables
180+
if(USE_FUNC_TESTS)
181+
target_link_libraries(${FUNC_TEST_EXEC} PUBLIC ${TASK_LIB_NAME})
182+
endif()
183+
if(USE_PERF_TESTS)
184+
target_link_libraries(${PERF_TEST_EXEC} PUBLIC ${TASK_LIB_NAME})
185+
endif()
186+
endif()
187+
endfunction()

tasks/CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,18 @@ file(
2121
GLOB subdirs
2222
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
2323
"${CMAKE_CURRENT_SOURCE_DIR}/*")
24+
# Filter out non-task directories
25+
set(task_dirs)
2426
foreach(sub IN LISTS subdirs)
25-
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${sub}" AND NOT sub STREQUAL
26-
"common")
27-
ppc_configure_subproject(${sub})
27+
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${sub}" AND NOT sub STREQUAL "common")
28+
list(APPEND task_dirs ${sub})
2829
endif()
30+
endforeach()
31+
32+
# Use single-task libraries for all platforms
33+
message(STATUS "Using single-task library system (${CMAKE_CXX_COMPILER_ID})")
34+
35+
# Configure each task as separate library
36+
foreach(sub IN LISTS task_dirs)
37+
ppc_configure_single_subproject(${sub})
2938
endforeach()

tasks/chaschin_v_max_for_each_row/tests/functional/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ const std::array<TestType, 20> kTestParam = {
8080
std::make_tuple(5, "31"), std::make_tuple(7, "33"), std::make_tuple(1, "35"), std::make_tuple(0, "37")};
8181

8282
const auto kTestTasksList = std::tuple_cat(
83-
ppc::util::AddFuncTask<ChaschinVMaxForEachRow, InType>(kTestParam, PPC_SETTINGS_example_processes),
84-
ppc::util::AddFuncTask<ChaschinVMaxForEachRowSEQ, InType>(kTestParam, PPC_SETTINGS_example_processes));
83+
ppc::util::AddFuncTask<ChaschinVMaxForEachRow, InType>(kTestParam, PPC_SETTINGS_chaschin_v_max_for_each_row),
84+
ppc::util::AddFuncTask<ChaschinVMaxForEachRowSEQ, InType>(kTestParam, PPC_SETTINGS_chaschin_v_max_for_each_row));
8585

8686
const auto kGtestValues = ppc::util::ExpandToValues(kTestTasksList);
8787

tasks/chaschin_v_max_for_each_row/tests/performance/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ TEST_P(ChaschinVRunPerfTestProcesses, RunPerfModes) {
5151
}
5252

5353
const auto kAllPerfTasks = ppc::util::MakeAllPerfTasks<InType, ChaschinVMaxForEachRow, ChaschinVMaxForEachRowSEQ>(
54-
PPC_SETTINGS_example_processes);
54+
PPC_SETTINGS_chaschin_v_max_for_each_row);
5555

5656
const auto kGtestValues = ppc::util::TupleToGTestValues(kAllPerfTasks);
5757

tasks/chaschin_v_sobel_operator/tests/functional/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ const std::array<TestType, 19> kTestParam = {
121121
std::make_tuple(33, "33"), std::make_tuple(35, "35"), std::make_tuple(37, "37")};
122122

123123
const auto kTestTasksList = std::tuple_cat(
124-
ppc::util::AddFuncTask<ChaschinVSobelOperatorMPI, InType>(kTestParam, PPC_SETTINGS_example_processes),
125-
ppc::util::AddFuncTask<ChaschinVSobelOperatorSEQ, InType>(kTestParam, PPC_SETTINGS_example_processes));
124+
ppc::util::AddFuncTask<ChaschinVSobelOperatorMPI, InType>(kTestParam, PPC_SETTINGS_chaschin_v_sobel_operator),
125+
ppc::util::AddFuncTask<ChaschinVSobelOperatorSEQ, InType>(kTestParam, PPC_SETTINGS_chaschin_v_sobel_operator));
126126

127127
const auto kGtestValues = ppc::util::ExpandToValues(kTestTasksList);
128128

tasks/chaschin_v_sobel_operator/tests/performance/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ TEST_P(ChaschinVRunPerfTestProcessesSO, RunPerfModes) {
111111
}
112112

113113
const auto kAllPerfTasks = ppc::util::MakeAllPerfTasks<InType, ChaschinVSobelOperatorMPI, ChaschinVSobelOperatorSEQ>(
114-
PPC_SETTINGS_example_processes);
114+
PPC_SETTINGS_chaschin_v_sobel_operator);
115115

116116
const auto kGtestValues = ppc::util::TupleToGTestValues(kAllPerfTasks);
117117

tasks/dorofeev_i_monte_carlo_integration/tests/functional/main.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ const std::array<TestType, 3> kParams = {
5959
std::make_tuple(20000, "large"),
6060
};
6161

62-
const auto kTaskList = std::tuple_cat(
63-
ppc::util::AddFuncTask<DorofeevIMonteCarloIntegrationSEQ, InType>(kParams, PPC_SETTINGS_example_processes),
64-
ppc::util::AddFuncTask<DorofeevIMonteCarloIntegrationMPI, InType>(kParams, PPC_SETTINGS_example_processes));
62+
const auto kTaskList = std::tuple_cat(ppc::util::AddFuncTask<DorofeevIMonteCarloIntegrationSEQ, InType>(
63+
kParams, PPC_SETTINGS_dorofeev_i_monte_carlo_integration),
64+
ppc::util::AddFuncTask<DorofeevIMonteCarloIntegrationMPI, InType>(
65+
kParams, PPC_SETTINGS_dorofeev_i_monte_carlo_integration));
6566

6667
INSTANTIATE_TEST_SUITE_P(IntegrationTests, MonteCarloFuncTests, ppc::util::ExpandToValues(kTaskList),
6768
MonteCarloFuncTests::PrintTestParam);
@@ -164,9 +165,10 @@ const std::array<TestType, 5> kExtraParams = {
164165
std::make_tuple(3, "large_samples"), std::make_tuple(4, "negative_interval"),
165166
};
166167

167-
const auto kExtraTaskList = std::tuple_cat(
168-
ppc::util::AddFuncTask<DorofeevIMonteCarloIntegrationSEQ, InType>(kExtraParams, PPC_SETTINGS_example_processes),
169-
ppc::util::AddFuncTask<DorofeevIMonteCarloIntegrationMPI, InType>(kExtraParams, PPC_SETTINGS_example_processes));
168+
const auto kExtraTaskList = std::tuple_cat(ppc::util::AddFuncTask<DorofeevIMonteCarloIntegrationSEQ, InType>(
169+
kExtraParams, PPC_SETTINGS_dorofeev_i_monte_carlo_integration),
170+
ppc::util::AddFuncTask<DorofeevIMonteCarloIntegrationMPI, InType>(
171+
kExtraParams, PPC_SETTINGS_dorofeev_i_monte_carlo_integration));
170172

171173
INSTANTIATE_TEST_SUITE_P(ExtraIntegrationTests, MonteCarloExtraFuncTests, ppc::util::ExpandToValues(kExtraTaskList),
172174
MonteCarloExtraFuncTests::PrintName);

tasks/dorofeev_i_monte_carlo_integration/tests/performance/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ TEST_P(MonteCarloPerfTests, PerfTestModes) {
4747
// making performance probs: MPI + SEQ
4848
const auto kPerfTasks =
4949
ppc::util::MakeAllPerfTasks<InType, DorofeevIMonteCarloIntegrationMPI, DorofeevIMonteCarloIntegrationSEQ>(
50-
PPC_SETTINGS_example_processes);
50+
PPC_SETTINGS_dorofeev_i_monte_carlo_integration);
5151

5252
// converting to GTest values
5353
const auto kGTestValues = ppc::util::TupleToGTestValues(kPerfTasks);

tasks/leonova_a_star/tests/functional/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ const std::array<TestType, 6> kTestParam = {
115115
std::vector<std::vector<int>>{{1900, 2200}, {4300, 5000}})};
116116

117117
const auto kTestTasksList =
118-
std::tuple_cat(ppc::util::AddFuncTask<LeonovaAStarMPI, InType>(kTestParam, PPC_SETTINGS_example_processes_2),
119-
ppc::util::AddFuncTask<LeonovaAStarSEQ, InType>(kTestParam, PPC_SETTINGS_example_processes_2));
118+
std::tuple_cat(ppc::util::AddFuncTask<LeonovaAStarMPI, InType>(kTestParam, PPC_SETTINGS_leonova_a_star),
119+
ppc::util::AddFuncTask<LeonovaAStarSEQ, InType>(kTestParam, PPC_SETTINGS_leonova_a_star));
120120

121121
const auto kGtestValues = ppc::util::ExpandToValues(kTestTasksList);
122122

0 commit comments

Comments
 (0)