fix(dfr): fix thread binding when running both HPX and OpenMP runtimes.

This commit is contained in:
Antoniu Pop
2022-05-27 09:32:36 +01:00
committed by Antoniu Pop
parent 8f2b12d812
commit b405a2daf2
2 changed files with 18 additions and 0 deletions

View File

@@ -10,6 +10,10 @@ if(CONCRETELANG_PARALLEL_EXECUTION_ENABLED)
PRIVATE
HPX::hpx HPX::iostreams_component
)
set_source_files_properties(
DFRuntime.cpp
PROPERTIES COMPILE_FLAGS "-fopenmp"
)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

View File

@@ -17,6 +17,7 @@
#include <hpx/hpx_start.hpp>
#include <hpx/hpx_suspend.hpp>
#include <hwloc.h>
#include <omp.h>
#include "concretelang/Runtime/DFRuntime.hpp"
#include "concretelang/Runtime/distributed_generic_task_server.hpp"
@@ -788,12 +789,25 @@ static inline void _dfr_stop_impl() {
static inline void _dfr_start_impl(int argc, char *argv[]) {
mlir::concretelang::dfr::dl_handle = dlopen(nullptr, RTLD_NOW);
// If OpenMP is to be used, we need to force its initialization
// before thread binding occurs. Otherwise OMP threads will be bound
// to the core of the thread initializing the OMP runtime.
if (mlir::concretelang::dfr::_dfr_use_omp()) {
#pragma omp parallel shared(mlir::concretelang::dfr::use_omp_p)
{
#pragma omp critical
mlir::concretelang::dfr::use_omp_p = true;
}
}
if (argc == 0) {
int nCores, nOMPThreads, nHPXThreads;
std::string hpxThreadNum;
std::vector<char *> parameters;
parameters.push_back(const_cast<char *>("__dummy_dfr_HPX_program_name__"));
parameters.push_back(const_cast<char *>("--hpx:print-bind"));
hwloc_topology_t topology;
hwloc_topology_init(&topology);