Skip to content

Noc changes on top of zero engine #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: zero_engine
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9520f4d
start working on a NOC extension and example
KADichev Nov 29, 2024
d1055f7
Start using NOC notation in example
KADichev Dec 2, 2024
14ee22a
Functional tests use GoogleTest now (#26)
KADichev Dec 2, 2024
0aa7363
WIP
KADichev Dec 3, 2024
3c2c337
WIP, now it compiles, but logic incomplete
KADichev Dec 3, 2024
69608f0
Use more inheritance instead of separate NOC methods, and fix a few bugs
KADichev Dec 4, 2024
de50310
Revert the use of shared pointers. Nothing really changes, still look…
KADichev Dec 4, 2024
b37b1eb
Remove use of shared_ptr, suspecting SIGILL is due to that
KADichev Dec 4, 2024
47178f4
Two important changes. First, refactor the NOC example to be an IBVer…
KADichev Dec 5, 2024
43a6544
Fix string comparison, it seems I need to convert to std::string or t…
KADichev Dec 6, 2024
b63f5b0
First working version! ToDo: implement serializable objects
KADichev Dec 7, 2024
d2d6ce9
Implement serialize/deserialize methods for memory region class. Unfo…
KADichev Dec 10, 2024
bfed254
Working version using strings for serialize/deserialize. Will improve…
KADichev Dec 11, 2024
d121723
Replace string and string stream with direct binary copying via memcpy
KADichev Dec 11, 2024
9d3a1d9
Implemented Noc within LPF layer (not only IBVerbs). Now fixing compi…
KADichev Dec 12, 2024
0e3a1c2
A lot of refactoring treating every GCC warning as error. I think tha…
KADichev Dec 12, 2024
ac3161d
Forgot to add the new LPF-based NOC functionality test. Remove mesgqu…
KADichev Dec 12, 2024
0ad1ec7
A fully working example now. Resolved a very nasty bug: The informati…
KADichev Dec 12, 2024
bf68a0c
Update test name, name it 'lpf_test_noc_ring'
KADichev Dec 13, 2024
a9dadeb
Refactoring towards registering NOC slots as NOC slots, and not as lo…
KADichev Dec 14, 2024
bb65de3
Slightly refactoring verbs API and lpf API test for NOC functionaliy …
KADichev Dec 14, 2024
52ea900
rename serialize/deserialize to be named lpf_noc_*
KADichev Dec 15, 2024
07ac180
Merge branch 'master' into noc_extension
KADichev Dec 15, 2024
7078fe6
Complete merging manually, LPF_HAS_ABORT was missing for some conflic…
KADichev Dec 15, 2024
141e55b
During the merge, forgot to re-introduce zero engine, back on
KADichev Dec 16, 2024
5074ff2
This commit fixes a bug in the zero-cost synchronization method count…
KADichev Jan 23, 2025
26e405f
This commit fixes https://github.com/Algebraic-Programming/LPF/issues…
KADichev Jan 23, 2025
974f3df
A file from tests is used to validate we can compile LPF MPI simple p…
KADichev Jan 23, 2025
a455246
I think the assertions that a mem slot is not a null poiner and not w…
KADichev Feb 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 138 additions & 66 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"A high performance BSP communications library" )
"A high performance BSP communications library" )

set(CPACK_SOURCE_GENERATOR "TGZ" )
set(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/" "/\\\\.svn/" "\\\\.swp$" "/site/" "/build/" "/pclint/" "/junit/" "/ideas/" )
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"LPF-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_PACKAGE}")
"LPF-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_PACKAGE}")

set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
Expand Down Expand Up @@ -183,10 +183,29 @@ endif()

#enable the hybrid engine
if ( LIB_POSIX_THREADS AND LIB_MATH AND LIB_DL AND MPI_FOUND
AND MPI_IS_THREAD_COMPAT AND MPI_IS_NOT_OPENMPI1
AND ENABLE_IBVERBS )
list(APPEND ENGINES "hybrid")
set(HYBRID_ENGINE_ENABLED on)
AND MPI_IS_THREAD_COMPAT AND MPI_IS_NOT_OPENMPI1 )
if( ENABLE_IBVERBS )
set(LPFLIB_HYBRID_MPI_ENGINE "ibverbs" CACHE STRING
"Choice of MPI engine to use for inter-process communication")
list(APPEND ENGINES "hybrid")
set(HYBRID_ENGINE_ENABLED on)
elseif( MPI_RMA )
set(LPFLIB_HYBRID_MPI_ENGINE "mpirma" CACHE STRING
"Choice of MPI engine to use for inter-process communication")
list(APPEND ENGINES "hybrid")
set(HYBRID_ENGINE_ENABLED on)
elseif( LIB_MATH AND LIB_DL AND MPI_FOUND )
set(LPFLIB_HYBRID_MPI_ENGINE "mpimsg" CACHE STRING
"Choice of MPI engine to use for inter-process communication")
list(APPEND ENGINES "hybrid")
set(HYBRID_ENGINE_ENABLED on)
endif()
if( HYBRID_ENGINE_ENABLED )
message( "Hybrid engine will be built using the ${LPFLIB_HYBRID_MPI_ENGINE} engine" )
else()
message( "No suitable inter-node communication engine found; "
"hybrid engine will not be built" )
endif()
endif()

message( STATUS "The following engines will be built: ${ENGINES}")
Expand All @@ -209,6 +228,7 @@ endif()

# When system is not Linux, enable conditionally compiled blocks
if (APPLE)
message( WARNING "LPF compilation on OS X is not regularly tested" )
add_definitions(-DLPF_ON_MACOS=1)
endif()

Expand All @@ -233,8 +253,8 @@ option(LPF_ENABLE_TESTS
"Enable unit and API tests. This uses Google Testing and Mocking Framework"
OFF)
option(GTEST_AGREE_TO_LICENSE
"Does the user agree to the GoogleTest license"
OFF)
"Does the user agree to the GoogleTest license"
OFF)

# C++ standard -- Google tests require newer C++ standard than C++11
if (LPF_ENABLE_TESTS)
Expand Down Expand Up @@ -312,14 +332,43 @@ endfunction(target_compile_flags)
# Source
set(lpf_cflags)
set(lpf_lib_link_flags)
set(lpf_exe_link_flags "-rdynamic")
set(lpf_exe_link_flags)

# Populate lpf_cflags, lpf_lib_link_flags, lpf_exe_link_flags according to
# (enabled) engine requirements
# - 0) PThreads engine needs nothing special
# - 1) MPI-based engines:
if ( LIB_MATH AND LIB_DL AND MPI_FOUND )
# -fPIC and -rdynamic are necessary to ensure that symbols can be
# looked up by dlsym which is the mechanism lpf_exec uses to broadcast the
# function that should be executed
set(rdyn_lflag "-rdynamic")
if (APPLE)
# OS X does not support -rdynamic
set(rdyn_lflag "")
endif ()

# include flags:
set( mpi_include_flags )
string( REPLACE ";" " -I" mpi_include_flags "${MPI_C_INCLUDE_PATH}" )
set(lpf_cflags "${lpf_cflags} -I${mpi_include_flags} -fPIC")

# linker flags:
set(lib_lflags "${MPI_C_LINK_FLAGS}") #Note: the core library is already linked with MPI_C_LIBRARIES.
string(REPLACE ";" " " lib_lflags "${lib_lflags}") # So, no need to also link executables with it.
set(lpf_lib_link_flags "${lpf_lib_link_flags} ${lib_lflags} ${rdyn_lflag}")

# executable linker flags:
set(lpf_exe_link_flags "${lpf_exe_link_flags} ${rdyn_lflag}")
endif ()
# ...add requirements from other engines here...

# Collating all compile & link flags
set(LPF_CORE_COMPILE_FLAGS "${lpf_cflags}" CACHE STRING "Compilation flags for all user code" )
set(LPF_CORE_LIB_LINK_FLAGS "${lpf_lib_link_flags}" CACHE STRING "Flags to link user libraries" )
set(LPF_CORE_EXE_LINK_FLAGS "${lpf_exe_link_flags}" CACHE STRING "Flags to link user executables" )

# Compiling LPF programmes in the build dir
# Compiling LPF programs in the build dir
function( target_link_exe_with_core target )
set(engine "imp")
if (ARGV1)
Expand All @@ -343,10 +392,12 @@ if (LPF_ENABLE_TESTS)
message(STATUS "Unit and API tests will be built. This requires CMake version 3.29 or higher, since we use recent features of the GoogleTest package in CMake.")

if (NOT GTEST_AGREE_TO_LICENSE)
message(FATAL_ERROR "The user needs to agree with the GoogleTest license to use tests (option GTEST_AGREE_TO_LICENSE=TRUE)")
message(FATAL_ERROR "The user needs to agree with the GoogleTest license to use tests (option GTEST_AGREE_TO_LICENSE=TRUE)")
endif()
# Enable testing in CMake
enable_testing()
include(ProcessorCount)
ProcessorCount(processorCount)
find_package(GTest)
include(GoogleTest)
if(NOT GTest_FOUND) # if not found, download it and pull it in
Expand All @@ -367,64 +418,84 @@ if (LPF_ENABLE_TESTS)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/junit)
set(test_output "${CMAKE_BINARY_DIR}/junit")

set(MY_TEST_LAUNCHER ${CMAKE_BINARY_DIR}/test_launcher.py)
configure_file( ${CMAKE_SOURCE_DIR}/test_launcher.py ${MY_TEST_LAUNCHER} @ONLY FILE_PERMISSIONS WORLD_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)
if( NOT Python3_FOUND )
find_package( Python3 REQUIRED)
endif()
find_package( Python3 REQUIRED COMPONENTS Interpreter)
set(MY_TEST_LAUNCHER ${Python3_EXECUTABLE} ${CMAKE_BINARY_DIR}/test_launcher.py)
configure_file( ${CMAKE_SOURCE_DIR}/test_launcher.py.in ${CMAKE_BINARY_DIR}/test_launcher.py @ONLY FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)

# Macro for adding a new GoogleTest test
function(add_gtest testName ENGINE debug testSource )
if ("{$ENGINE}" STREQUAL "")
message(FATAL_ERROR "engine cannot be empty, ever!")
endif()
add_executable(${testName} ${testSource} ${ARGN})
target_compile_definitions(${testName} PUBLIC LPF_CORE_IMPL_ID=${ENGINE})
target_compile_definitions(${testName} PUBLIC LPF_CORE_MPI_USES_${ENGINE})
if (debug)
target_include_directories( ${testName} BEFORE PRIVATE ${CMAKE_SOURCE_DIR}/include/debug )
target_link_libraries(${testName} lpf_debug lpf_hl_debug GTest::gtest GTest::gtest_main)
else(debug)
target_link_libraries(${testName} GTest::gtest GTest::gtest_main)
endif(debug)


# Extract test-specific information from comments of tests
file(READ ${testSource} fileContents)
string(REGEX MATCH "Exit code: ([0-9]+)" _ ${fileContents})
set(retCode ${CMAKE_MATCH_1})
string(REGEX MATCH "pre P >= ([0-9]+)" _ ${fileContents})
set(minProcs ${CMAKE_MATCH_1})
string(REGEX MATCH "pre P <= ([0-9]+)" _ ${fileContents})
set(maxProcs ${CMAKE_MATCH_1})
string(REGEX MATCH "-probe ([0-9]+.[0-9]+)" _ ${fileContents})
set(lpfProbeSecs ${CMAKE_MATCH_1})

target_link_exe_with_core(${testName} ${ENGINE})


if ("${minProcs}" STREQUAL "")
set(minProcs "1")
endif()
if ("${maxProcs}" STREQUAL "")
set(maxProcs "5")
endif()
if ("${lpfProbeSecs}" STREQUAL "")
set(lpfProbeSecs "0.0")
endif()
if ("${retCode}" STREQUAL "")
set(retCode "0")
endif()

# Most recent approach to Gtests, recommended!
set_property(TARGET ${testName} PROPERTY TEST_LAUNCHER ${MY_TEST_LAUNCHER};-e;${ENGINE};-L;${CMAKE_BINARY_DIR}/lpfrun_build;-p;${minProcs};-P;${maxProcs};-t;${lpfProbeSecs};-R;${retCode})
gtest_discover_tests(${testName}
TEST_PREFIX ${ENGINE}_
EXTRA_ARGS --gtest_output=xml:${test_output}/${ENGINE}_${testName}
DISCOVERY_MODE POST_BUILD
DISCOVERY_TIMEOUT 15
)
if ("{$ENGINE}" STREQUAL "")
message(FATAL_ERROR "engine cannot be empty, ever!")
endif()
add_executable(${testName} ${testSource} ${ARGN})
target_compile_definitions(${testName} PUBLIC LPF_CORE_IMPL_ID=${ENGINE})
target_compile_definitions(${testName} PUBLIC LPF_CORE_MPI_USES_${ENGINE})
if (debug)
target_include_directories( ${testName} BEFORE PRIVATE ${CMAKE_SOURCE_DIR}/include/debug )
target_link_libraries(${testName} lpf_debug lpf_hl_debug GTest::gtest GTest::gtest_main)
else(debug)
target_link_libraries(${testName} GTest::gtest GTest::gtest_main)
endif(debug)


# Extract test-specific information from comments of tests
file(READ ${testSource} fileContents)
string(REGEX MATCH "Exit code: ([0-9]+)" _ ${fileContents})
set(retCode ${CMAKE_MATCH_1})
string(REGEX MATCH "pre P >= ([0-9]+)" _ ${fileContents})
set(minProcs ${CMAKE_MATCH_1})
string(REGEX MATCH "pre P <= ([0-9]+)" _ ${fileContents})
set(maxProcs ${CMAKE_MATCH_1})
string(REGEX MATCH "-probe ([0-9]+.[0-9]+)" _ ${fileContents})
set(lpfProbeSecs ${CMAKE_MATCH_1})

target_link_exe_with_core(${testName} ${ENGINE})

# The "\pre P <= max" comment in a test indicates the desired number of
# maximum LPF processes. If the test does not define a desired number of
# maximum LPF processes, it will be set to 5.
#
# The "\pre P >= min" comment in a test indicates the desired number of
# minimum LPF processes. If the test does not define a desired minimum
# number of LPF processes, it will be set to 1.
#
# Let 'processorCount' be the detected number of processors by the system.
# If this number is smaller than the desider minimum and/or maximum number
# of processes, it overwrites these
#
# Most tests only define a mininum number of desired processes, such as
# "\pre P >= 1". In those cases, the test will execute for the range 1,..,5
# (including)

if ("${minProcs}" STREQUAL "")
set(minProcs "1")
endif()
if ("${maxProcs}" STREQUAL "")
set(maxProcs "5")
endif()
# cap min with processorCount, if needed
if ("${minProcs}" GREATER "${processorCount}")
set(minProcs ${processorCount})
endif()
# cap max with processorCount, if needed
if ("${maxProcs}" GREATER "${processorCount}")
set(maxProcs ${processorCount})
endif()
if ("${lpfProbeSecs}" STREQUAL "")
set(lpfProbeSecs "0.0")
endif()
if ("${retCode}" STREQUAL "")
set(retCode "0")
endif()

# Most recent approach to Gtests, recommended!
set_property(TARGET ${testName} PROPERTY TEST_LAUNCHER ${MY_TEST_LAUNCHER};--engine;${ENGINE};--parallel_launcher;${CMAKE_BINARY_DIR}/lpfrun_build;--min_process_count;${minProcs};--max_process_count;${maxProcs};--lpf_probe_timer;${lpfProbeSecs};--expected_return_code;${retCode})
gtest_discover_tests(${testName}
TEST_PREFIX ${ENGINE}_
EXTRA_ARGS --gtest_output=xml:${test_output}/${ENGINE}_${testName}
DISCOVERY_MODE POST_BUILD
DISCOVERY_TIMEOUT 15
)

endfunction(add_gtest)

Expand All @@ -436,10 +507,11 @@ else(LPF_ENABLE_TESTS)

endif(LPF_ENABLE_TESTS)

# Main LPF library includes and sources
include_directories(include)
include_directories(src/common)

add_subdirectory(src)

# Apps
add_subdirectory(src/utils)

Expand Down
4 changes: 4 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Optional MPI engine requires
Optional for thread pinning by Pthreads and hybrid engines
- hwloc > 1.11

Optional tests requires
- GNU C++ compiler (C++17 compatible),
- Python 3.

Optional (see --enable-doc) documentation requires
- doxygen > 1.5.6,
- graphviz,
Expand Down
6 changes: 3 additions & 3 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ EOF

--with-mpiexec=*)
mpiexec="${arg#--with-mpiexec=}"
mpi_cmake_flags="${mpi_cmake_flags} -DMPIEXEC=$mpiexec"
mpi_cmake_flags="${mpi_cmake_flags} -DMPIEXEC=$mpiexec -DMPIEXEC_EXECUTABLE=$mpiexec"
shift;
;;

Expand Down Expand Up @@ -288,8 +288,8 @@ ${CMAKE_EXE} -Wno-dev \
-DLPF_HWLOC="${hwloc}" \
$hwloc_found_flag \
$mpi_cmake_flags \
"$extra_flags" \
"$perf_flags" \
${extra_flags+"$extra_flags"} \
${perf_flags+"$perf_flags"} \
"$@" $srcdir \
|| { echo FAIL "Failed to configure LPF; Please check your chosen configuration"; exit 1; }

Expand Down
15 changes: 12 additions & 3 deletions cmake/mpi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,17 @@ try_run( IBVERBS_INIT_RUNS IBVERBS_INIT_COMPILES
endif()

set(ENABLE_IBVERBS FALSE)
if (LIB_IBVERBS AND NOT IBVERBS_INIT_RUNS STREQUAL "FAILED_TO_RUN")
set(ENABLE_IBVERBS TRUE)
if (LPF_ENABLE_TESTS)
# The Google Test integration requires that tests successfully compiled are
# also runnable
if (LIB_IBVERBS AND NOT IBVERBS_INIT_RUNS STREQUAL "FAILED_TO_RUN")
set(ENABLE_IBVERBS TRUE)
endif()
else()
# Without the aforementioned Google Test requirement, we can safely build
# it and allow the user to deploy the built binaries on IB-enabled nodes.
if (LIB_IBVERBS)
set(ENABLE_IBVERBS TRUE)
endif()
endif()


4 changes: 2 additions & 2 deletions doc/lpf_core.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,8 @@ INPUT = @PROJECT_SOURCE_DIR@/include/lpf/core.h \
@PROJECT_SOURCE_DIR@/include/bsp/bsp.h \
@PROJECT_SOURCE_DIR@/include/lpf/hybrid.h \
@PROJECT_SOURCE_DIR@/include/lpf/mpirpc-client.h \
@PROJECT_SOURCE_DIR@/include/lpf/rpc-client.h

@PROJECT_SOURCE_DIR@/include/lpf/rpc-client.h \
@PROJECT_SOURCE_DIR@/include/lpf/abort.h

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
Loading