feat(dfr): add default configuration file for HPX runtime.

This commit is contained in:
Antoniu Pop
2022-04-29 00:06:19 +01:00
committed by Antoniu Pop
parent 93d5a06557
commit ae55e88435
3 changed files with 54 additions and 1 deletions

View File

@@ -83,7 +83,10 @@ if(CONCRETELANG_PARALLEL_EXECUTION_ENABLED)
find_package(HPX REQUIRED CONFIG)
include_directories(SYSTEM ${HPX_INCLUDE_DIRS})
list(APPEND CMAKE_MODULE_PATH "${HPX_CMAKE_DIR}")
add_compile_options(-DCONCRETELANG_PARALLEL_EXECUTION_ENABLED)
add_compile_options(
-DCONCRETELANG_PARALLEL_EXECUTION_ENABLED
-DHPX_DEFAULT_CONFIG_FILE="${PROJECT_SOURCE_DIR}/hpx.ini"
)
else()
message(STATUS "ConcreteLang parallel execution disabled.")

27
compiler/hpx.ini Normal file
View File

@@ -0,0 +1,27 @@
[hpx]
location = ${HPX_LOCATION:$[system.prefix]}
component_path = $[hpx.location]/lib/hpx:$[system.executable_prefix]/lib/hpx:$[system.executable_prefix]/../lib/hpx
master_ini_path = $[hpx.location]/share/hpx-<version>:$[system.executable_prefix]/share/hpx-<version>:$[system.executable_prefix]/../share/hpx-<version>
ini_path = $[hpx.master_ini_path]/ini
os_threads = 1
localities = 1
program_name =
cmd_line =
lock_detection = ${HPX_LOCK_DETECTION:0}
throw_on_held_lock = ${HPX_THROW_ON_HELD_LOCK:1}
minimal_deadlock_detection = <debug>
spinlock_deadlock_detection = <debug>
spinlock_deadlock_detection_limit = ${HPX_SPINLOCK_DEADLOCK_DETECTION_LIMIT:1000000}
max_background_threads = ${HPX_MAX_BACKGROUND_THREADS:$[hpx.os_threads]}
max_idle_loop_count = ${HPX_MAX_IDLE_LOOP_COUNT:<hpx_idle_loop_count_max>}
max_busy_loop_count = ${HPX_MAX_BUSY_LOOP_COUNT:<hpx_busy_loop_count_max>}
max_idle_backoff_time = ${HPX_MAX_IDLE_BACKOFF_TIME:<hpx_idle_backoff_time_max>}
exception_verbosity = ${HPX_EXCEPTION_VERBOSITY:1}
default_stack_size = 0x20000000
[hpx.stacks]
small_size = 0x8000000
medium_size = 0x10000000
large_size = 0x20000000
huge_size = 0x40000000
use_guard_pages = ${HPX_THREAD_GUARD_PAGE:3}

View File

@@ -791,12 +791,21 @@ static inline void _dfr_start_impl(int argc, char *argv[]) {
if (nCores < 1)
nCores = 1;
// We do not directly handle this, but we should take into account
// the choices made by the OpenMP runtime if we would be mixing
// loop & dataflow parallelism.
char *env = getenv("OMP_NUM_THREADS");
if (env != nullptr)
nOMPThreads = strtoul(env, NULL, 10);
else
nOMPThreads = nCores;
// Unless specified, we will consider that within each node loop
// parallelism is the priority, so we would allocate either
// ncores/OMP_NUM_THREADS or ncores-OMP_NUM_THREADS+1. Both make
// sense depending on whether we have very regular computation or
// not - the latter being more conservative in that we will
// exploit all cores, but we may oversubscribe.
env = getenv("DFR_NUM_THREADS");
if (env != nullptr)
nHPXThreads = strtoul(env, NULL, 10);
@@ -805,7 +814,16 @@ static inline void _dfr_start_impl(int argc, char *argv[]) {
if (nHPXThreads < 1)
nHPXThreads = 1;
// If the user does not provide their own config file, one is by
// default located at the root of the concrete-compiler directory.
env = getenv("HPX_CONFIG_FILE");
// If no file is provided, try and check that the default is
// available - otherwise use a basic default configuration.
#ifdef HPX_DEFAULT_CONFIG_FILE
if (env == nullptr)
if (access(HPX_DEFAULT_CONFIG_FILE, F_OK) == 0)
env = const_cast<char *>(HPX_DEFAULT_CONFIG_FILE);
#endif
if (env != nullptr) {
int _argc = 3;
char *_argv[3] = {const_cast<char *>("__dummy_dfr_HPX_program_name__"),
@@ -813,6 +831,11 @@ static inline void _dfr_start_impl(int argc, char *argv[]) {
const_cast<char *>(env)};
hpx::start(nullptr, _argc, _argv);
} else {
// Last resort configuration in case no config file could be
// identified, provide some default values that make (some)
// sense for homomorphic computations (stacks need to reflect
// the size of ciphertexts rather than simple cleartext
// scalars).
std::string numHPXThreads = std::to_string(nHPXThreads);
int _argc = 7;
char *_argv[7] = {