Skip to content

Commit c0f76c1

Browse files
committed
The new LCW parcelpoort
LCW: Lightweight Communication Wrapper. The idea is to provide a thin wrapper layer mimicing the LCI parcelport's infrastructure. Right now LCW supports the standard MPI, MPI with extensions, and LCI2 backend.
1 parent b3ed893 commit c0f76c1

54 files changed

Lines changed: 4148 additions & 5 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ if(APPLE
663663
OR HPX_WITH_CUDA
664664
OR HPX_WITH_HIP
665665
OR HPX_WITH_PARCELPORT_LCI
666+
OR HPX_WITH_PARCELPORT_LCW
666667
)
667668
set(HPX_WITH_PKGCONFIG_DEFAULT OFF)
668669
endif()
@@ -1303,6 +1304,46 @@ if(HPX_WITH_NETWORKING)
13031304
hpx_add_config_define(HPX_HAVE_PARCELPORT_LCI_PCOUNTER)
13041305
endif()
13051306

1307+
hpx_option(
1308+
HPX_WITH_PARCELPORT_LCW BOOL "Enable the LCW based parcelport." OFF
1309+
CATEGORY "Parcelport"
1310+
)
1311+
if(HPX_WITH_PARCELPORT_LCW)
1312+
hpx_add_config_define(HPX_HAVE_PARCELPORT_LCW)
1313+
endif()
1314+
# Options for automatically fetching LCI
1315+
hpx_option(
1316+
HPX_WITH_FETCH_LCW
1317+
BOOL
1318+
"Use FetchContent to fetch LCW. By default an installed LCW will be used. (default: OFF)"
1319+
OFF
1320+
CATEGORY "Build Targets"
1321+
ADVANCED
1322+
)
1323+
hpx_option(
1324+
HPX_WITH_LCW_TAG STRING "LCW repository tag or branch" "master"
1325+
CATEGORY "Build Targets"
1326+
ADVANCED
1327+
)
1328+
hpx_option(
1329+
HPX_WITH_PARCELPORT_LCW_LOG STRING
1330+
"Enable the LCW-parcelport-specific logger" OFF
1331+
CATEGORY "Parcelport"
1332+
ADVANCED
1333+
)
1334+
if(HPX_WITH_PARCELPORT_LCW_LOG)
1335+
hpx_add_config_define(HPX_HAVE_PARCELPORT_LCW_LOG)
1336+
endif()
1337+
hpx_option(
1338+
HPX_WITH_PARCELPORT_LCW_PCOUNTER STRING
1339+
"Enable the LCW-parcelport-specific performance counter" OFF
1340+
CATEGORY "Parcelport"
1341+
ADVANCED
1342+
)
1343+
if(HPX_WITH_PARCELPORT_LCW_PCOUNTER)
1344+
hpx_add_config_define(HPX_HAVE_PARCELPORT_LCW_PCOUNTER)
1345+
endif()
1346+
13061347
hpx_option(
13071348
HPX_WITH_PARCELPORT_GASNET BOOL "Enable the GASNET based parcelport." OFF
13081349
CATEGORY "Parcelport"
@@ -1435,7 +1476,32 @@ if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_LCI)
14351476
endif()
14361477
endif()
14371478

1438-
# External libraries/frameworks used by some of the examples and benchmarks
1479+
if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_LCW)
1480+
# lcw parcelport settings
1481+
hpx_option(
1482+
HPX_WITH_PARCELPORT_LCW_ENV
1483+
STRING
1484+
"List of environment variables checked to detect LCW (default: MV2_COMM_WORLD_RANK;PMI_RANK;OMPI_COMM_WORLD_SIZE;ALPS_APP_PE;PMIX_RANK;PALS_NODEID;LCT_PMI_FILE_NRANKS)."
1485+
"MV2_COMM_WORLD_RANK;PMI_RANK;OMPI_COMM_WORLD_SIZE;ALPS_APP_PE;PMIX_RANK;PALS_NODEID;LCT_PMI_FILE_NRANKS"
1486+
CATEGORY "Parcelport"
1487+
ADVANCED
1488+
)
1489+
1490+
# This list is to detect whether we run inside an lcw environment. If one of
1491+
# those environment variables is set, the LCW parcelport is enabled by
1492+
# default. PMI_RANK: Intel MPI and MVAPICH2 OMPI_COMM_WORLD_SIZE: OpenMPI
1493+
# starting at version 1.3
1494+
if(HPX_WITH_PARCELPORT_LCW_ENV)
1495+
string(REPLACE ";" "," hpx_parcelport_lcw_env_
1496+
"${HPX_WITH_PARCELPORT_LCW_ENV}"
1497+
)
1498+
hpx_add_config_define(
1499+
HPX_HAVE_PARCELPORT_LCW_ENV "\"${hpx_parcelport_lcw_env_}\""
1500+
)
1501+
endif()
1502+
endif()
1503+
1504+
# External libraries/frameworks used by sme of the examples and benchmarks
14391505
hpx_option(
14401506
HPX_WITH_EXAMPLES_OPENMP BOOL
14411507
"Enable examples requiring OpenMP support (default: OFF)." OFF
@@ -2352,6 +2418,10 @@ if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_LCI)
23522418
include(HPX_SetupLCI)
23532419
hpx_setup_lci()
23542420
endif()
2421+
if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_LCW)
2422+
include(HPX_SetupLCW)
2423+
hpx_setup_lcw()
2424+
endif()
23552425
if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_GASNET)
23562426
include(HPX_SetupGasnet)
23572427
hpx_setup_gasnet()

cmake/HPX_AddTest.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,31 @@ function(add_hpx_test category name)
182182
endif()
183183
endif()
184184
endif()
185+
if(HPX_WITH_PARCELPORT_LCW AND NOT ${${name}_NO_PARCELPORT_LCW})
186+
set(_add_test FALSE)
187+
if(DEFINED ${name}_PARCELPORTS)
188+
set(PP_FOUND -1)
189+
list(FIND ${name}_PARCELPORTS "lcw" PP_FOUND)
190+
if(NOT PP_FOUND EQUAL -1)
191+
set(_add_test TRUE)
192+
endif()
193+
else()
194+
set(_add_test TRUE)
195+
endif()
196+
if(_add_test)
197+
set(_full_name "${category}.distributed.lcw.${name}")
198+
add_test(NAME "${_full_name}" COMMAND ${cmd} "-p" "lcw" "-r" "mpi"
199+
${args}
200+
)
201+
set_tests_properties("${_full_name}" PROPERTIES RUN_SERIAL TRUE)
202+
203+
if(${name}_TIMEOUT)
204+
set_tests_properties(
205+
"${_full_name}" PROPERTIES TIMEOUT ${${name}_TIMEOUT}
206+
)
207+
endif()
208+
endif()
209+
endif()
185210
if(HPX_WITH_PARCELPORT_GASNET AND NOT ${name}_NO_PARCELPORT_GASNET)
186211
set(_add_test FALSE)
187212
if(DEFINED ${name}_PARCELPORTS)

cmake/HPX_SetupLCW.cmake

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Copyright (c) 2021-2023 Ste||ar Group
2+
#
3+
# SPDX-License-Identifier: BSL-1.0
4+
# Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
7+
# FIXME : in the future put it directly inside the cmake directory of the
8+
# corresponding plugin
9+
10+
macro(hpx_setup_lcw)
11+
# LCW always needs LCI
12+
include(HPX_SetupLCI)
13+
hpx_setup_lci()
14+
15+
if(NOT TARGET LCW::LCW)
16+
17+
# compatibility with older CMake versions
18+
if(LCW_ROOT AND NOT Lcw_ROOT)
19+
set(Lcw_ROOT
20+
${LCW_ROOT}
21+
CACHE PATH "LCW base directory"
22+
)
23+
unset(LCW_ROOT CACHE)
24+
endif()
25+
26+
if(NOT HPX_WITH_FETCH_LCW)
27+
find_package(
28+
LCW
29+
CONFIG
30+
REQUIRED
31+
HINTS
32+
${Lcw_ROOT}
33+
$ENV{LCW_ROOT}
34+
PATH_SUFFIXES
35+
lib/cmake
36+
lib64/cmake
37+
)
38+
elseif(NOT HPX_FIND_PACKAGE)
39+
if(FETCHCONTENT_SOURCE_DIR_LCW)
40+
hpx_info(
41+
"HPX_WITH_FETCH_LCW=${HPX_WITH_FETCH_LCW}, LCW will be used through CMake's FetchContent and installed alongside HPX (FETCHCONTENT_SOURCE_DIR_LCW=${FETCHCONTENT_SOURCE_DIR_LCW})"
42+
)
43+
else()
44+
hpx_info(
45+
"HPX_WITH_FETCH_LCW=${HPX_WITH_FETCH_LCW}, LCW will be fetched using CMake's FetchContent and installed alongside HPX (HPX_WITH_LCW_TAG=${HPX_WITH_LCW_TAG})"
46+
)
47+
endif()
48+
include(FetchContent)
49+
fetchcontent_declare(
50+
lcw
51+
GIT_REPOSITORY https://github.com/JiakunYan/lcw
52+
GIT_TAG ${HPX_WITH_LCW_TAG}
53+
)
54+
55+
fetchcontent_getproperties(lcw)
56+
if(NOT lcw_POPULATED)
57+
fetchcontent_populate(lcw)
58+
enable_language(CXX)
59+
add_subdirectory(${lcw_SOURCE_DIR} ${lcw_BINARY_DIR})
60+
# Move LCW target into its own FOLDER
61+
set_target_properties(lcw PROPERTIES FOLDER "Core/Dependencies")
62+
# add_library(LCW::LCW ALIAS lcw)
63+
set(HPX_CMAKE_ADDITIONAL_MODULE_PATH_BUILD
64+
"${lcw_SOURCE_DIR}/cmake_modules"
65+
CACHE INTERNAL ""
66+
)
67+
endif()
68+
69+
install(
70+
TARGETS lcw
71+
EXPORT HPXLCWTarget
72+
COMPONENT core
73+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
74+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
75+
)
76+
77+
install(
78+
DIRECTORY ${lcw_SOURCE_DIR}/lcw/api/ ${lcw_BINARY_DIR}/lcw/api/
79+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
80+
COMPONENT core
81+
FILES_MATCHING
82+
PATTERN "*.h"
83+
)
84+
85+
export(
86+
TARGETS lcw
87+
NAMESPACE LCW::
88+
FILE "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${HPX_PACKAGE_NAME}/HPXLCWTarget.cmake"
89+
)
90+
91+
install(
92+
EXPORT HPXLCWTarget
93+
NAMESPACE LCW::
94+
FILE HPXLCWTarget.cmake
95+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${HPX_PACKAGE_NAME}
96+
COMPONENT cmake
97+
)
98+
endif()
99+
endif()
100+
endmacro()

cmake/templates/HPXConfig.cmake.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_LCI)
6363
endif()
6464
endif()
6565

66+
# LCW
67+
if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_LCW)
68+
if(HPX_WITH_FETCH_LCW)
69+
include("${CMAKE_CURRENT_LIST_DIR}/HPXLCWTarget.cmake")
70+
else()
71+
include(HPX_SetupLCW)
72+
hpx_setup_lcw()
73+
endif()
74+
endif()
75+
6676
if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_GASNET)
6777
include(HPX_SetupGasnet)
6878
hpx_setup_gasnet()

cmake/templates/hpxrun.py.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ def build_cmd(options, args):
260260
select_parcelport = (lambda pp:
261261
['--hpx:ini=hpx.parcel.mpi.priority=1000', '--hpx:ini=hpx.parcel.mpi.enable=1', '--hpx:ini=hpx.parcel.bootstrap=mpi'] if pp == 'mpi'
262262
else ['--hpx:ini=hpx.parcel.lci.priority=1000', '--hpx:ini=hpx.parcel.lci.enable=1', '--hpx:ini=hpx.parcel.bootstrap=lci'] if pp == 'lci'
263+
else ['--hpx:ini=hpx.parcel.lcw.priority=1000', '--hpx:ini=hpx.parcel.lcw.enable=1', '--hpx:ini=hpx.parcel.bootstrap=lcw'] if pp == 'lcw'
263264
else ['--hpx:ini=hpx.parcel.gasnet.priority=1000', '--hpx:ini=hpx.parcel.gasnet.enable=1', '--hpx:ini=hpx.parcel.bootstrap=gasnet'] if pp == 'gasnet'
264265
else ['--hpx:ini=hpx.parcel.tcp.priority=1000', '--hpx:ini=hpx.parcel.tcp.enable=1'] if pp == 'tcp'
265266
else [])
@@ -297,7 +298,7 @@ def check_options(parser, options, args):
297298
print('Can not start less than one thread per locality', sys.stderr)
298299
sys.exit(1)
299300

300-
check_valid_parcelport = (lambda x: x == 'mpi' or x == 'lci' or x == 'gasnet' or x == 'tcp' or x == 'none');
301+
check_valid_parcelport = (lambda x: x == 'mpi' or x == 'lci' or x == 'lcw' or x == 'gasnet' or x == 'tcp' or x == 'none');
301302
if not check_valid_parcelport(options.parcelport):
302303
print('Error: Parcelport option not valid\n', sys.stderr)
303304
parser.print_help()
@@ -383,7 +384,7 @@ Used by the tcp parcelport only.
383384
parser.add_option('-p', '--parcelport'
384385
, action='store', type='string'
385386
, dest='parcelport', default=default_env('HPXRUN_PARCELPORT', 'tcp')
386-
, help='Which parcelport to use (Options are: mpi, lci, gasnet, tcp) '
387+
, help='Which parcelport to use (Options are: mpi, lci, lcw, gasnet, tcp) '
387388
'(environment variable HPXRUN_PARCELPORT')
388389

389390
parser.add_option('-r', '--runwrapper'

libs/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ set(_hpx_core_modules
5151
iterator_support
5252
itt_notify
5353
lci_base
54+
lcw_base
5455
lcos_local
5556
lock_registration
5657
logging

libs/core/lci_base/src/lci_environment.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ namespace hpx { namespace util {
4444
get_entry_as(cfg, "hpx.parcel.lci.priority", 0))) ||
4545
(get_entry_as(cfg, "hpx.parcel.mpi.enable", 1) &&
4646
(get_entry_as(cfg, "hpx.parcel.mpi.priority", 1) >
47+
get_entry_as(cfg, "hpx.parcel.lci.priority", 0))) ||
48+
(get_entry_as(cfg, "hpx.parcel.lcw.enable", 1) &&
49+
(get_entry_as(cfg, "hpx.parcel.lcw.priority", 1) >
4750
get_entry_as(cfg, "hpx.parcel.lci.priority", 0))))
4851
{
4952
LBT_(info)

libs/core/lcw_base/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2019-2021 The STE||AR-Group
2+
#
3+
# SPDX-License-Identifier: BSL-1.0
4+
# Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
7+
if(NOT (HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_LCW))
8+
return()
9+
endif()
10+
11+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
12+
13+
# setup LCW, if necessary
14+
include(HPX_SetupLCW)
15+
hpx_setup_lcw()
16+
17+
# Default location is $HPX_ROOT/libs/lcw_base/include
18+
set(lcw_base_headers hpx/lcw_base/lcw_environment.hpp)
19+
20+
set(lcw_base_sources lcw_environment.cpp)
21+
22+
include(HPX_AddModule)
23+
add_hpx_module(
24+
core lcw_base
25+
GLOBAL_HEADER_GEN ON
26+
SOURCES ${lcw_base_sources}
27+
HEADERS ${lcw_base_headers}
28+
MODULE_DEPENDENCIES hpx_logging hpx_runtime_configuration hpx_string_util
29+
hpx_util
30+
DEPENDENCIES LCW::LCW LCI::LCT
31+
CMAKE_SUBDIRS examples tests
32+
)

libs/core/lcw_base/docs/index.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
..
2+
Copyright (c) 2020 The STE||AR-Group
3+
4+
SPDX-License-Identifier: BSL-1.0
5+
Distributed under the Boost Software License, Version 1.0. (See accompanying
6+
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7+
8+
.. _modules_lcw_base:
9+
10+
========
11+
lcw_base
12+
========
13+
14+
This module provides helper functionality for detecting LCW environments.
15+
16+
See the :ref:`API reference <modules_lcw_base_api>` of this module for more
17+
details.
18+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2020 The STE||AR-Group
2+
#
3+
# SPDX-License-Identifier: BSL-1.0
4+
# Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
7+
if(HPX_WITH_EXAMPLES)
8+
add_hpx_pseudo_target(examples.modules.lcw_base)
9+
add_hpx_pseudo_dependencies(examples.modules examples.modules.lcw_base)
10+
if(HPX_WITH_TESTS
11+
AND HPX_WITH_TESTS_EXAMPLES
12+
AND HPX_LCW_BASE_WITH_TESTS
13+
)
14+
add_hpx_pseudo_target(tests.examples.modules.lcw_base)
15+
add_hpx_pseudo_dependencies(
16+
tests.examples.modules tests.examples.modules.lcw_base
17+
)
18+
endif()
19+
endif()

0 commit comments

Comments
 (0)