diff --git a/batch/parallel/application/CMakeLists.txt b/batch/parallel/application/CMakeLists.txt index c8b9f52..fb8ec21 100644 --- a/batch/parallel/application/CMakeLists.txt +++ b/batch/parallel/application/CMakeLists.txt @@ -21,4 +21,7 @@ set(PACKAGE_BUGREPORT "https://github.com/GoogleCloudPlatform/cpp-samples/issues") project(cpp-samples-batch CXX) +find_package(OpenMP REQUIRED) + add_executable(finsim src/finsim.cc) +target_link_libraries(finsim PRIVATE OpenMP::OpenMP_CXX) diff --git a/batch/parallel/application/src/finsim.cc b/batch/parallel/application/src/finsim.cc index b9f5ac3..9d104ef 100644 --- a/batch/parallel/application/src/finsim.cc +++ b/batch/parallel/application/src/finsim.cc @@ -103,6 +103,8 @@ int main(int argc, char* argv[]) { std::vector results(input_config.simulations); simulate(input_config); + omp_set_num_threads(input_config.total_threads); + #pragma omp parallel for for (int i = 0; i < input_config.simulations; i++) { results[i] = simulate(input_config);