From 9520f4d1124fbbdf287af383b7130e469315bf71 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Fri, 29 Nov 2024 17:06:59 +0100 Subject: [PATCH 01/28] start working on a NOC extension and example --- src/MPI/ibverbsZero.cpp | 1 + src/common/memreg.hpp | 42 ++++++++++--- tests/functional/CMakeLists.txt | 15 +++-- .../functional/func_lpf_test_noc_register.cpp | 63 +++++++++++++++++++ 4 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 tests/functional/func_lpf_test_noc_register.cpp diff --git a/src/MPI/ibverbsZero.cpp b/src/MPI/ibverbsZero.cpp index 6f52fa5b..c20b2078 100644 --- a/src/MPI/ibverbsZero.cpp +++ b/src/MPI/ibverbsZero.cpp @@ -763,6 +763,7 @@ void IBVerbs :: put( SlotID srcSlot, size_t srcOffset, const MemorySlot & dst = m_memreg.lookup( dstSlot ); ASSERT( src.mr ); + ASSERT( dst.mr ); int numMsgs = size/m_maxMsgSize + (size % m_maxMsgSize > 0); //+1 if last msg size < m_maxMsgSize if (size == 0) numMsgs = 1; diff --git a/src/common/memreg.hpp b/src/common/memreg.hpp index f48d519c..4c92f6c7 100644 --- a/src/common/memreg.hpp +++ b/src/common/memreg.hpp @@ -211,6 +211,7 @@ class CombinedMemoryRegister void destroy() { m_local.destroy(); m_global.destroy(); + m_noc.destroy(); } Slot addLocalReg( Record record ) // nothrow @@ -218,6 +219,11 @@ class CombinedMemoryRegister return toLocal( m_local.add( record ) ); } + Slot addNocReg( Record record ) // nothrow + { + return toNoc( m_local.add( record ) ); + } + Slot addGlobalReg( Record record ) // nothrow { return toGlobal( m_global.add(record) ); @@ -227,16 +233,20 @@ class CombinedMemoryRegister { if (isLocalSlot(slot)) m_local.remove( fromLocal(slot) ) ; - else + else if (isGlobalSlot(slot)) m_global.remove( fromGlobal( slot ) ); + else + m_noc.remove(fromNoc( slot ) ); } const Record & lookup( Slot slot ) const // nothrow { if (isLocalSlot(slot)) return m_local.lookup( fromLocal(slot)); - else + else if (isGlobalSlot(slot)) return m_global.lookup( fromGlobal( slot )); + else // isNocSlot(slot) == true + return m_noc.lookup( fromNoc( slot )); } Record & update( Slot slot ) // nothrow @@ -252,36 +262,50 @@ class CombinedMemoryRegister { m_global.reserve( size, defaultRecord ); m_local.reserve( size, defaultRecord ); + m_noc.reserve( size, defaultRecord ); } size_t capacity( ) const { - return std::min( m_global.capacity(), m_local.capacity() ); + return std::min(std::min( m_global.capacity(), m_local.capacity()), m_noc.capacity() ); } size_t range() const { - return std::max( 2*m_global.capacity(), 2*m_local.capacity()+1 ); + return std::max(std::max( 3*m_global.capacity(), 3*m_local.capacity()+1), 3*m_noc.capacity()+2); } static bool isLocalSlot( Slot slot ) - { return slot % 2 == 1; } + { return slot % 3 == 1; } + + static bool isGlobalSlot( Slot slot ) + { return slot % 3 == 0; } + + static bool isNocSlot( Slot slot ) + { return slot % 3 == 2; } private: static Slot fromGlobal( Slot slot ) - { return slot / 2; } + { return slot / 3; } static Slot fromLocal( Slot slot ) - { return (slot - 1) / 2; } + { return (slot - 1) / 3; } + + static Slot fromNoc( Slot slot ) + { return (slot - 2) / 3; } static Slot toGlobal( Slot slot ) - { return 2*slot; } + { return 3*slot; } static Slot toLocal( Slot slot ) - { return 2*slot + 1; } + { return 3*slot + 1; } + + static Slot toNoc( Slot slot ) + { return 3*slot + 2; } MemoryRegister m_local; MemoryRegister m_global; + MemoryRegister m_noc; }; } // namespace lpf diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 11e4baf1..4a404668 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -142,19 +142,18 @@ foreach (LPF_IMPL_ID ${ENGINES}) string(REGEX MATCH "overlapping|early|bsplib" foundTest ${testSource}) if (NOT ${LPF_IMPL_ID} STREQUAL "zero") add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${testSource}") - - string(REGEX REPLACE "(.${LPF_IMPL_ID})?.cpp$" "" baseName ${testSource}) - get_filename_component(baseName ${testSource} NAME_WE ) - set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") elseif ("${foundTest}" STREQUAL "") add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${testSource}") - - string(REGEX REPLACE "(.${LPF_IMPL_ID})?.cpp$" "" baseName ${testSource}) - get_filename_component(baseName ${testSource} NAME_WE ) - set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") endif() endforeach(testSource) + + # NOC test for HiCR + set(baseName "func_lpf_test_noc_register") + set(debug OFF) + set(mode "") + set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") + add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${baseName}.cpp") endforeach(LPF_IMPL_ID) diff --git a/tests/functional/func_lpf_test_noc_register.cpp b/tests/functional/func_lpf_test_noc_register.cpp new file mode 100644 index 00000000..15488da2 --- /dev/null +++ b/tests/functional/func_lpf_test_noc_register.cpp @@ -0,0 +1,63 @@ + +/* + * Copyright 2021 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "gtest/gtest.h" + + +void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) +{ + (void) args; + int x = 3, y = 6; + lpf_memslot_t xSlot = LPF_INVALID_MEMSLOT; + lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; + + lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); + EXPECT_EQ( LPF_SUCCESS, rc ); + + rc = lpf_resize_message_queue( lpf, 1 ); + EXPECT_EQ( LPF_SUCCESS, rc ); + + rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); + EXPECT_EQ( LPF_SUCCESS, rc ); + + rc = lpf_register_local( lpf, &x, sizeof(x), &xSlot ); + EXPECT_EQ( LPF_SUCCESS, rc ); + + rc = lpf_register_local( lpf, &y, sizeof(x), &ySlot ); + EXPECT_EQ( LPF_SUCCESS, rc ); + + rc = lpf_put( lpf, ySlot, 0, (pid+1)%nprocs, xSlot, 0, sizeof(x), LPF_MSG_DEFAULT ); + EXPECT_EQ( LPF_SUCCESS, rc ); + rc = lpf_sync(lpf, LPF_SYNC_DEFAULT); + EXPECT_EQ( LPF_SUCCESS, rc ); + // Every process should copy + EXPECT_EQ(x, 6); +} + +/** + * \test Testing a lpf_put with an inactive destination memory slot + * \pre P >= 1 + * \return Message: destination memory slot was not yet active + * \return Exit code: 6 + */ +TEST( API, func_lpf_test_noc_register ) +{ + lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); + EXPECT_EQ( LPF_SUCCESS, rc ); +} From d1055f78cdc02c5b9894e2c7803a4a947efca352 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Mon, 2 Dec 2024 09:06:23 +0100 Subject: [PATCH 02/28] Start using NOC notation in example --- tests/functional/func_lpf_test_noc_register.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/functional/func_lpf_test_noc_register.cpp b/tests/functional/func_lpf_test_noc_register.cpp index 15488da2..178b9289 100644 --- a/tests/functional/func_lpf_test_noc_register.cpp +++ b/tests/functional/func_lpf_test_noc_register.cpp @@ -36,13 +36,13 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); EXPECT_EQ( LPF_SUCCESS, rc ); - rc = lpf_register_local( lpf, &x, sizeof(x), &xSlot ); + rc = lpf_noc_register( lpf, &x, sizeof(x), &xSlot ); EXPECT_EQ( LPF_SUCCESS, rc ); - rc = lpf_register_local( lpf, &y, sizeof(x), &ySlot ); + rc = lpf_noc_register( lpf, &y, sizeof(x), &ySlot ); EXPECT_EQ( LPF_SUCCESS, rc ); - rc = lpf_put( lpf, ySlot, 0, (pid+1)%nprocs, xSlot, 0, sizeof(x), LPF_MSG_DEFAULT ); + rc = lpf_noc_put( lpf, ySlot, 0, (pid+1)%nprocs, xSlot, 0, sizeof(x), LPF_MSG_DEFAULT ); EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync(lpf, LPF_SYNC_DEFAULT); EXPECT_EQ( LPF_SUCCESS, rc ); From 14ee22a78735a63258d69c4b10567081bf78f23e Mon Sep 17 00:00:00 2001 From: Kiril Dichev <30658903+KADichev@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:28:28 +0100 Subject: [PATCH 03/28] Functional tests use GoogleTest now (#26) This MR makes all LPF functional tests use GoogleTest. The main changes for CMake are: - reorganize CMake to use GTest CMake package for compilation, and gtest_add_tests clause to define Gtests; - remove all use of the run.sh script; - make explicit the list of tests and do not use file(GLOB, ...) clauses to look for all files in test directories, as recommended by CMakesource files: The main changes for source files are: - every single test file needed to be modified to not include internal Test.h but gtest.h, and to use the assert/equal clauses of GoogleTest - all death tests are slightly modified now to expect FAIL() after the expected fail condition - some modernization of C to C++ was needed for a number of files, incl. use of new/delete instead of malloc/free, or string manipulation instead of C char * manipulation A new Python wrapper script test_launcher.py is being employed now for more flexible checking of return codes, which is needed for death tests and normal tests alike. The expected return codes are still parsed from scanning the source files as before. For the complete history, see GitHub PR #26 . This MR also resolves bugs that have appeared on more modern cluster deployments compared to the previous main tag of LPF. This is hence a priority MR to base all further extensions and evolutions of LPF on. This MR was tested successfully for: - x86_64, CentOS Stream 9, GCC 11.5.0, MPICH 4.1.1 (caveat 2) - x86_64, CentOS Stream 9, GCC 11.5.0, OpenMPI 4.1.1 (caveats 1, 2, and 5) - x86_64, Fedora, GCC 9.3.1, MPICH 3.3.2 (caveat 2) - x86_64, Ubuntu 23.04, GCC 13.1.0, OpenMPI 4.1.6 (caveat 5) - x86_64, openEuler 20.03 LTS, GCC 7.3, MPICH 3.2.1 - x86_64, Ubuntu 22.04 LTS, GCC 11.4.0, MPICH 4.3.0b1 (caveat 3, transient) - ARM, Ubuntu 22.04 LTS, GCC 11.4.0, MPICH 4.3.0b1 (caveats 3 & 4) These are under different variations of calls to `bootstrap.sh` to test all the above-described changes. The following caveats apply: 1. with OpenMPI and default arguments to its `mpirun`, oversubscription to larger process counts may be limited, causing some tests to fail. Issue #37 has been raised to pass the appropriate flags to the OpenMPI `mpirun` during testing; 2. `make install` post-install checks fail (as they should) when: 1) tests are disabled, 2) ibverbs dev libraries are present, but 3) no IB card is present. On the machines with IB we tested on, all post-install checks succeed. 3. The hybrid backend on MPICH 4.3.0b1 does not pass the debug layer tests due to a segfault in MPICH's MPI_Abort. Issue #41 has been raised to track this. This error presently only is consistently reproducible on our cluster's ARM nodes and transient on our cluster's x86_64 nodes. They have not been observed outside our cluster. 4. With MPICH 4.3.0b1, we furthermore hit issues #43 and #44. Also these issues are only reproducible on ARM nodes. 5. With OpenMPI 4.1.6 and OpenMPI 4.1.1 on x86_64 we hit issue #45 6. At present, we have no CI flow that can run all build variations relevant to this MR. Issues #40 has been raised to (partially) address as well as to track this issue. --- CMakeLists.txt | 285 +++++++++++----- README | 8 +- bootstrap.sh | 14 +- cmake/googletest.cmake | 59 ---- cmake/ibverbs_init.c | 19 ++ cmake/is_openmpi.c | 12 + cmake/mpi.cmake | 30 ++ doc/lpf_core.cfg.in | 4 +- include/debug/lpf/core.h | 6 + include/lpf/abort.h | 152 +++++++++ include/lpf/core.h | 2 + include/lpf/hybrid.h | 2 +- include/lpf/pthread.h | 2 +- include/lpf/static_dispatch.h | 4 + lpfcc.in | 26 ++ .../cmake-module-test/src/CMakeLists.txt | 2 +- post-install/post-install-test.cmake.in | 8 +- src/MPI/CMakeLists.txt | 142 ++++---- src/MPI/core.cpp | 12 + src/MPI/dall2all.t.cpp | 63 ++-- src/MPI/dynamichook.cpp | 10 - src/MPI/dynamichook.t.cpp | 92 ++++-- src/MPI/hall2all.t.cpp | 77 +++-- src/MPI/ibverbs.hpp | 4 + src/MPI/ibverbs.t.cpp | 309 +++++++++--------- src/MPI/interface.cpp | 2 - src/MPI/messagesort.t.cpp | 4 + src/MPI/spall2all.t.cpp | 104 +++--- src/common/CMakeLists.txt | 6 +- src/debug/CMakeLists.txt | 9 +- src/debug/core.cpp | 136 +++++--- src/hybrid/CMakeLists.txt | 6 +- src/hybrid/core.cpp | 14 +- src/hybrid/dispatch.hpp | 9 + src/imp/core.c | 7 + src/pthreads/core.cpp | 17 + test_launcher.py.in | 38 +++ tests/functional/CMakeLists.txt | 159 ++++++--- tests/functional/Test.h | 135 -------- tests/functional/c99/CMakeLists.txt | 51 --- tests/functional/collectives/CMakeLists.txt | 54 +++ .../func_lpf_allcombine.cpp} | 33 +- .../func_lpf_allgather.cpp} | 47 ++- .../func_lpf_allgather_overlapped.cpp} | 37 +-- .../func_lpf_allreduce.cpp} | 33 +- .../func_lpf_alltoall.cpp} | 47 ++- .../func_lpf_broadcast.cpp} | 33 +- .../func_lpf_broadcast_prime_size_object.cpp} | 33 +- ...lpf_broadcast_small_prime_size_object.cpp} | 33 +- .../func_lpf_collectives_init.cpp} | 27 +- .../func_lpf_collectives_init_overflow.cpp} | 27 +- .../func_lpf_combine.cpp} | 33 +- .../func_lpf_gather.cpp} | 41 ++- .../func_lpf_reduce.cpp} | 35 +- .../func_lpf_scatter.cpp} | 37 +-- tests/functional/debug/CMakeLists.txt | 103 ++++-- ...pf_debug_deregister_non_existing_slot.cpp} | 7 +- ...=> func_lpf_debug_exec_null_f_symbols.cpp} | 9 +- ...t.c => func_lpf_debug_exec_null_input.cpp} | 9 +- ....c => func_lpf_debug_exec_null_output.cpp} | 9 +- ...md.c => func_lpf_debug_exec_null_spmd.cpp} | 9 +- ... => func_lpf_debug_get_local_src_slot.cpp} | 26 +- ...unc_lpf_debug_get_overflow_dst_offset.cpp} | 25 +- ...unc_lpf_debug_get_overflow_src_offset.cpp} | 25 +- ...st_source_memory_global_known_at_sync.cpp} | 25 +- ...ource_memory_global_known_before_sync.cpp} | 27 +- ... func_lpf_debug_get_too_many_requests.cpp} | 32 +- ...pf_debug_get_too_many_requests_remote.cpp} | 29 +- ..._lpf_debug_get_too_many_requests_self.cpp} | 26 +- ... func_lpf_debug_get_unknown_dest_slot.cpp} | 25 +- ...func_lpf_debug_get_unknown_source_pid.cpp} | 26 +- ...unc_lpf_debug_get_unknown_source_slot.cpp} | 25 +- ...bug_get_write_past_dest_memory_global.cpp} | 26 +- ...ebug_get_write_past_dest_memory_local.cpp} | 26 +- ..._lpf_debug_global_deregister_mismatch.cpp} | 25 +- ...ebug_global_deregister_order_mismatch.cpp} | 27 +- ...c_lpf_debug_global_deregister_unequal.cpp} | 23 +- ...lpf_debug_global_register_null_memreg.cpp} | 8 +- ...lpf_debug_hook_null_f_symbols.pthread.cpp} | 32 +- ...unc_lpf_debug_hook_null_input.pthread.cpp} | 33 +- ...nc_lpf_debug_hook_null_output.pthread.cpp} | 33 +- ...func_lpf_debug_hook_null_spmd.pthread.cpp} | 33 +- ..._lpf_debug_local_register_null_memreg.cpp} | 10 +- ...c_lpf_debug_put_after_deregister_dest.cpp} | 30 +- ..._put_after_deregister_dest_after_sync.cpp} | 30 +- ...lpf_debug_put_after_deregister_source.cpp} | 30 +- ...ut_after_deregister_source_after_sync.cpp} | 30 +- ...c_lpf_debug_put_get_too_many_requests.cpp} | 28 +- ...ebug_put_get_too_many_requests_remote.cpp} | 28 +- ...=> func_lpf_debug_put_local_dest_slot.cpp} | 26 +- ...unc_lpf_debug_put_overflow_dst_offset.cpp} | 24 +- ...unc_lpf_debug_put_overflow_src_offset.cpp} | 26 +- ...ug_put_read_past_source_memory_global.cpp} | 27 +- ...bug_put_read_past_source_memory_local.cpp} | 27 +- ...unc_lpf_debug_put_read_write_conflict.cpp} | 29 +- ...ug_put_read_write_conflict_among_many.cpp} | 38 +-- ... func_lpf_debug_put_too_many_requests.cpp} | 30 +- ...pf_debug_put_too_many_requests_remote.cpp} | 28 +- ..._lpf_debug_put_too_many_requests_self.cpp} | 26 +- ...> func_lpf_debug_put_unknown_dest_pid.cpp} | 28 +- ... func_lpf_debug_put_unknown_dest_slot.cpp} | 27 +- ...unc_lpf_debug_put_unknown_source_slot.cpp} | 23 +- ...past_dest_memory_global_known_at_sync.cpp} | 28 +- ..._dest_memory_global_known_before_sync.cpp} | 27 +- ...pf_debug_register_global_dst_unsynced.cpp} | 25 +- ...pf_debug_register_global_src_unsynced.cpp} | 25 +- ...unc_lpf_debug_register_global_unequal.cpp} | 19 +- ... func_lpf_debug_rehook_null_f_symbols.cpp} | 9 +- ...c => func_lpf_debug_rehook_null_input.cpp} | 9 +- ... => func_lpf_debug_rehook_null_output.cpp} | 9 +- ....c => func_lpf_debug_rehook_null_spmd.cpp} | 9 +- ...ry_register_with_size_max_minus_three.cpp} | 9 +- tests/functional/exception_list | 5 - ..._sum.c => func_bsplib_example_lpf_sum.cpp} | 25 +- ...unc_bsplib_example_lpf_sum_unsafemode.cpp} | 24 +- ...ay.c => func_bsplib_example_put_array.cpp} | 25 +- ...c_bsplib_example_put_array_unsafemode.cpp} | 25 +- ...erse.c => func_bsplib_example_reverse.cpp} | 25 +- ...unc_bsplib_example_reverse_unsafemode.cpp} | 25 +- ...tions.c => func_bsplib_get_exceptions.cpp} | 23 +- ...et_normal.c => func_bsplib_get_normal.cpp} | 23 +- ... => func_bsplib_get_normal_unsafemode.cpp} | 23 +- ... func_bsplib_get_twice_on_same_remote.cpp} | 53 ++- ...b_get_twice_on_same_remote_unsafemode.cpp} | 53 ++- ...est.c => func_bsplib_getput_same_dest.cpp} | 35 +- ...nc_bsplib_getput_same_dest_unsafemode.cpp} | 35 +- ...e.c => func_bsplib_getput_same_remote.cpp} | 33 +- ..._bsplib_getput_same_remote_unsafemode.cpp} | 33 +- ...es.c => func_bsplib_getput_zero_bytes.cpp} | 44 +-- ...pget_many.c => func_bsplib_hpget_many.cpp} | 31 +- ...pput_many.c => func_bsplib_hpput_many.cpp} | 31 +- ...end_many.c => func_bsplib_hpsend_many.cpp} | 39 +-- ...bsplib_nprocs.c => func_bsplib_nprocs.cpp} | 13 +- ...{func_bsplib_pid.c => func_bsplib_pid.cpp} | 13 +- ...c => func_bsplib_pushpopreg_ambiguous.cpp} | 23 +- ...bsplib_pushpopreg_different_variables.cpp} | 23 +- ... => func_bsplib_pushpopreg_exceptions.cpp} | 29 +- ...c => func_bsplib_pushpopreg_many_same.cpp} | 23 +- ...al.c => func_bsplib_pushpopreg_normal.cpp} | 37 +-- ...c_bsplib_pushpopreg_normal_unsafemode.cpp} | 37 +-- ...null.c => func_bsplib_pushpopreg_null.cpp} | 51 ++- ...func_bsplib_pushpopreg_pop_before_put.cpp} | 29 +- ..._pushpopreg_pop_before_put_unsafemode.cpp} | 29 +- ..._bsplib_pushpopreg_pop_on_one_process.cpp} | 19 +- ...bsplib_pushpopreg_push_on_one_process.cpp} | 15 +- ...bsplib_pushpopreg_same_growing_memory.cpp} | 53 ++- ...plib_pushpopreg_same_shrinking_memory.cpp} | 61 ++-- ...b_pushpopreg_two_pops_before_two_puts.cpp} | 35 +- ...tions.c => func_bsplib_put_exceptions.cpp} | 21 +- ...ut_normal.c => func_bsplib_put_normal.cpp} | 31 +- ... => func_bsplib_put_normal_unsafemode.cpp} | 31 +- ...y_tag.c => func_bsplib_send_empty_tag.cpp} | 69 ++-- ...g.c => func_bsplib_send_non_empty_tag.cpp} | 72 ++-- ..._send_none.c => func_bsplib_send_none.cpp} | 21 +- ..._send_null.c => func_bsplib_send_null.cpp} | 73 ++--- ...ib_send_one.c => func_bsplib_send_one.cpp} | 23 +- ....c => func_bsplib_send_one_unsafemode.cpp} | 23 +- ...=> func_bsplib_set_different_tag_size.cpp} | 13 +- ...ag_size.c => func_bsplib_set_tag_size.cpp} | 21 +- ...pt_p0.c => func_bsplib_sync_except_p0.cpp} | 13 +- ...only_p0.c => func_bsplib_sync_only_p0.cpp} | 13 +- ...unc_bsplib_time.c => func_bsplib_time.cpp} | 15 +- ...func_lpf_deregister_parallel_multiple.cpp} | 27 +- ...> func_lpf_deregister_parallel_single.cpp} | 29 +- ...ec_multiple_call_single_arg_dual_proc.cpp} | 53 ++- ...exec_nested_call_single_arg_dual_proc.cpp} | 63 ++-- ..._lpf_exec_single_call_no_arg_max_proc.cpp} | 19 +- ...f_exec_single_call_no_arg_single_proc.cpp} | 19 +- ...exec_single_call_single_arg_dual_proc.cpp} | 21 +- ...ll_single_arg_max_proc_early_exit_one.cpp} | 50 +-- ...l_single_arg_max_proc_early_exit_zero.cpp} | 27 +- ...ec_single_call_single_arg_single_proc.cpp} | 15 +- ...l.c => func_lpf_get_parallel_alltoall.cpp} | 39 ++- ..._huge.c => func_lpf_get_parallel_huge.cpp} | 41 ++- ...lpf_get_parallel_overlapping_complete.cpp} | 43 ++- ..._lpf_get_parallel_overlapping_pyramid.cpp} | 51 ++- ...f_get_parallel_overlapping_rooftiling.cpp} | 56 ++-- ...gle.c => func_lpf_get_parallel_single.cpp} | 31 +- ...irma.c => func_lpf_hook_simple.mpirma.cpp} | 31 +- ...ead.c => func_lpf_hook_simple.pthread.cpp} | 43 ++- ...imsg.c => func_lpf_hook_subset.mpimsg.cpp} | 10 +- ....mpirma.c => func_lpf_hook_tcp.mpirma.cpp} | 61 ++-- ...c => func_lpf_hook_tcp_timeout.mpirma.cpp} | 7 +- ...ull.c => func_lpf_probe_parallel_full.cpp} | 51 ++- ...d.c => func_lpf_probe_parallel_nested.cpp} | 125 ++++--- ...f_probe_root.c => func_lpf_probe_root.cpp} | 23 +- ...c => func_lpf_put_and_get_overlapping.cpp} | 41 ++- ...l.c => func_lpf_put_parallel_alltoall.cpp} | 39 ++- .../func_lpf_put_parallel_bad_pattern.c | 101 ------ ...el_big.c => func_lpf_put_parallel_big.cpp} | 23 +- ..._huge.c => func_lpf_put_parallel_huge.cpp} | 41 ++- ...lpf_put_parallel_overlapping_complete.cpp} | 43 ++- ..._lpf_put_parallel_overlapping_pyramid.cpp} | 51 ++- ...f_put_parallel_overlapping_rooftiling.cpp} | 56 ++-- ...gle.c => func_lpf_put_parallel_single.cpp} | 31 +- ...f_register_and_deregister_irregularly.cpp} | 31 +- ...f_register_and_deregister_many_global.cpp} | 19 +- ...unc_lpf_register_global_parallel_grow.cpp} | 27 +- ...lpf_register_global_parallel_multiple.cpp} | 81 +++-- ...c_lpf_register_global_parallel_shrink.cpp} | 25 +- ...unc_lpf_register_global_root_multiple.cpp} | 47 ++- ... func_lpf_register_global_root_single.cpp} | 33 +- ..._lpf_register_local_parallel_multiple.cpp} | 49 ++- ...ze_delayed_shrinking_memory_registers.cpp} | 25 +- ...size_delayed_shrinking_message_queues.cpp} | 31 +- ...ve.c => func_lpf_resize_parallel_five.cpp} | 13 +- ...t_five.c => func_lpf_resize_root_five.cpp} | 11 +- ...em.c => func_lpf_resize_root_outofmem.cpp} | 13 +- ...t_zero.c => func_lpf_resize_root_zero.cpp} | 11 +- ...ro_LPF_VERSION.c => macro_LPF_VERSION.cpp} | 7 +- tests/functional/run.sh | 299 ----------------- ...{type_lpf_spmd_t.c => type_lpf_spmd_t.cpp} | 11 +- .../{type_lpf_t.c => type_lpf_t.cpp} | 11 +- 213 files changed, 3716 insertions(+), 3936 deletions(-) delete mode 100644 cmake/googletest.cmake create mode 100644 cmake/ibverbs_init.c create mode 100644 cmake/is_openmpi.c create mode 100644 include/lpf/abort.h create mode 100644 test_launcher.py.in delete mode 100644 tests/functional/Test.h delete mode 100644 tests/functional/c99/CMakeLists.txt create mode 100644 tests/functional/collectives/CMakeLists.txt rename tests/functional/{c99/func_lpf_allcombine.c => collectives/func_lpf_allcombine.cpp} (78%) rename tests/functional/{c99/func_lpf_allgather.c => collectives/func_lpf_allgather.cpp} (71%) rename tests/functional/{c99/func_lpf_allgather_overlapped.c => collectives/func_lpf_allgather_overlapped.cpp} (75%) rename tests/functional/{c99/func_lpf_allreduce.c => collectives/func_lpf_allreduce.cpp} (78%) rename tests/functional/{c99/func_lpf_alltoall.c => collectives/func_lpf_alltoall.cpp} (70%) rename tests/functional/{c99/func_lpf_broadcast.c => collectives/func_lpf_broadcast.cpp} (76%) rename tests/functional/{c99/func_lpf_broadcast_prime_size_object.c => collectives/func_lpf_broadcast_prime_size_object.cpp} (75%) rename tests/functional/{c99/func_lpf_broadcast_small_prime_size_object.c => collectives/func_lpf_broadcast_small_prime_size_object.cpp} (76%) rename tests/functional/{c99/func_lpf_collectives_init.c => collectives/func_lpf_collectives_init.cpp} (75%) rename tests/functional/{c99/func_lpf_collectives_init_overflow.c => collectives/func_lpf_collectives_init_overflow.cpp} (82%) rename tests/functional/{c99/func_lpf_combine.c => collectives/func_lpf_combine.cpp} (79%) rename tests/functional/{c99/func_lpf_gather.c => collectives/func_lpf_gather.cpp} (74%) rename tests/functional/{c99/func_lpf_reduce.c => collectives/func_lpf_reduce.cpp} (77%) rename tests/functional/{c99/func_lpf_scatter.c => collectives/func_lpf_scatter.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_deregister_non_existing_slot.c => func_lpf_debug_deregister_non_existing_slot.cpp} (90%) rename tests/functional/debug/{func_lpf_debug_exec_null_f_symbols.c => func_lpf_debug_exec_null_f_symbols.cpp} (84%) rename tests/functional/debug/{func_lpf_debug_exec_null_input.c => func_lpf_debug_exec_null_input.cpp} (87%) rename tests/functional/debug/{func_lpf_debug_exec_null_output.c => func_lpf_debug_exec_null_output.cpp} (87%) rename tests/functional/debug/{func_lpf_debug_exec_null_spmd.c => func_lpf_debug_exec_null_spmd.cpp} (83%) rename tests/functional/debug/{func_lpf_debug_get_local_src_slot.c => func_lpf_debug_get_local_src_slot.cpp} (71%) rename tests/functional/debug/{func_lpf_debug_get_overflow_dst_offset.c => func_lpf_debug_get_overflow_dst_offset.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_get_overflow_src_offset.c => func_lpf_debug_get_overflow_src_offset.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_get_read_past_source_memory_global_known_at_sync.c => func_lpf_debug_get_read_past_source_memory_global_known_at_sync.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_get_read_past_source_memory_global_known_before_sync.c => func_lpf_debug_get_read_past_source_memory_global_known_before_sync.cpp} (70%) rename tests/functional/debug/{func_lpf_debug_get_too_many_requests.c => func_lpf_debug_get_too_many_requests.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_get_too_many_requests_remote.c => func_lpf_debug_get_too_many_requests_remote.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_get_too_many_requests_self.c => func_lpf_debug_get_too_many_requests_self.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_get_unknown_dest_slot.c => func_lpf_debug_get_unknown_dest_slot.cpp} (76%) rename tests/functional/debug/{func_lpf_debug_get_unknown_source_pid.c => func_lpf_debug_get_unknown_source_pid.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_get_unknown_source_slot.c => func_lpf_debug_get_unknown_source_slot.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_get_write_past_dest_memory_global.c => func_lpf_debug_get_write_past_dest_memory_global.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_get_write_past_dest_memory_local.c => func_lpf_debug_get_write_past_dest_memory_local.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_global_deregister_mismatch.c => func_lpf_debug_global_deregister_mismatch.cpp} (78%) rename tests/functional/debug/{func_lpf_debug_global_deregister_order_mismatch.c => func_lpf_debug_global_deregister_order_mismatch.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_global_deregister_unequal.c => func_lpf_debug_global_deregister_unequal.cpp} (79%) rename tests/functional/debug/{func_lpf_debug_global_register_null_memreg.c => func_lpf_debug_global_register_null_memreg.cpp} (90%) rename tests/functional/debug/{func_lpf_debug_hook_null_f_symbols.pthread.c => func_lpf_debug_hook_null_f_symbols.pthread.cpp} (81%) rename tests/functional/debug/{func_lpf_debug_hook_null_input.pthread.c => func_lpf_debug_hook_null_input.pthread.cpp} (80%) rename tests/functional/debug/{func_lpf_debug_hook_null_output.pthread.c => func_lpf_debug_hook_null_output.pthread.cpp} (80%) rename tests/functional/debug/{func_lpf_debug_hook_null_spmd.pthread.c => func_lpf_debug_hook_null_spmd.pthread.cpp} (78%) rename tests/functional/debug/{func_lpf_debug_local_register_null_memreg.c => func_lpf_debug_local_register_null_memreg.cpp} (84%) rename tests/functional/debug/{func_lpf_debug_put_after_deregister_dest_after_sync.c => func_lpf_debug_put_after_deregister_dest.cpp} (73%) rename tests/functional/debug/{func_lpf_debug_put_after_deregister_dest.c => func_lpf_debug_put_after_deregister_dest_after_sync.cpp} (74%) rename tests/functional/debug/{func_lpf_debug_put_after_deregister_source.c => func_lpf_debug_put_after_deregister_source.cpp} (74%) rename tests/functional/debug/{func_lpf_debug_put_after_deregister_source_after_sync.c => func_lpf_debug_put_after_deregister_source_after_sync.cpp} (73%) rename tests/functional/debug/{func_lpf_debug_put_get_too_many_requests.c => func_lpf_debug_put_get_too_many_requests.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_put_get_too_many_requests_remote.c => func_lpf_debug_put_get_too_many_requests_remote.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_put_local_dest_slot.c => func_lpf_debug_put_local_dest_slot.cpp} (76%) rename tests/functional/debug/{func_lpf_debug_put_overflow_dst_offset.c => func_lpf_debug_put_overflow_dst_offset.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_put_overflow_src_offset.c => func_lpf_debug_put_overflow_src_offset.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_put_read_past_source_memory_global.c => func_lpf_debug_put_read_past_source_memory_global.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_put_read_past_source_memory_local.c => func_lpf_debug_put_read_past_source_memory_local.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_put_read_write_conflict.c => func_lpf_debug_put_read_write_conflict.cpp} (74%) rename tests/functional/debug/{func_lpf_debug_put_read_write_conflict_among_many.c => func_lpf_debug_put_read_write_conflict_among_many.cpp} (73%) rename tests/functional/debug/{func_lpf_debug_put_too_many_requests.c => func_lpf_debug_put_too_many_requests.cpp} (75%) rename tests/functional/debug/{func_lpf_debug_put_too_many_requests_remote.c => func_lpf_debug_put_too_many_requests_remote.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_put_too_many_requests_self.c => func_lpf_debug_put_too_many_requests_self.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_put_unknown_dest_pid.c => func_lpf_debug_put_unknown_dest_pid.cpp} (77%) rename tests/functional/debug/{func_lpf_debug_put_unknown_dest_slot.c => func_lpf_debug_put_unknown_dest_slot.cpp} (76%) rename tests/functional/debug/{func_lpf_debug_put_unknown_source_slot.c => func_lpf_debug_put_unknown_source_slot.cpp} (78%) rename tests/functional/debug/{func_lpf_debug_put_write_past_dest_memory_global_known_at_sync.c => func_lpf_debug_put_write_past_dest_memory_global_known_at_sync.cpp} (73%) rename tests/functional/debug/{func_lpf_debug_put_write_past_dest_memory_global_known_before_sync.c => func_lpf_debug_put_write_past_dest_memory_global_known_before_sync.cpp} (74%) rename tests/functional/debug/{func_lpf_debug_register_global_dst_unsynced.c => func_lpf_debug_register_global_dst_unsynced.cpp} (76%) rename tests/functional/debug/{func_lpf_debug_register_global_src_unsynced.c => func_lpf_debug_register_global_src_unsynced.cpp} (76%) rename tests/functional/debug/{func_lpf_debug_register_global_unequal.c => func_lpf_debug_register_global_unequal.cpp} (81%) rename tests/functional/debug/{func_lpf_debug_rehook_null_f_symbols.c => func_lpf_debug_rehook_null_f_symbols.cpp} (89%) rename tests/functional/debug/{func_lpf_debug_rehook_null_input.c => func_lpf_debug_rehook_null_input.cpp} (89%) rename tests/functional/debug/{func_lpf_debug_rehook_null_output.c => func_lpf_debug_rehook_null_output.cpp} (89%) rename tests/functional/debug/{func_lpf_debug_rehook_null_spmd.c => func_lpf_debug_rehook_null_spmd.cpp} (87%) rename tests/functional/debug/{func_lpf_debug_resize_memory_register_with_size_max_minus_three.c => func_lpf_debug_resize_memory_register_with_size_max_minus_three.cpp} (85%) delete mode 100644 tests/functional/exception_list rename tests/functional/{func_bsplib_example_lpf_sum.c => func_bsplib_example_lpf_sum.cpp} (78%) rename tests/functional/{func_bsplib_example_lpf_sum_unsafemode.c => func_bsplib_example_lpf_sum_unsafemode.cpp} (78%) rename tests/functional/{func_bsplib_example_put_array.c => func_bsplib_example_put_array.cpp} (78%) rename tests/functional/{func_bsplib_example_put_array_unsafemode.c => func_bsplib_example_put_array_unsafemode.cpp} (78%) rename tests/functional/{func_bsplib_example_reverse.c => func_bsplib_example_reverse.cpp} (73%) rename tests/functional/{func_bsplib_example_reverse_unsafemode.c => func_bsplib_example_reverse_unsafemode.cpp} (73%) rename tests/functional/{func_bsplib_get_exceptions.c => func_bsplib_get_exceptions.cpp} (74%) rename tests/functional/{func_bsplib_get_normal.c => func_bsplib_get_normal.cpp} (79%) rename tests/functional/{func_bsplib_get_normal_unsafemode.c => func_bsplib_get_normal_unsafemode.cpp} (79%) rename tests/functional/{func_bsplib_get_twice_on_same_remote.c => func_bsplib_get_twice_on_same_remote.cpp} (66%) rename tests/functional/{func_bsplib_get_twice_on_same_remote_unsafemode.c => func_bsplib_get_twice_on_same_remote_unsafemode.cpp} (66%) rename tests/functional/{func_bsplib_getput_same_dest.c => func_bsplib_getput_same_dest.cpp} (69%) rename tests/functional/{func_bsplib_getput_same_dest_unsafemode.c => func_bsplib_getput_same_dest_unsafemode.cpp} (68%) rename tests/functional/{func_bsplib_getput_same_remote.c => func_bsplib_getput_same_remote.cpp} (69%) rename tests/functional/{func_bsplib_getput_same_remote_unsafemode.c => func_bsplib_getput_same_remote_unsafemode.cpp} (69%) rename tests/functional/{func_bsplib_getput_zero_bytes.c => func_bsplib_getput_zero_bytes.cpp} (72%) rename tests/functional/{func_bsplib_hpget_many.c => func_bsplib_hpget_many.cpp} (75%) rename tests/functional/{func_bsplib_hpput_many.c => func_bsplib_hpput_many.cpp} (75%) rename tests/functional/{func_bsplib_hpsend_many.c => func_bsplib_hpsend_many.cpp} (76%) rename tests/functional/{func_bsplib_nprocs.c => func_bsplib_nprocs.cpp} (83%) rename tests/functional/{func_bsplib_pid.c => func_bsplib_pid.cpp} (84%) rename tests/functional/{func_bsplib_pushpopreg_ambiguous.c => func_bsplib_pushpopreg_ambiguous.cpp} (77%) rename tests/functional/{func_bsplib_pushpopreg_different_variables.c => func_bsplib_pushpopreg_different_variables.cpp} (76%) rename tests/functional/{func_bsplib_pushpopreg_exceptions.c => func_bsplib_pushpopreg_exceptions.cpp} (73%) rename tests/functional/{func_bsplib_pushpopreg_many_same.c => func_bsplib_pushpopreg_many_same.cpp} (79%) rename tests/functional/{func_bsplib_pushpopreg_normal.c => func_bsplib_pushpopreg_normal.cpp} (68%) rename tests/functional/{func_bsplib_pushpopreg_normal_unsafemode.c => func_bsplib_pushpopreg_normal_unsafemode.cpp} (68%) rename tests/functional/{func_bsplib_pushpopreg_null.c => func_bsplib_pushpopreg_null.cpp} (67%) rename tests/functional/{func_bsplib_pushpopreg_pop_before_put.c => func_bsplib_pushpopreg_pop_before_put.cpp} (71%) rename tests/functional/{func_bsplib_pushpopreg_pop_before_put_unsafemode.c => func_bsplib_pushpopreg_pop_before_put_unsafemode.cpp} (71%) rename tests/functional/{func_bsplib_pushpopreg_pop_on_one_process.c => func_bsplib_pushpopreg_pop_on_one_process.cpp} (77%) rename tests/functional/{func_bsplib_pushpopreg_push_on_one_process.c => func_bsplib_pushpopreg_push_on_one_process.cpp} (81%) rename tests/functional/{func_bsplib_pushpopreg_same_growing_memory.c => func_bsplib_pushpopreg_same_growing_memory.cpp} (66%) rename tests/functional/{func_bsplib_pushpopreg_same_shrinking_memory.c => func_bsplib_pushpopreg_same_shrinking_memory.cpp} (66%) rename tests/functional/{func_bsplib_pushpopreg_two_pops_before_two_puts.c => func_bsplib_pushpopreg_two_pops_before_two_puts.cpp} (68%) rename tests/functional/{func_bsplib_put_exceptions.c => func_bsplib_put_exceptions.cpp} (76%) rename tests/functional/{func_bsplib_put_normal.c => func_bsplib_put_normal.cpp} (73%) rename tests/functional/{func_bsplib_put_normal_unsafemode.c => func_bsplib_put_normal_unsafemode.cpp} (73%) rename tests/functional/{func_bsplib_send_empty_tag.c => func_bsplib_send_empty_tag.cpp} (63%) rename tests/functional/{func_bsplib_send_non_empty_tag.c => func_bsplib_send_non_empty_tag.cpp} (61%) rename tests/functional/{func_bsplib_send_none.c => func_bsplib_send_none.cpp} (77%) rename tests/functional/{func_bsplib_send_null.c => func_bsplib_send_null.cpp} (62%) rename tests/functional/{func_bsplib_send_one.c => func_bsplib_send_one.cpp} (76%) rename tests/functional/{func_bsplib_send_one_unsafemode.c => func_bsplib_send_one_unsafemode.cpp} (75%) rename tests/functional/{func_bsplib_set_different_tag_size.c => func_bsplib_set_different_tag_size.cpp} (83%) rename tests/functional/{func_bsplib_set_tag_size.c => func_bsplib_set_tag_size.cpp} (78%) rename tests/functional/{func_bsplib_sync_except_p0.c => func_bsplib_sync_except_p0.cpp} (83%) rename tests/functional/{func_bsplib_sync_only_p0.c => func_bsplib_sync_only_p0.cpp} (83%) rename tests/functional/{func_bsplib_time.c => func_bsplib_time.cpp} (83%) rename tests/functional/{func_lpf_deregister_parallel_multiple.c => func_lpf_deregister_parallel_multiple.cpp} (78%) rename tests/functional/{func_lpf_deregister_parallel_single.c => func_lpf_deregister_parallel_single.cpp} (76%) rename tests/functional/{func_lpf_exec_multiple_call_single_arg_dual_proc.c => func_lpf_exec_multiple_call_single_arg_dual_proc.cpp} (60%) rename tests/functional/{func_lpf_exec_nested_call_single_arg_dual_proc.c => func_lpf_exec_nested_call_single_arg_dual_proc.cpp} (58%) rename tests/functional/{func_lpf_exec_single_call_no_arg_max_proc.c => func_lpf_exec_single_call_no_arg_max_proc.cpp} (70%) rename tests/functional/{func_lpf_exec_single_call_no_arg_single_proc.c => func_lpf_exec_single_call_no_arg_single_proc.cpp} (70%) rename tests/functional/{func_lpf_exec_single_call_single_arg_dual_proc.c => func_lpf_exec_single_call_single_arg_dual_proc.cpp} (73%) rename tests/functional/{func_lpf_exec_single_call_single_arg_max_proc_early_exit_one.c => func_lpf_exec_single_call_single_arg_max_proc_early_exit_one.cpp} (66%) rename tests/functional/{func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero.c => func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero.cpp} (68%) rename tests/functional/{func_lpf_exec_single_call_single_arg_single_proc.c => func_lpf_exec_single_call_single_arg_single_proc.cpp} (79%) rename tests/functional/{func_lpf_get_parallel_alltoall.c => func_lpf_get_parallel_alltoall.cpp} (73%) rename tests/functional/{func_lpf_get_parallel_huge.c => func_lpf_get_parallel_huge.cpp} (73%) rename tests/functional/{func_lpf_get_parallel_overlapping_complete.c => func_lpf_get_parallel_overlapping_complete.cpp} (72%) rename tests/functional/{func_lpf_get_parallel_overlapping_pyramid.c => func_lpf_get_parallel_overlapping_pyramid.cpp} (74%) rename tests/functional/{func_lpf_get_parallel_overlapping_rooftiling.c => func_lpf_get_parallel_overlapping_rooftiling.cpp} (74%) rename tests/functional/{func_lpf_get_parallel_single.c => func_lpf_get_parallel_single.cpp} (74%) rename tests/functional/{func_lpf_hook_simple.mpirma.c => func_lpf_hook_simple.mpirma.cpp} (76%) rename tests/functional/{func_lpf_hook_simple.pthread.c => func_lpf_hook_simple.pthread.cpp} (72%) rename tests/functional/{func_lpf_hook_subset.mpimsg.c => func_lpf_hook_subset.mpimsg.cpp} (92%) rename tests/functional/{func_lpf_hook_tcp.mpirma.c => func_lpf_hook_tcp.mpirma.cpp} (71%) rename tests/functional/{func_lpf_hook_tcp_timeout.mpirma.c => func_lpf_hook_tcp_timeout.mpirma.cpp} (91%) rename tests/functional/{func_lpf_probe_parallel_full.c => func_lpf_probe_parallel_full.cpp} (52%) rename tests/functional/{func_lpf_probe_parallel_nested.c => func_lpf_probe_parallel_nested.cpp} (59%) rename tests/functional/{func_lpf_probe_root.c => func_lpf_probe_root.cpp} (58%) rename tests/functional/{func_lpf_put_and_get_overlapping.c => func_lpf_put_and_get_overlapping.cpp} (74%) rename tests/functional/{func_lpf_put_parallel_alltoall.c => func_lpf_put_parallel_alltoall.cpp} (73%) delete mode 100644 tests/functional/func_lpf_put_parallel_bad_pattern.c rename tests/functional/{func_lpf_put_parallel_big.c => func_lpf_put_parallel_big.cpp} (84%) rename tests/functional/{func_lpf_put_parallel_huge.c => func_lpf_put_parallel_huge.cpp} (73%) rename tests/functional/{func_lpf_put_parallel_overlapping_complete.c => func_lpf_put_parallel_overlapping_complete.cpp} (71%) rename tests/functional/{func_lpf_put_parallel_overlapping_pyramid.c => func_lpf_put_parallel_overlapping_pyramid.cpp} (74%) rename tests/functional/{func_lpf_put_parallel_overlapping_rooftiling.c => func_lpf_put_parallel_overlapping_rooftiling.cpp} (74%) rename tests/functional/{func_lpf_put_parallel_single.c => func_lpf_put_parallel_single.cpp} (74%) rename tests/functional/{func_lpf_register_and_deregister_irregularly.c => func_lpf_register_and_deregister_irregularly.cpp} (76%) rename tests/functional/{func_lpf_register_and_deregister_many_global.c => func_lpf_register_and_deregister_many_global.cpp} (81%) rename tests/functional/{func_lpf_register_global_parallel_grow.c => func_lpf_register_global_parallel_grow.cpp} (77%) rename tests/functional/{func_lpf_register_global_parallel_multiple.c => func_lpf_register_global_parallel_multiple.cpp} (60%) rename tests/functional/{func_lpf_register_global_parallel_shrink.c => func_lpf_register_global_parallel_shrink.cpp} (82%) rename tests/functional/{func_lpf_register_global_root_multiple.c => func_lpf_register_global_root_multiple.cpp} (65%) rename tests/functional/{func_lpf_register_global_root_single.c => func_lpf_register_global_root_single.cpp} (70%) rename tests/functional/{func_lpf_register_local_parallel_multiple.c => func_lpf_register_local_parallel_multiple.cpp} (69%) rename tests/functional/{func_lpf_resize_delayed_shrinking_memory_registers.c => func_lpf_resize_delayed_shrinking_memory_registers.cpp} (77%) rename tests/functional/{func_lpf_resize_delayed_shrinking_message_queues.c => func_lpf_resize_delayed_shrinking_message_queues.cpp} (75%) rename tests/functional/{func_lpf_resize_parallel_five.c => func_lpf_resize_parallel_five.cpp} (84%) rename tests/functional/{func_lpf_resize_root_five.c => func_lpf_resize_root_five.cpp} (84%) rename tests/functional/{func_lpf_resize_root_outofmem.c => func_lpf_resize_root_outofmem.cpp} (81%) rename tests/functional/{func_lpf_resize_root_zero.c => func_lpf_resize_root_zero.cpp} (84%) rename tests/functional/{macro_LPF_VERSION.c => macro_LPF_VERSION.cpp} (90%) delete mode 100755 tests/functional/run.sh rename tests/functional/{type_lpf_spmd_t.c => type_lpf_spmd_t.cpp} (86%) rename tests/functional/{type_lpf_t.c => type_lpf_t.cpp} (82%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00b78dde..844a4499 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ # limitations under the License. # -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.29.0 FATAL_ERROR) project(LPF C CXX ASM) # Version info @@ -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") @@ -105,18 +105,6 @@ set( INSTALL_HEADERS "${prefix}/include" CACHE PATH "Installation path for header files" ) message( STATUS "Installation directory prefix is ${prefix}") -# C++ standard -find_file(TR1_ARRAY "tr1/array") -if (TR1_ARRAY) - message(STATUS "Governing C++ standard is C++98/TR1") - set(CMAKE_CXX_STANDARD 98) - set(CMAKE_CXX_STANDARD_REQUIRED YES) -else() - message(STATUS "Governing C++ standard is C++11") - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED YES) -endif() - # Dependencies set(ENGINES) find_library( LIB_POSIX_THREADS @@ -173,9 +161,6 @@ if ( MPI_FOUND ) if ( NOT MPI_IS_THREAD_COMPAT OR NOT MPI_IS_NOT_OPENMPI1 ) message( WARNING "MPI implementation does not tolerate any threading. Hybrid implementation will not be built") endif() - if ( NOT MPI_OPEN_PORT ) - message( WARNING "MPI implementation does not support dynamically connecting separate MPI processes. Hence, lpf_mpi_initialize_over_tcp will always fail.") - endif() if ( NOT MPI_IBARRIER ) message( WARNING "MPI implementation does not have MPI_Ibarrier, which is required to use the dense all-to-all algorithm on large (> 2 GB) meta-data exchanges") endif() @@ -189,7 +174,7 @@ if ( LIB_MATH AND LIB_DL AND MPI_FOUND ) list(APPEND ENGINES "mpirma") endif() - if (LIB_IBVERBS) + if (ENABLE_IBVERBS) list(APPEND ENGINES "ibverbs") endif() @@ -197,10 +182,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 LIB_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}") @@ -223,6 +227,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() @@ -246,59 +251,19 @@ add_definitions(-DBSPLIB_DLL=1) 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) + +# C++ standard -- Google tests require newer C++ standard than C++11 if (LPF_ENABLE_TESTS) -message(STATUS "Unit and API tests will be built") - -# set testing timeout to 60 seconds -set(CMAKE_TESTING_TIMEOUT 60) - -# import Google Testing Framework -include(cmake/googletest.cmake) - -# Have directory to gather all the tests results -file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/junit) -set(test_output "${CMAKE_BINARY_DIR}/junit") - -# Have a macro to add a unit test -function(add_gtest testName) - add_executable(${testName} ${ARGN}) - target_link_libraries(${testName} gtest_main) - add_test(${testName} ${testName} --gtest_output=xml:${test_output}/ ) -endfunction(add_gtest) - -# Have a macro to add a unit test that should run with MPI -if (MPI_FOUND) - function(add_gtest_mpi testName nprocs) - add_executable(${testName} ${ARGN}) - target_link_libraries(${testName} ${MPI_C_LIBRARIES} gtest_main) - foreach( p ${nprocs}) - set(mpmd) - foreach( i RANGE 1 ${p}) - if (i GREATER 1) - set(mpmd ${mpmd} ":") - endif() - set(mpmd ${mpmd} ${MPIEXEC_NUMPROC_FLAG} 1 ${MPIEXEC_PREFLAGS} - ./${testName} --gtest_output=xml:${test_output}/${testName}_${i}of${p}.xml) - endforeach(i) - add_test(NAME ${testName}_${p} - COMMAND ${MPIRUN} ${mpmd} - ) - endforeach(p) - endfunction(add_gtest_mpi) -endif(MPI_FOUND) - -# Enable testing in CMake -enable_testing() -else(LPF_ENABLE_TESTS) - message(STATUS "Unit and API tests will *not* be built") - function(add_gtest testName) - # Do nothing because tests are disabled - endfunction(add_gtest) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED YES) +else() + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED YES) +endif() - function(add_gtest_mpi testName nprocs) - # DO nothing because tests are disabled - endfunction(add_gtest_mpi) -endif(LPF_ENABLE_TESTS) # Handling of compiler flags function(target_add_compilation_flags target visibility) @@ -367,16 +332,42 @@ endfunction(target_compile_flags) set(lpf_cflags) set(lpf_lib_link_flags) set(lpf_exe_link_flags) -include_directories(include) -include_directories(src/common) -add_subdirectory(src) + +# 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) @@ -384,14 +375,142 @@ function( target_link_exe_with_core target ) endif() set(corelib "lpf_core_univ_${engine}_${LPFLIB_CONFIG_NAME}") - target_link_libraries(${target} ${corelib}) + if ("${engine}" STREQUAL "pthread") + target_link_libraries(${target} ${corelib}) + else() + target_link_libraries(${target} ${corelib} ${MPI_C_LIBRARIES}) + endif() target_compile_flags(${target} PRIVATE ${LPF_CORE_COMPILE_FLAGS}) set_target_properties(${target} PROPERTIES - LINK_FLAGS "${LPF_CORE_LIB_LINK_FLAGS} ${LPF_CORE_EXE_LINK_FLAGS}" - LINKER_LANGUAGE CXX - ) + LINK_FLAGS "${LPF_CORE_LIB_LINK_FLAGS} ${LPF_CORE_EXE_LINK_FLAGS}" + LINKER_LANGUAGE CXX + ) endfunction() +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)") + 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 + include(FetchContent) + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + # This tag corresponds to GoogleTest 1.15.0 release + GIT_TAG e397860 + ) + FetchContent_MakeAvailable(googletest) + + endif() + # set testing timeout to 60 seconds + set(CMAKE_TESTING_TIMEOUT 60) + + # Have directory to gather all the tests results + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/junit) + set(test_output "${CMAKE_BINARY_DIR}/junit") + + 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}) + + # 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) + +else(LPF_ENABLE_TESTS) + message(STATUS "Unit and API tests will *not* be built") + function(add_gtest testName ENGINE debug testSource ) + # Do nothing because tests are disabled + endfunction(add_gtest) + +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) @@ -432,7 +551,7 @@ set( lpf_proxy_dummy ${CMAKE_CURRENT_BINARY_DIR}/src/MPI/lpf_proxy_dummy) set( lpf_probe ${CMAKE_CURRENT_BINARY_DIR}/src/utils/lpfprobe) set( lpfrun ${CMAKE_CURRENT_BINARY_DIR}/lpfrun_build) set( lpfcore ${CMAKE_CURRENT_BINARY_DIR}/src/*/liblpf_core_univ_ENGINE_${LPFLIB_CONFIG_NAME}${SOSUFFIX} ) -configure_file( lpfrun.in lpfrun_build @ONLY) +configure_file( lpfrun.in lpfrun_build FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE @ONLY) configure_file( lpfproxy.in lpfproxy_build @ONLY) configure_file( lpfprobe.in lpfprobe_build @ONLY) diff --git a/README b/README index 9fd8463d..b0a5b33d 100644 --- a/README +++ b/README @@ -28,9 +28,9 @@ Prerequisites Mandatory - GNU/Linux, - GNU C compiler, - - GNU C++ compiler (C++03/TR1 or C++11), + - GNU C++ compiler (C++11 compatible; however, C++17 compatible with tests enabled) - GNU Make, - - CMake 3.1 or better. + - CMake 3.29.0 or better. Optional MPI engine requires - MPI-3, such as 'MPICH', 'OpenMPI', or 'MVAPICH'. @@ -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, diff --git a/bootstrap.sh b/bootstrap.sh index e641e56e..1bc1835c 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -87,7 +87,7 @@ installdir="$builddir" config=Release doc=OFF functests=OFF -googletest_license_agreement=NO +googletest_license_agreement=FALSE perftests=OFF reconfig=no CMAKE_EXE=cmake @@ -133,7 +133,7 @@ do ------------------------------------------------------------------------------ The functional test suite requires Google Testing Framework which comes with its own license. The license can be viewed via - https://github.com/google/googletest/blob/release-1.8.1/LICENSE + https://github.com/google/googletest/blob/v1.15.x/LICENSE Do you agree with the license [yes/no] ? EOF read answer @@ -154,7 +154,7 @@ User agrees with Google Testing Framework license. It will be downloaded during the build. ============================================================================== EOF - googletest_license_agreement=YES + googletest_license_agreement=TRUE fi shift @@ -162,7 +162,7 @@ EOF --functests=i-agree-with-googletest-license) functests=ON - googletest_license_agreement=YES + googletest_license_agreement=TRUE shift ;; @@ -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; ;; @@ -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; } diff --git a/cmake/googletest.cmake b/cmake/googletest.cmake deleted file mode 100644 index 14135c2f..00000000 --- a/cmake/googletest.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright 2021 Huawei Technologies Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -include(ExternalProject) -set(gtest_prefix "${CMAKE_CURRENT_BINARY_DIR}/gtest") -set(GTEST_DOWNLOAD_URL - "https://github.com/google/googletest/archive/release-1.8.1.tar.gz" - CACHE STRING "File location or URL from where to download Google Test") -set(GTEST_LICENSE_URL - "https://github.com/google/googletest/blob/release-1.8.1/LICENSE" - CACHE STRING "File location or URL to license file of Google Test") -option(GTEST_AGREE_TO_LICENSE - "User agreement with license of Google Testing Framework, available at ${GOOGLE_LICENSE_URL}" - OFF) - -if (NOT GTEST_AGREE_TO_LICENSE) - message(SEND_ERROR "The LPF test suite requires agreement with the license of Google Test. Either disable LPF_ENABLE_TESTS or agree with the license by enabling GTEST_AGREE_TO_LICENSE") -endif() - -ExternalProject_Add( - GoogleTest - PREFIX ${gtest_prefix} - INSTALL_DIR ${gtest_prefix} - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${gtest_prefix} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -Dgtest_disable_pthreads=ON - URL ${GTEST_DOWNLOAD_URL} - EXCLUDE_FROM_ALL YES) -ExternalProject_Add_StepTargets(GoogleTest install) -add_library(gtest_main STATIC IMPORTED) -add_dependencies(gtest_main GoogleTest-install) -add_library(gtest STATIC IMPORTED) -add_dependencies(gtest GoogleTest-install) - -# In order to prevent failure of the next set_target_properties -# INTERFACE_INCLUDE_DIRECTORIES, make this directory before it is made by the -# GoogleTest external project -file(MAKE_DIRECTORY ${gtest_prefix}/include) -set_target_properties(gtest_main - PROPERTIES IMPORTED_LOCATION ${gtest_prefix}/${CMAKE_INSTALL_LIBDIR}/libgtest_main.a - INTERFACE_INCLUDE_DIRECTORIES ${gtest_prefix}/include - INTERFACE_LINK_LIBRARIES ${gtest_prefix}/${CMAKE_INSTALL_LIBDIR}/libgtest.a) -set_target_properties(gtest - PROPERTIES IMPORTED_LOCATION ${gtest_prefix}/${CMAKE_INSTALL_LIBDIR}/libgtest.a - INTERFACE_INCLUDE_DIRECTORIES ${gtest_prefix}/include) diff --git a/cmake/ibverbs_init.c b/cmake/ibverbs_init.c new file mode 100644 index 00000000..f38be9dc --- /dev/null +++ b/cmake/ibverbs_init.c @@ -0,0 +1,19 @@ +#include "infiniband/verbs.h" +#include + +int main(int argc, char** argv) +{ + + int numDevices = -1; + struct ibv_device * * const try_get_device_list = ibv_get_device_list( &numDevices ); + + if (!try_get_device_list) { + abort(); + } + + if (numDevices < 1) { + abort(); + } + + return 0; +} diff --git a/cmake/is_openmpi.c b/cmake/is_openmpi.c new file mode 100644 index 00000000..d3ed13c9 --- /dev/null +++ b/cmake/is_openmpi.c @@ -0,0 +1,12 @@ +#include "mpi.h" +#include + +#ifdef OMPI_MAJOR_VERSION + +int main() { + printf("The OMPI_MAJOR_VERSION is %d\n", OMPI_MAJOR_VERSION); + return 0; +} +#else +#error This is not Open MPI +#endif diff --git a/cmake/mpi.cmake b/cmake/mpi.cmake index 71b184c1..f8d55851 100644 --- a/cmake/mpi.cmake +++ b/cmake/mpi.cmake @@ -78,6 +78,14 @@ if (MPI_FOUND) -DINCLUDE_DIRECTORIES:STRING=${MPI_C_INCLUDE_PATH} ) + try_compile( IS_OPENMPI "${CMAKE_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/is_openmpi.c" + LINK_LIBRARIES ${MPI_C_LIBRARIES} + CMAKE_FLAGS + -DCMAKE_C_FLAGS:STRING=${MPI_C_COMPILE_FLAGS} + -DCMAKE_EXE_LINKER_FLAGS:STRING=${MPI_C_LINK_FLAGS} + -DINCLUDE_DIRECTORIES:STRING=${MPI_C_INCLUDE_PATH} + ) try_run( MPI_IS_THREAD_COMPAT_RC MPI_IS_THREAD_COMPAT_COMPILES ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/mpi_is_thread_compat.c @@ -153,4 +161,26 @@ if (MPI_FOUND) endif() +if (LIB_IBVERBS) +try_run( IBVERBS_INIT_RUNS IBVERBS_INIT_COMPILES + ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ibverbs_init.c + LINK_LIBRARIES ${LIB_IBVERBS} + ARGS ${MPIRUN} + ) +endif() + +set(ENABLE_IBVERBS FALSE) +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() diff --git a/doc/lpf_core.cfg.in b/doc/lpf_core.cfg.in index 0a8de71c..bfb940b2 100644 --- a/doc/lpf_core.cfg.in +++ b/doc/lpf_core.cfg.in @@ -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 diff --git a/include/debug/lpf/core.h b/include/debug/lpf/core.h index 028e015f..ff2306c6 100644 --- a/include/debug/lpf/core.h +++ b/include/debug/lpf/core.h @@ -70,6 +70,9 @@ extern "C" { #define lpf_resize_message_queue( ctx, size ) \ lpf_debug_resize_message_queue( __FILE__, __LINE__, (ctx), (size) ) +#define lpf_abort( ctx ) \ + lpf_debug_abort( __FILE__, __LINE__, (ctx)) + extern _LPFLIB_API lpf_err_t lpf_debug_exec( const char * file, int line, @@ -133,6 +136,9 @@ extern _LPFLIB_API lpf_err_t lpf_debug_resize_message_queue( const char * file, int line, lpf_t ctx, size_t max_msgs ); +extern _LPFLIB_API +lpf_err_t lpf_debug_abort( const char * file, int line, lpf_t ctx); + #ifdef __cplusplus } #endif diff --git a/include/lpf/abort.h b/include/lpf/abort.h new file mode 100644 index 00000000..383a6ab8 --- /dev/null +++ b/include/lpf/abort.h @@ -0,0 +1,152 @@ + +/* + * Copyright 2021 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LPFLIB_ABORT_H +#define LPFLIB_ABORT_H + +#include "lpf/static_dispatch.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** \addtogroup LPF_EXTENSIONS LPF API extensions + * @{ + * + * \defgroup LPF_ABORT Functionality for aborting LPF applications + * + * If #LPF_HAS_ABORT has a nonzero value, then a call to #lpf_abort from any + * process in a distributed application, will abort the entire application. + * + * \note As with all LPF extensions, it is \em not mandatory for all LPF + * implementations to support this one. + * + * If #LPF_HAS_ABORT has a zero value, then a call to #lpf_abort shall have no + * other effect than it returning #LPF_SUCCESS. + * + * Therefore, + * - LPF implementations that cannot support an abort functionality may still + * provide a valid, albeit trivial, implementation of this extension. + * - LPF applications that aim to rely on #lpf_abort should first ensure that + * #LPF_HAS_ABORT is nonzero. + * + * \warning Portable LPF implementations best not rely on #lpf_abort at all. + * Although sometimes unavoidable, the recommendation is to avoid the + * use of this extension as best as possible. + * + * \note One case where #lpf_abort is absolutely required is for \em testing an + * LPF debug layer. Such a layer should detect erroneous usage, report it, + * but then typically cannot continue execution. In this case, relying on + * the standard abort or exit functionalities to terminate the process the + * error was detected at, typically results in implementation-specific + * (i.e., undefined) behaviour with regards to how the application at + * large terminates. This means that a test-suite for such a debug layer + * cannot reliably detect whether a distributed application has terminated + * for the expected reasons. In this case, #lpf_abort provides a reliable + * mechanism that such a test requires. + * + * @{ + */ + +/** + * Whether the active LPF engine supports aborting distributed applications. + * + * If the value of this field is zero (0), then a call to #lpf_abort will be a + * no-op and always return #LPF_SUCCESS. + */ +extern _LPFLIB_VAR const int LPF_HAS_ABORT ; + +/** + * A call to this function aborts the distributed application as soon as + * possible. + * + * \warning This function corresponds to a no-op if #LPF_HAS_ABORT equals zero. + * + * The below specification only applies when #LPF_HAS_ABORT contains a non-zero + * value; otherwise, a call to this function will have no other effect besides + * returning #LPF_SUCCESS. + * + * \note Rationale: the capability to abort relies on the software stack that + * underlies LPF, and in aiming to be a minimal API, LPF does not wish to + * force such a capabilities unto the underlying software or system. + * + * \note Applications that rely on #lpf_abort therefore should first check if + * the capability is supported. + * + * \note The recommended way to abort LPF applications that is fully supported + * by the core specification alone (i.e., excluding this #lpf_abort + * extension), is to simply exit the process that should be aborted. + * Compliant LPF implementations will then quit sibling processes at + * latest at a call to #lpf_sync that should handle communications + * with the exited process. Sibling processes may also exit early without + * involvement of LPF. In all cases, the parent call to #lpf_exec, + * #lpf_hook, or #lpf_rehook should return with #LPF_ERR_FATAL. + * + * \warning Therefore, whenever possible, code implemented on top of LPF ideally + * does not rely on #lpf_abort. Instead, error handling more reliably + * could be implemented on top of the above-described default LPF + * behaviour. + * + * The call to #lpf_abort differs from the stdlib abort; for example, + * implementations are not required to raise SIGABRT as part of a call to + * #lpf_abort. Instead, the requirements are that: + * 1. processes that call this function terminate during the call to + * #lpf_abort; + * 2. all other processes associated with the distributed application terminate + * at latest during a next call to #lpf_sync that should have handled + * communications with any aborted process; + * 3. regardless of whether LPF aborted sibling processes, whether they exited + * gracefully, or whether they also called #lpf_abort, the process(es) which + * made the parent call to #lpf_exec, #lpf_hook, or #lpf_rehook should + * either: a) terminate also, at latest when all (other) associated + * processes have terminated, (exclusive-)or b) return #LPF_ERR_FATAL. + * Which behaviour (a or b) will be followed is up to the implementation, + * and portable applications should account for both possibilities. + * + * \note In the above, \em other is between parenthesis since the processes + * executing the application may be fully disjoint from the process that + * spawned the application. In this case it is natural to elect that the + * spawning process returns #LPF_ERR_FATAL, though under this + * specification also that process may be aborted before the spawning + * call returns. + * + * \note If one of the associated processes deadlock (e.g. due to executing + * while(1){}), it shall remain undefined when the entire + * application aborts. Implementations shall make a best effort to do this + * as early as possible. + * + * \note Though implied by the above, we note explicitly that #lpf_abort is + * \em not a collective function; a single process calling #lpf_abort can + * terminate all associated processes. + * + * @returns #LPF_SUCCESS If and only if #LPF_HAS_ABORT equals zero. + * + * If #LPF_HAS_ABORT is nonzero, then this function shall not return. + */ +extern _LPFLIB_API +lpf_err_t lpf_abort(lpf_t ctx); + +/** + * @} + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/lpf/core.h b/include/lpf/core.h index 42872f15..9c0d1da8 100644 --- a/include/lpf/core.h +++ b/include/lpf/core.h @@ -126,6 +126,8 @@ * - \ref LPF_EXTENSIONS * - \ref LPF_PTHREAD * - \ref LPF_MPI + * - \ref LPF_HYBRID + * - \ref LPF_ABORT * - \ref LPF_HL * - \ref LPF_BSPLIB * - \ref LPF_COLLECTIVES diff --git a/include/lpf/hybrid.h b/include/lpf/hybrid.h index 00845f08..4c324adf 100644 --- a/include/lpf/hybrid.h +++ b/include/lpf/hybrid.h @@ -28,7 +28,7 @@ extern "C" { * * @{ * - * \defgroup LPF_HYBRID Specific to Hybrid implementation + * \defgroup LPF_HYBRID Specific to the hybrid engine * * @{ */ diff --git a/include/lpf/pthread.h b/include/lpf/pthread.h index ba68f3f8..454eaf0e 100644 --- a/include/lpf/pthread.h +++ b/include/lpf/pthread.h @@ -28,7 +28,7 @@ extern "C" { * * @{ * - * \defgroup LPF_PTHREAD Specific to Pthreads + * \defgroup LPF_PTHREAD Specific to the Pthreads engine * * @{ */ diff --git a/include/lpf/static_dispatch.h b/include/lpf/static_dispatch.h index 8df6a092..e9eea40b 100644 --- a/include/lpf/static_dispatch.h +++ b/include/lpf/static_dispatch.h @@ -49,6 +49,7 @@ #undef lpf_exec #undef lpf_hook #undef lpf_rehook +#undef lpf_abort #undef lpf_init_t #undef lpf_pid_t @@ -77,6 +78,7 @@ #undef LPF_NONE #undef LPF_INIT_NONE #undef LPF_NO_ARGS +#undef LPF_HAS_ABORT #ifdef LPF_FUNC @@ -92,6 +94,7 @@ #define lpf_exec LPF_FUNC(exec) #define lpf_hook LPF_FUNC(hook) #define lpf_rehook LPF_FUNC(rehook) +#define lpf_abort LPF_FUNC(abort) #define lpf_init_t LPF_TYPE(init_t) #define lpf_pid_t LPF_TYPE(pid_t) @@ -120,6 +123,7 @@ #define LPF_NONE LPF_CONST(NONE) #define LPF_INIT_NONE LPF_CONST(INIT_NONE) #define LPF_NO_ARGS LPF_CONST(NO_ARGS) +#define LPF_HAS_ABORT LPF_CONST(HAS_ABORT) #endif diff --git a/lpfcc.in b/lpfcc.in index b1a89659..b58da83a 100644 --- a/lpfcc.in +++ b/lpfcc.in @@ -187,6 +187,32 @@ do shift ;; + # The below two special cases are to ensure good integration with CMake. + # Note that the arguments that follow -MT and -MQ are object files, which + # otherwise would be appended to the objects list. In case of manual + # usage of lpfcc, therefore, the use of these flags should come after --, + # however, it is unclear how to pass that to CMake and we choose this + # solution instead (nor would that be desired-- ideally, lpfcc can act as + # a "regular" CC from the CMake perspective) + + -MT) + other_args[$arg_number]="-MT" + arg_number=$((arg_number + 1)) + shift + other_args[$arg_number]="$arg" + arg_number=$((arg_number + 1)) + shift + ;; + + -MQ) + other_args[$arg_number]="-MQ" + arg_number=$((arg_number + 1)) + shift + other_args[$arg_number]="$arg" + arg_number=$((arg_number + 1)) + shift + ;; + *) case $state in engine) diff --git a/post-install/cmake-module-test/src/CMakeLists.txt b/post-install/cmake-module-test/src/CMakeLists.txt index fe1ae2a8..eeef8252 100644 --- a/post-install/cmake-module-test/src/CMakeLists.txt +++ b/post-install/cmake-module-test/src/CMakeLists.txt @@ -15,7 +15,7 @@ # limitations under the License. # -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.10) project(findlpf_test) find_package(lpf REQUIRED CONFIG) diff --git a/post-install/post-install-test.cmake.in b/post-install/post-install-test.cmake.in index 65c9ef9f..edd06922 100644 --- a/post-install/post-install-test.cmake.in +++ b/post-install/post-install-test.cmake.in @@ -268,12 +268,12 @@ if (MPI_FOUND) endif() - message("Compiling a simple LPF program with mpimsg engine") + message("Compiling a simple MPI LPF program with mpimsg engine") # Compile this to check whether mpi.h can be found execute_process( - COMMAND @bindir@/lpfcc -engine mpimsg -I@common@ - @testdir@/func_lpf_hook_subset.mpimsg.c - -o lpfhook_subset_mpimsg_cc + COMMAND @bindir@/lpfcxx -engine mpimsg -I@common@ + @testdir@/func_lpf_hook_subset.mpimsg.cpp -c + -o lpfhook_subset_mpimsg_cc.o WORKING_DIRECTORY @builddir@ RESULT_VARIABLE status ) diff --git a/src/MPI/CMakeLists.txt b/src/MPI/CMakeLists.txt index beca3129..757b9004 100644 --- a/src/MPI/CMakeLists.txt +++ b/src/MPI/CMakeLists.txt @@ -22,13 +22,10 @@ if (MPI_FOUND) list(APPEND MPI_ENGINES mpirma) endif() - if (LIB_IBVERBS) + if (ENABLE_IBVERBS) list(APPEND MPI_ENGINES ibverbs) endif() - if (MPI_OPEN_PORT) - add_definitions("-DMPI_HAS_OPEN_PORT=1") - endif() if (MPI_IBARRIER) add_definitions("-DMPI_HAS_IBARRIER=1") endif() @@ -38,22 +35,20 @@ if (MPI_FOUND) set_target_properties( lpf_proxy_dummy PROPERTIES LINK_FLAGS "${MPI_C_LINK_FLAGS}" ) target_include_directories( lpf_proxy_dummy PRIVATE ${MPI_C_INCLUDE_PATH}) - target_compile_flags(lpf_proxy_dummy PRIVATE ${MPI_C_COMPILE_FLAGS}) install( TARGETS lpf_proxy_dummy RUNTIME DESTINATION ${INSTALL_HELPERS} ) - set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) -# univ_ stands for universal interface => lpf_exec, lpf_put, etc... -# spec_ stands for specific interface => lpf_mpimsg_release_exec, lpf_mpimsg_release_put, etc... + # univ_ stands for universal interface => lpf_exec, lpf_put, etc... + # spec_ stands for specific interface => lpf_mpimsg_release_exec, lpf_mpimsg_release_put, etc... foreach (iface "univ_" "spec_" ) - foreach (LPF_IMPL_ID ${MPI_ENGINES}) - set(libname "lpf_core_${iface}${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}") - set(comlib "lpf_common_${LPFLIB_CONFIG_NAME}") - - set(ibverbs_sources) - if (LPF_IMPL_ID STREQUAL ibverbs) + foreach (LPF_IMPL_ID ${MPI_ENGINES}) + set(libname "lpf_core_${iface}${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}") + set(comlib "lpf_common_${LPFLIB_CONFIG_NAME}") + + set(ibverbs_sources) + if (LPF_IMPL_ID STREQUAL ibverbs) set(ibverbs_sources ibverbs.cpp) endif() @@ -70,15 +65,13 @@ if (MPI_FOUND) spall2all.c messagesort.cpp spall2all.cpp - init.cpp + init.cpp ${ibverbs_sources} ) target_compile_flags(raw_${libname} - PUBLIC ${MPI_C_COMPILE_FLAGS} - INTERFACE "-fPIC" - ) + INTERFACE "-fPIC") target_compile_definitions(raw_${libname} PRIVATE "LPF_CORE_MPI_USES_${LPF_IMPL_ID}=1" @@ -106,9 +99,7 @@ if (MPI_FOUND) MACOSX_RPATH TRUE) target_compile_flags(${libname} - PUBLIC ${MPI_C_COMPILE_FLAGS} - INTERFACE "-fPIC" - ) + INTERFACE "-fPIC") if (iface STREQUAL "spec_") target_compile_definitions(${libname} @@ -152,78 +143,65 @@ if (MPI_FOUND) LIBRARY DESTINATION ${INSTALL_LIB} ARCHIVE DESTINATION ${INSTALL_LIB} ) - - set( mpi_include_flags ) - string( REPLACE ";" " -I" mpi_include_flags "${MPI_C_INCLUDE_PATH}" ) - - # -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(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_cflags "${lpf_cflags} ${MPI_C_COMPILE_FLAGS} -I${mpi_include_flags} -fPIC" PARENT_SCOPE) - set(lpf_lib_link_flags "${lpf_lib_link_flags} ${lib_lflags}" PARENT_SCOPE) - if (UNIX AND NOT APPLE) - set(lpf_exe_link_flags "${lpf_exe_link_flags} -rdynamic" PARENT_SCOPE) - endif() endforeach() include_directories(${MPI_C_INCLUDE_PATH}) # add a test for dynamichook - if (MPI_OPEN_PORT AND LPF_ENABLE_TESTS) - add_executable(dynamichook.t dynamichook.t.cpp dynamichook.cpp - $ ) - - target_include_directories(dynamichook.t PRIVATE ${GTEST_INCLUDE_PATH}) - target_link_libraries(dynamichook.t ${MPI_C_LIBRARIES} gtest) - set_target_properties(dynamichook.t PROPERTIES - COMPILE_FLAGS "${MPI_C_COMPILE_FLAGS}" - LINK_FLAGS "${MPI_C_LINK_FLAGS}" - ) - configure_file( dynamichook.t.sh.in dynamichook.t.sh @ONLY) - set( dynamic_hook_t_sh "${CMAKE_CURRENT_BINARY_DIR}/dynamichook.t.sh") - add_test(NAME dynamichook_1proc - COMMAND bash ${dynamic_hook_t_sh} 1) - set_tests_properties( dynamichook_1proc PROPERTIES TIMEOUT 120 ) - add_test(NAME dynamichook_2proc - COMMAND bash ${dynamic_hook_t_sh} 2) - set_tests_properties( dynamichook_2proc PROPERTIES TIMEOUT 240 ) - add_test(NAME dynamichook_3proc - COMMAND bash ${dynamic_hook_t_sh} 3) - set_tests_properties( dynamichook_3proc PROPERTIES TIMEOUT 360 ) - add_test(NAME dynamichook_10proc - COMMAND bash ${dynamic_hook_t_sh} 10) - set_tests_properties( dynamichook_10proc PROPERTIES TIMEOUT 1200 ) + if (NOT IS_OPENMPI AND LPF_ENABLE_TESTS) + add_gtest(dynamichook.t "mpimsg" ON + ${CMAKE_CURRENT_SOURCE_DIR}/dynamichook.t.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dynamichook.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mpilib.cpp) + + configure_file( dynamichook.t.sh.in dynamichook.t.sh @ONLY) + set( dynamic_hook_t_sh "${CMAKE_CURRENT_BINARY_DIR}/dynamichook.t.sh") + add_test(NAME dynamichook_1proc + COMMAND bash ${dynamic_hook_t_sh} 1) + # We set all dynamichook tests to run in serial mode, without any other tests, + # since these tests occupy the same port and would block each other + set_tests_properties( dynamichook_1proc PROPERTIES TIMEOUT 30 RUN_SERIAL TRUE) + add_test(NAME dynamichook_2proc + COMMAND bash ${dynamic_hook_t_sh} 2) + set_tests_properties( dynamichook_2proc PROPERTIES TIMEOUT 30 RUN_SERIAL TRUE) + add_test(NAME dynamichook_3proc + COMMAND bash ${dynamic_hook_t_sh} 3) + set_tests_properties( dynamichook_3proc PROPERTIES TIMEOUT 30 RUN_SERIAL TRUE) + add_test(NAME dynamichook_10proc + COMMAND bash ${dynamic_hook_t_sh} 10) + set_tests_properties( dynamichook_10proc PROPERTIES TIMEOUT 30 RUN_SERIAL TRUE) endif() # Other unit tests - if (LIB_IBVERBS AND LPF_ENABLE_TESTS) - add_gtest_mpi( ibverbs_test "1;2;5;10" ibverbs.t.cpp ibverbs.cpp - $ mpilib.cpp) - target_link_libraries( ibverbs_test ${LIB_IBVERBS}) + if (ENABLE_IBVERBS AND LPF_ENABLE_TESTS) + add_gtest( ibverbs_test "ibverbs" ON ${CMAKE_CURRENT_SOURCE_DIR}/ibverbs.t.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ibverbs.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mpilib.cpp) endif() - add_gtest_mpi( spall2all_test "1;2;5;10" spall2all.t.cpp spall2all.c - spall2all.cpp mpilib.cpp - $ - ) - - add_gtest_mpi( dall2all_test "1;2;5;10" dall2all.t.cpp - mpilib.cpp $ - ) - - if (MPI_IBARRIER) - add_gtest_mpi( hall2all_test "1;2;5;10" hall2all.t.cpp - mpilib.cpp $ ) - endif() + foreach (engine ${MPI_ENGINES}) + add_gtest( spall2all_test_${engine} ${engine} ON + ${CMAKE_CURRENT_SOURCE_DIR}/spall2all.t.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/spall2all.c + ${CMAKE_CURRENT_SOURCE_DIR}/spall2all.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mpilib.cpp) + + add_gtest( dall2all_test_${engine} ${engine} ON + ${CMAKE_CURRENT_SOURCE_DIR}/dall2all.t.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mpilib.cpp) + + if (MPI_IBARRIER) + add_gtest( hall2all_test_${engine} ${engine} ON + ${CMAKE_CURRENT_SOURCE_DIR}/hall2all.t.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mpilib.cpp) + endif() - add_gtest( messagesort_test messagesort.t.cpp messagesort.cpp - $ ) + add_gtest( messagesort_test_${engine} ${engine} ON + ${CMAKE_CURRENT_SOURCE_DIR}/messagesort.t.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/messagesort.cpp) - add_gtest( ipcmesg_test ipcmesg.t.cpp - $ ) + add_gtest( ipcmesg_test_${engine} ${engine} ON + ${CMAKE_CURRENT_SOURCE_DIR}/ipcmesg.t.cpp) + endforeach() endif(MPI_FOUND) - diff --git a/src/MPI/core.cpp b/src/MPI/core.cpp index 112403e6..94a9658f 100644 --- a/src/MPI/core.cpp +++ b/src/MPI/core.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -36,6 +37,10 @@ #include +// the value 2 in this implementation indicates support for lpf_abort in a way +// that may deviate from the stdlib abort() +const int LPF_HAS_ABORT = 2; + // Error codes. // Note: Some code (e.g. in process::broadcastSymbol) depends on the // fact that numbers are assigned in order of severity, where 0 means @@ -290,3 +295,10 @@ lpf_err_t lpf_resize_message_queue( lpf_t ctx, size_t max_msgs ) return i->resizeMesgQueue(max_msgs); } +lpf_err_t lpf_abort( lpf_t ctx ) { + (void) ctx; + MPI_Abort(MPI_COMM_WORLD, 6); + return LPF_SUCCESS; +} + + diff --git a/src/MPI/dall2all.t.cpp b/src/MPI/dall2all.t.cpp index 4e5d6172..9813c077 100644 --- a/src/MPI/dall2all.t.cpp +++ b/src/MPI/dall2all.t.cpp @@ -23,28 +23,51 @@ using namespace lpf::mpi; -extern "C" const int LPF_MPI_AUTO_INITIALIZE=1; +extern "C" const int LPF_MPI_AUTO_INITIALIZE=0; +/** + * \pre P >= 1 + * \pre P <= 2 + */ +class DenseAll2AllTests : public testing::Test { + + protected: + + static void SetUpTestSuite() { + + MPI_Init(NULL, NULL); + Lib::instance(); + + MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); + MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); + + } + + static void TearDownTestSuite() { + MPI_Finalize(); + } + + static int my_pid; + static int nprocs; +}; -TEST( Dall2all, Create ) +int DenseAll2AllTests::my_pid = -1; +int DenseAll2AllTests::nprocs = -1; + +TEST_F( DenseAll2AllTests, Create ) { DenseAllToAll x(9, 10); } -TEST( Dall2all, Reserve ) +TEST_F( DenseAll2AllTests, Reserve ) { DenseAllToAll x( 4,10); x.reserve( 50 , 100); } -TEST( Dall2all, Send ) +TEST_F( DenseAll2AllTests, Send ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - DenseAllToAll x( my_pid, nprocs ); x.reserve( nprocs , sizeof(int)); @@ -56,13 +79,8 @@ TEST( Dall2all, Send ) EXPECT_TRUE( !error ); } -TEST( Dall2all, Ring ) +TEST_F( DenseAll2AllTests, Ring ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - DenseAllToAll x(my_pid, nprocs); x.reserve( nprocs , sizeof(int)); x.send( (my_pid + 1) % nprocs, &my_pid, sizeof(my_pid) ); @@ -84,14 +102,8 @@ TEST( Dall2all, Ring ) } -TEST( Dall2all, ManyMsgs ) +TEST_F( DenseAll2AllTests, ManyMsgs ) { - Lib::instance(); - - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - DenseAllToAll x(my_pid, nprocs ); const int nMsgs = 10000; x.reserve( nMsgs , sizeof(int)); @@ -122,13 +134,8 @@ TEST( Dall2all, ManyMsgs ) } } -TEST( Dall2all, LargeSend ) +TEST_F( DenseAll2AllTests, LargeSend ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - DenseAllToAll x( my_pid, nprocs ); size_t bigNum = size_t(std::numeric_limits::max()) + 10u ; diff --git a/src/MPI/dynamichook.cpp b/src/MPI/dynamichook.cpp index 974534fd..930ff420 100644 --- a/src/MPI/dynamichook.cpp +++ b/src/MPI/dynamichook.cpp @@ -52,7 +52,6 @@ struct _LPFLIB_LOCAL HookException : public std::runtime_error { {} }; -#ifdef MPI_HAS_OPEN_PORT namespace { // Compares two sockaddr objects. @@ -514,7 +513,6 @@ namespace { } #endif } -#endif // @@ -525,13 +523,6 @@ MPI_Comm dynamicHook( const std::string & serverNode, ASSERT( nprocs > 0 ); ASSERT( pid < nprocs ); -#ifndef MPI_HAS_OPEN_PORT - (void) serverNode; - (void) serverPort; - (void) timeout; (void) pid; (void) nprocs; - throw HookException("MPI does not support MPI_Open_port"); -#else - #ifdef USE_SIGALRM HookException timeoutException("operation timed out"); struct sigaction oldact; @@ -723,7 +714,6 @@ MPI_Comm dynamicHook( const std::string & serverNode, #endif return result; -#endif } diff --git a/src/MPI/dynamichook.t.cpp b/src/MPI/dynamichook.t.cpp index e7b2e6ca..8509d110 100644 --- a/src/MPI/dynamichook.t.cpp +++ b/src/MPI/dynamichook.t.cpp @@ -24,39 +24,65 @@ #include +extern "C" const int LPF_MPI_AUTO_INITIALIZE=0; +int myArgc; +char **myArgv; + +/** + * \pre P >= 1 + * \pre P <= 1 + * \return Exit code: 1 + */ + int main(int argc, char ** argv) { - MPI_Init(&argc, &argv); - ASSERT( argc >= 6 && "usage: ./dynamichook.t [server] [port] [pid] [nprocs] [timeout]"); - - std::string server = argv[1]; - std::string port = argv[2]; - int pid = atoi(argv[3]); - int nprocs = atoi(argv[4]); - int timeout = atoi(argv[5]); - - MPI_Comm comm = MPI_COMM_NULL; - - try { - comm = lpf::mpi::dynamicHook( server, port, pid, nprocs, - lpf::Time::fromSeconds( timeout / 1000.0 ) ); - } - catch( std::runtime_error & e) - { - ADD_FAILURE() << "hookup failed. Fatal!: " << e.what() << "\n"; - _exit(EXIT_FAILURE); - } - - int mpiPid = -1, mpiNprocs = -1; - MPI_Comm_rank( comm, &mpiPid); - MPI_Comm_size( comm, &mpiNprocs ); - - EXPECT_EQ( pid, mpiPid ); - EXPECT_EQ( nprocs, mpiNprocs ); - - MPI_Comm_free(&comm); - - MPI_Finalize(); - - return 0; + myArgc = argc; + myArgv = argv; + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); + +} + +TEST(API, dynamicHook) +{ + + /** + * This test is run via following options via + * ./dynamichook.t + * Being run "as is" without all these 5 arguments will lead it + * to fail (which is the normal Google Test case, so we expect exit code 1) + * However, when run via custom add_test tests with correct 5 arguments, it shall work + */ + ASSERT_GE(myArgc, 6); + MPI_Init(&myArgc, &myArgv); + std::string server = myArgv[1]; + std::string port = myArgv[2]; + int pid = atoi(myArgv[3]); + int nprocs = atoi(myArgv[4]); + int timeout = atoi(myArgv[5]); + + + MPI_Comm comm = MPI_COMM_NULL; + + try { + comm = lpf::mpi::dynamicHook( server, port, pid, nprocs, + lpf::Time::fromSeconds( timeout / 1000.0 ) ); + } + catch( std::runtime_error & e) + { + ADD_FAILURE() << "hookup failed. Fatal!: " << e.what() << "\n"; + _exit(EXIT_FAILURE); + } + + int mpiPid = -1, mpiNprocs = -1; + MPI_Comm_rank( comm, &mpiPid); + MPI_Comm_size( comm, &mpiNprocs ); + + EXPECT_EQ( pid, mpiPid ); + EXPECT_EQ( nprocs, mpiNprocs ); + + MPI_Comm_free(&comm); + + MPI_Finalize(); } + diff --git a/src/MPI/hall2all.t.cpp b/src/MPI/hall2all.t.cpp index a5252792..6085dcdc 100644 --- a/src/MPI/hall2all.t.cpp +++ b/src/MPI/hall2all.t.cpp @@ -23,45 +23,65 @@ using namespace lpf::mpi; -extern "C" const int LPF_MPI_AUTO_INITIALIZE=1; +extern "C" const int LPF_MPI_AUTO_INITIALIZE=0; -TEST( Hall2all, Create ) +/** + * \pre P >= 1 + * \pre P <= 2 + */ +class HAll2AllTests : public testing::Test { + + protected: + + static void SetUpTestSuite() { + + MPI_Init(NULL, NULL); + Lib::instance(); + + MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); + MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); + + } + + static void TearDownTestSuite() { + MPI_Finalize(); + } + + static int my_pid; + static int nprocs; +}; + +int HAll2AllTests::my_pid = -1; +int HAll2AllTests::nprocs = -1; + +TEST_F( HAll2AllTests, Create ) { HoeflerAllToAll x(9, 10); } -TEST( Hall2all, Reserve ) +TEST_F( HAll2AllTests, Reserve ) { HoeflerAllToAll x( 4,10); x.reserve( 50 , 100); } -TEST( Hall2all, Send ) +TEST_F( HAll2AllTests, Send ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - - HoeflerAllToAll x( my_pid, nprocs ); x.reserve( nprocs , sizeof(int)); for (int i = 0; i <= my_pid ; ++i) x.send( (my_pid + 1) % nprocs, &i, sizeof(int) ); bool prerandomize = true; - int error = x.exchange( Lib::instance().world(), prerandomize, NULL); + int dummyOutput[4]; + int error = x.exchange( Lib::instance().world(), prerandomize, dummyOutput); EXPECT_TRUE( !error ); } -TEST( Hall2all, Ring ) +TEST_F( HAll2AllTests, Ring ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - + int dummyOutput[4]; HoeflerAllToAll x(my_pid, nprocs); x.reserve( nprocs , sizeof(int)); x.send( (my_pid + 1) % nprocs, &my_pid, sizeof(my_pid) ); @@ -69,7 +89,7 @@ TEST( Hall2all, Ring ) EXPECT_FALSE( x.empty() ); bool prerandomize = true; - int error = x.exchange( Lib::instance().world(), prerandomize, NULL); + int error = x.exchange( Lib::instance().world(), prerandomize, dummyOutput); EXPECT_TRUE( !error ); EXPECT_FALSE( x.empty() ); @@ -83,14 +103,8 @@ TEST( Hall2all, Ring ) } -TEST( Hall2all, ManyMsgs ) +TEST_F( HAll2AllTests, ManyMsgs ) { - Lib::instance(); - - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - HoeflerAllToAll x(my_pid, nprocs ); const int nMsgs = 10000; x.reserve( nMsgs , sizeof(int)); @@ -105,8 +119,9 @@ TEST( Hall2all, ManyMsgs ) bool prerandomize = true; int trials = 5; + int dummyOutput[4]; int error = x.exchange( Lib::instance().world(), prerandomize, - NULL, trials); + dummyOutput, trials); EXPECT_FALSE( error ); for (int i = 0; i < nMsgs; ++i) @@ -121,13 +136,8 @@ TEST( Hall2all, ManyMsgs ) } } -TEST( Hall2all, LargeSend ) +TEST_F( HAll2AllTests, LargeSend ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - HoeflerAllToAll x( my_pid, nprocs ); std::vector data( size_t(std::numeric_limits::max()) + 10u ); @@ -138,7 +148,8 @@ TEST( Hall2all, LargeSend ) x.send( (my_pid + 1) % nprocs, data.data(), data.size() ); bool prerandomize = false; - int error = x.exchange( Lib::instance().world(), prerandomize, NULL); + int dummyOutput[4]; + int error = x.exchange( Lib::instance().world(), prerandomize, dummyOutput); EXPECT_TRUE( !error ); x.recv( data.data(), data.size() ); diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index b79ec53a..a96030a2 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -62,6 +62,10 @@ class _LPFLIB_LOCAL IBVerbs SlotID regGlobal( void * addr, size_t size ); void dereg( SlotID id ); + size_t getMaxMsgSize() const { + return m_maxMsgSize; + } + void put( SlotID srcSlot, size_t srcOffset, int dstPid, SlotID dstSlot, size_t dstOffset, size_t size ); diff --git a/src/MPI/ibverbs.t.cpp b/src/MPI/ibverbs.t.cpp index 65bd4905..8b916711 100644 --- a/src/MPI/ibverbs.t.cpp +++ b/src/MPI/ibverbs.t.cpp @@ -24,124 +24,139 @@ using namespace lpf::mpi; -extern "C" const int LPF_MPI_AUTO_INITIALIZE=1; +extern "C" const int LPF_MPI_AUTO_INITIALIZE=0; -TEST( IBVerbs, init ) + +/** + * \pre P >= 1 + * \pre P <= 2 + */ +class IBVerbsTests : public testing::Test { + + protected: + + static void SetUpTestSuite() { + + MPI_Init(NULL, NULL); + Lib::instance(); + comm = new Comm(); + *comm = Lib::instance().world(); + comm->barrier(); + verbs = new IBVerbs( *comm ); + } + + static void TearDownTestSuite() { + delete verbs; + verbs = nullptr; + delete comm; + comm = nullptr; + MPI_Finalize(); + } + + static Comm *comm; + static IBVerbs *verbs; +}; + +lpf::mpi::Comm * IBVerbsTests::comm = nullptr; +IBVerbs * IBVerbsTests::verbs = nullptr; + + +TEST_F( IBVerbsTests, init ) { - Comm comm = Lib::instance().world(); - comm.barrier(); - IBVerbs verbs( comm ); - comm.barrier(); + comm->barrier(); } -TEST( IBVerbs, resizeMemreg ) +TEST_F( IBVerbsTests, resizeMemreg ) { - Comm comm = Lib::instance().world(); - - comm.barrier(); - IBVerbs verbs( comm ); - verbs.resizeMemreg( 2 ); + verbs->resizeMemreg( 2 ); - comm.barrier(); + comm->barrier(); } -TEST( IBVerbs, resizeMesgq ) +TEST_F( IBVerbsTests, resizeMesgq ) { - Comm comm = Lib::instance().world(); - - comm.barrier(); - IBVerbs verbs( comm ); - verbs.resizeMesgq( 2 ); + verbs->resizeMesgq( 2 ); - comm.barrier(); + comm->barrier(); } -TEST( IBVerbs, regVars ) +TEST_F( IBVerbsTests, regVars ) { - Comm comm = Lib::instance().world(); - comm.barrier(); - IBVerbs verbs( comm ); char buf1[30] = "Hi"; char buf2[30] = "Boe"; - verbs.resizeMemreg( 2 ); + verbs->resizeMemreg( 2 ); - verbs.regLocal( buf1, sizeof(buf1) ); - verbs.regGlobal( buf2, sizeof(buf2) ); + IBVerbs::SlotID b1 = verbs->regLocal( buf1, sizeof(buf1) ); + IBVerbs::SlotID b2 = verbs->regGlobal( buf2, sizeof(buf2) ); - comm.barrier(); + comm->barrier(); + verbs->dereg(b1); + verbs->dereg(b2); } -TEST( IBVerbs, put ) +TEST_F( IBVerbsTests, put ) { - Comm comm = Lib::instance().world(); - - comm.barrier(); - IBVerbs verbs( comm ); char buf1[30] = "Hi"; char buf2[30] = "Boe"; - verbs.resizeMemreg( 2 ); - verbs.resizeMesgq( 1 ); + verbs->resizeMemreg( 2 ); + verbs->resizeMesgq( 1 ); - IBVerbs::SlotID b1 = verbs.regLocal( buf1, sizeof(buf1) ); - IBVerbs::SlotID b2 = verbs.regGlobal( buf2, sizeof(buf2) ); - - comm.barrier(); + IBVerbs::SlotID b1 = verbs->regLocal( buf1, sizeof(buf1) ); + IBVerbs::SlotID b2 = verbs->regGlobal( buf2, sizeof(buf2) ); + + comm->barrier(); - verbs.put( b1, 0, (comm.pid() + 1)%comm.nprocs(), b2, 0, sizeof(buf1)); + verbs->put( b1, 0, (comm->pid() + 1)%comm->nprocs(), b2, 0, sizeof(buf1)); - verbs.sync(true); + verbs->sync(true); EXPECT_EQ( "Hi", std::string(buf1) ); EXPECT_EQ( "Hi", std::string(buf2) ); + verbs->dereg(b1); + verbs->dereg(b2); } -TEST( IBVerbs, get ) +TEST_F( IBVerbsTests, get ) { - Comm comm = Lib::instance().world(); - - comm.barrier(); - IBVerbs verbs( comm ); char buf1[30] = "Hoi"; char buf2[30] = "Vreemd"; - verbs.resizeMemreg( 2 ); - verbs.resizeMesgq( 1 ); + verbs->resizeMemreg( 2 ); + verbs->resizeMesgq( 1 ); - IBVerbs::SlotID b1 = verbs.regLocal( buf1, sizeof(buf1) ); - IBVerbs::SlotID b2 = verbs.regGlobal( buf2, sizeof(buf2) ); - - comm.barrier(); + IBVerbs::SlotID b1 = verbs->regLocal( buf1, sizeof(buf1) ); + IBVerbs::SlotID b2 = verbs->regGlobal( buf2, sizeof(buf2) ); + + comm->barrier(); - verbs.get( (comm.pid() + 1)%comm.nprocs(), b2, 0, + verbs->get( (comm->pid() + 1)%comm->nprocs(), b2, 0, b1, 0, sizeof(buf2)); - verbs.sync(true); + verbs->sync(true); EXPECT_EQ( "Vreemd", std::string(buf1) ); EXPECT_EQ( "Vreemd", std::string(buf2) ); + verbs->dereg(b1); + verbs->dereg(b2); } -TEST( IBVerbs, putAllToAll ) +TEST_F( IBVerbsTests, putAllToAll ) { - Comm comm = Lib::instance().world(); - int nprocs = comm.nprocs(); - int pid = comm.pid(); - - comm.barrier(); - IBVerbs verbs( comm ); - + int nprocs = comm->nprocs(); + int pid = comm->pid(); + const int H = 2.5 * nprocs; std::vector< int > a(H); @@ -152,165 +167,159 @@ TEST( IBVerbs, putAllToAll ) b[i] = nprocs*nprocs - ( i * nprocs + pid); } - verbs.resizeMemreg( 2 ); - verbs.resizeMesgq( H ); + verbs->resizeMemreg( 2 ); + verbs->resizeMesgq( H ); - IBVerbs::SlotID a1 = verbs.regGlobal( a.data(), sizeof(int)*a.size()); - IBVerbs::SlotID b1 = verbs.regGlobal( b.data(), sizeof(int)*b.size()); - - comm.barrier(); + IBVerbs::SlotID a1 = verbs->regGlobal( a.data(), sizeof(int)*a.size()); + IBVerbs::SlotID b1 = verbs->regGlobal( b.data(), sizeof(int)*b.size()); + + comm->barrier(); for (int i = 0; i < H; ++i) { int dstPid = (pid + i ) % nprocs; - verbs.put( a1, sizeof(int)*i, - dstPid, b1, sizeof(int)*i, sizeof(int)); + verbs->put( a1, sizeof(int)*i, + dstPid, b1, sizeof(int)*i, sizeof(int)); } - verbs.sync(true); + verbs->sync(true); for (int i = 0; i < H; ++i) { int srcPid = (nprocs + pid - (i%nprocs)) % nprocs; EXPECT_EQ( i*nprocs + pid, a[i] ) ; EXPECT_EQ( i*nprocs + srcPid, b[i] ); } + verbs->dereg(a1); + verbs->dereg(b1); } -TEST( IBVerbs, getAllToAll ) +TEST_F( IBVerbsTests, getAllToAll ) { - Comm comm = Lib::instance().world(); - int nprocs = comm.nprocs(); - int pid = comm.pid(); + int nprocs = comm->nprocs(); + int pid = comm->pid(); - comm.barrier(); - IBVerbs verbs( comm ); + const int H = 100.3 * nprocs; - const int H = 1000.3 * nprocs; - - std::vector< int > a(H); - std::vector< int > b(H); + std::vector< int > a(H), a2(H); + std::vector< int > b(H), b2(H); for (int i = 0; i < H; ++i) { a[i] = i * nprocs + pid ; + a2[i] = a[i]; b[i] = nprocs*nprocs - ( i * nprocs + pid); + b2[i] = i*nprocs+ (nprocs + pid + i) % nprocs; } - verbs.resizeMemreg( 2 ); - verbs.resizeMesgq( H ); + verbs->resizeMemreg( 2 ); + verbs->resizeMesgq( H ); + + IBVerbs::SlotID a1 = verbs->regGlobal( a.data(), sizeof(int)*a.size()); + IBVerbs::SlotID b1 = verbs->regGlobal( b.data(), sizeof(int)*b.size()); - IBVerbs::SlotID a1 = verbs.regGlobal( a.data(), sizeof(int)*a.size()); - IBVerbs::SlotID b1 = verbs.regGlobal( b.data(), sizeof(int)*b.size()); - - comm.barrier(); + comm->barrier(); for (int i = 0; i < H; ++i) { int srcPid = (pid + i) % nprocs; - verbs.get( srcPid, a1, sizeof(int)*i, - b1, sizeof(int)*i, sizeof(int)); + verbs->get( srcPid, a1, sizeof(int)*i, + b1, sizeof(int)*i, sizeof(int)); } - verbs.sync(true); + verbs->sync(true); - for (int i = 0; i < H; ++i) { - int srcPid = (nprocs + pid + i ) % nprocs; - EXPECT_EQ( i*nprocs + pid, a[i] ) ; - EXPECT_EQ( i*nprocs + srcPid, b[i] ); - } -} + EXPECT_EQ(a, a2); + EXPECT_EQ(b, b2); + verbs->dereg(a1); + verbs->dereg(b1); -TEST( IBVerbs, putHuge ) -{ - Comm comm = Lib::instance().world(); +} - comm.barrier(); - IBVerbs verbs( comm ); - LOG(4, "Allocating mem1 "); - std::vector< char > hugeMsg( std::numeric_limits::max() * 1.5l ); - LOG(4, "Allocating mem2 "); - std::vector< char > hugeBuf( hugeMsg.size() ); +TEST_F( IBVerbsTests, putHuge ) +{ + std::vector hugeMsg(3*verbs->getMaxMsgSize()); + std::vector< char > hugeBuf(3*verbs->getMaxMsgSize()); + LOG(4, "Allocating putHuge with vector size: " << hugeMsg.size()); -#if 0 - LOG(4, "Initializing mem2 "); for ( size_t i = 0; i < hugeMsg.size() ; ++i) hugeMsg[i] = char( i ); -#endif - verbs.resizeMemreg( 2 ); - verbs.resizeMesgq( 1 ); + verbs->resizeMemreg( 2 ); + verbs->resizeMesgq( 1 ); - IBVerbs::SlotID b1 = verbs.regLocal( hugeMsg.data(), hugeMsg.size() ); - IBVerbs::SlotID b2 = verbs.regGlobal( hugeBuf.data(), hugeBuf.size() ); - - comm.barrier(); + IBVerbs::SlotID b1 = verbs->regLocal( hugeMsg.data(), hugeMsg.size() ); + IBVerbs::SlotID b2 = verbs->regGlobal( hugeBuf.data(), hugeBuf.size() ); + + comm->barrier(); - verbs.put( b1, 0, (comm.pid() + 1)%comm.nprocs(), b2, 0, hugeMsg.size() ); + verbs->put( b1, 0, (comm->pid() + 1)%comm->nprocs(), b2, 0, hugeMsg.size() * sizeof(char) ); - verbs.sync(true); + verbs->sync(true); EXPECT_EQ( hugeMsg, hugeBuf ); + + verbs->dereg(b1); + verbs->dereg(b2); } -TEST( IBVerbs, getHuge ) +TEST_F( IBVerbsTests, getHuge ) { - Comm comm = Lib::instance().world(); - - comm.barrier(); - IBVerbs verbs( comm ); - std::vector< char > hugeMsg( std::numeric_limits::max() * 1.5 ); - std::vector< char > hugeBuf( hugeMsg.size() ); + std::vector hugeMsg(3*verbs->getMaxMsgSize()); + std::vector< char > hugeBuf(3*verbs->getMaxMsgSize()); + LOG(4, "Allocating getHuge with vector size: " << hugeMsg.size()); for ( size_t i = 0; i < hugeMsg.size() ; ++i) - hugeMsg[i] = char( i ); + hugeMsg[i] = char(i); - verbs.resizeMemreg( 2 ); - verbs.resizeMesgq( 1 ); + verbs->resizeMemreg( 2 ); + verbs->resizeMesgq( 1 ); - IBVerbs::SlotID b1 = verbs.regLocal( hugeBuf.data(), hugeBuf.size() ); - IBVerbs::SlotID b2 = verbs.regGlobal( hugeMsg.data(), hugeMsg.size() ); - - comm.barrier(); + IBVerbs::SlotID b1 = verbs->regLocal( hugeMsg.data(), hugeMsg.size() ); + IBVerbs::SlotID b2 = verbs->regGlobal( hugeBuf.data(), hugeBuf.size() ); - verbs.get( (comm.pid() + 1)%comm.nprocs(), b2, 0, b1, 0, hugeMsg.size() ); + comm->barrier(); - verbs.sync(true); + verbs->get( (comm->pid() + 1)%comm->nprocs(), b2, 0, b1, 0, hugeMsg.size() * sizeof(char)); - EXPECT_EQ( hugeMsg, hugeBuf ); + verbs->sync(true); + + EXPECT_EQ(hugeMsg, hugeBuf); + + verbs->dereg(b1); + verbs->dereg(b2); } -TEST( IBVerbs, manyPuts ) +TEST_F( IBVerbsTests, manyPuts ) { - Comm comm = Lib::instance().world(); - - comm.barrier(); - IBVerbs verbs( comm ); - const unsigned N = 100000; + const unsigned N = 5000; std::vector< unsigned char > buf1( N ); std::vector< unsigned char > buf2( N ); for (unsigned int i = 0 ; i < N; ++ i) - buf1[i] = i + comm.pid() ; + buf1[i] = i + comm->pid() ; - verbs.resizeMemreg( 2 ); - verbs.resizeMesgq( N ); + verbs->resizeMemreg( 2 ); + verbs->resizeMesgq( N ); - IBVerbs::SlotID b1 = verbs.regLocal( buf1.data(), buf1.size() ); - IBVerbs::SlotID b2 = verbs.regGlobal( buf2.data(), buf1.size() ); - - comm.barrier(); + IBVerbs::SlotID b1 = verbs->regLocal( buf1.data(), buf1.size() ); + IBVerbs::SlotID b2 = verbs->regGlobal( buf2.data(), buf1.size() ); + + comm->barrier(); for ( unsigned i = 0 ; i < N; ++i) - verbs.put( b1, i, (comm.pid() + 1)%comm.nprocs(), b2, i, 1); + verbs->put( b1, i, (comm->pid() + 1)%comm->nprocs(), b2, i, 1); - verbs.sync(true); + verbs->sync(true); for ( unsigned i = 0 ; i < N; ++i) { - unsigned char b2_exp = i + (comm.pid() + comm.nprocs() - 1) % comm.nprocs(); - unsigned char b1_exp = i + comm.pid(); + unsigned char b2_exp = i + (comm->pid() + comm->nprocs() - 1) % comm->nprocs(); + unsigned char b1_exp = i + comm->pid(); EXPECT_EQ( b2_exp, buf2[i]); EXPECT_EQ( b1_exp, buf1[i] ); } + + verbs->dereg(b1); + verbs->dereg(b2); } diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index f1919f33..30ece40d 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -225,6 +225,4 @@ void Interface :: probe( machine_t & machine ) machine.l = &Interface::latency; } - - } // namespace lpf diff --git a/src/MPI/messagesort.t.cpp b/src/MPI/messagesort.t.cpp index 8347fd45..cd532762 100644 --- a/src/MPI/messagesort.t.cpp +++ b/src/MPI/messagesort.t.cpp @@ -31,6 +31,10 @@ TEST( MessageSort, empty ) } +/** + * \pre P >= 1 + * \pre P <= 1 + */ TEST( MessageSort, oneMsg ) { std::vector< char > array( 50 * G); diff --git a/src/MPI/spall2all.t.cpp b/src/MPI/spall2all.t.cpp index 42fae2c2..1a19d94c 100644 --- a/src/MPI/spall2all.t.cpp +++ b/src/MPI/spall2all.t.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -30,16 +31,40 @@ using namespace lpf::mpi; -extern "C" const int LPF_MPI_AUTO_INITIALIZE=1; +extern "C" const int LPF_MPI_AUTO_INITIALIZE=0; +/** + * \pre P >= 1 + * \pre P <= 2 + */ +class SparseAll2AllTests : public testing::Test { -TEST( Spall2allC, EnoughMemory ) -{ - lpf::mpi::Lib::instance().world(); + protected: + + static void SetUpTestSuite() { + + MPI_Init(NULL, NULL); + Lib::instance(); + + MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); + MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); + + } - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); + static void TearDownTestSuite() { + MPI_Finalize(); + } + + static int my_pid; + static int nprocs; +}; + +int SparseAll2AllTests::my_pid = -1; +int SparseAll2AllTests::nprocs = -1; + + +TEST_F( SparseAll2AllTests, EnoughMemory ) +{ using namespace std; using namespace lpf::mpi; @@ -160,23 +185,18 @@ const int M = N * (6 + 2*(int) ceil(1+log10(nprocs)) ); sparse_all_to_all_destroy( &spt ); } -TEST( Spall2all, Create ) +TEST_F( SparseAll2AllTests, Create ) { SparseAllToAll x(9, 10); } -TEST( Spall2all, Reserve ) +TEST_F( SparseAll2AllTests, Reserve ) { SparseAllToAll x( 4,10); } -TEST( Spall2all, ReserveUnequal ) +TEST_F( SparseAll2AllTests, ReserveUnequal ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - SparseAllToAll x( my_pid, nprocs ); // simulate the case where one of the processes can't @@ -189,14 +209,8 @@ TEST( Spall2all, ReserveUnequal ) EXPECT_TRUE( !error ); } -TEST( Spall2all, Send ) +TEST_F( SparseAll2AllTests, Send ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - - SparseAllToAll x( my_pid, nprocs ); x.reserve( nprocs * ceil(1+log2(nprocs)) , sizeof(int)); for (int i = 0; i <= my_pid ; ++i) @@ -207,13 +221,8 @@ TEST( Spall2all, Send ) EXPECT_TRUE( !error ); } -TEST( Spall2all, Ring ) +TEST_F( SparseAll2AllTests, Ring ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - SparseAllToAll x(my_pid, nprocs); EXPECT_TRUE( x.empty() ); @@ -236,13 +245,8 @@ TEST( Spall2all, Ring ) } -TEST( Spall2all, Access ) +TEST_F( SparseAll2AllTests, Access ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - SparseAllToAll x(my_pid, nprocs); x.reserve( nprocs * ceil(1+log2(nprocs)) , sizeof(int) ); EXPECT_TRUE( x.empty() ); @@ -260,14 +264,8 @@ TEST( Spall2all, Access ) EXPECT_TRUE( x.empty() ); } -TEST( Spall2all, SmallBuf ) +TEST_F( SparseAll2AllTests, SmallBuf ) { - Lib::instance(); - - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - SparseAllToAll x(my_pid, nprocs); const int nMsgs = 5; x.reserve( nMsgs , sizeof(int) ); @@ -287,13 +285,8 @@ TEST( Spall2all, SmallBuf ) } -TEST( Spall2all, SmallBufProc1 ) +TEST_F( SparseAll2AllTests, SmallBufProc1 ) { - Lib::instance(); - - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); SparseAllToAll x(my_pid, nprocs); const int nMsgs = 100; @@ -318,14 +311,8 @@ TEST( Spall2all, SmallBufProc1 ) } -TEST( Spall2all, ManyMsgs ) +TEST_F( SparseAll2AllTests, ManyMsgs ) { - Lib::instance(); - - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - SparseAllToAll x(my_pid, nprocs); const int nMsgs = 10000; x.reserve( nMsgs * 2 , sizeof(int) ); @@ -356,19 +343,14 @@ TEST( Spall2all, ManyMsgs ) } } -TEST( Spall2all, LargeSend ) +TEST_F( SparseAll2AllTests, LargeSend ) { - Lib::instance(); - int my_pid = -1, nprocs = -1; - MPI_Comm_rank( MPI_COMM_WORLD, &my_pid ); - MPI_Comm_size( MPI_COMM_WORLD, &nprocs ); - - SparseAllToAll x( my_pid, nprocs ); std::vector data( size_t(std::numeric_limits::max()) + 10u ); for (size_t i = 0; i < data.size(); ++i) data[i] = char(i + my_pid) ; + SparseAllToAll x( my_pid, nprocs ); x.reserve( 1 , data.size() ); x.send( (my_pid + 1) % nprocs, data.data(), data.size() ); diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 5932d9db..91eddb06 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -24,7 +24,7 @@ add_library(lpf_common_${LPFLIB_CONFIG_NAME} OBJECT ) -add_gtest(time_test time.t.cpp time.cpp stack.cpp) -add_gtest(memreg_test memreg.t.cpp log.cpp time.cpp config.cpp stack.cpp) -add_gtest(sparseset_test sparseset.t.cpp log.cpp time.cpp config.cpp stack.cpp) +add_gtest(time_test "pthread" OFF time.t.cpp time.cpp stack.cpp) +add_gtest(memreg_test "pthread" OFF memreg.t.cpp log.cpp time.cpp config.cpp stack.cpp) +add_gtest(sparseset_test "pthread" OFF sparseset.t.cpp log.cpp time.cpp config.cpp stack.cpp) diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt index 47c0d57d..7f3f9c92 100644 --- a/src/debug/CMakeLists.txt +++ b/src/debug/CMakeLists.txt @@ -25,7 +25,8 @@ add_library( ${libname} rwconflict.cpp $ ) -target_link_libraries( ${libname} ${LIB_POSIX_THREADS} ) +target_link_libraries(${libname} ${LIB_POSIX_THREADS}) +target_include_directories(${libname} PRIVATE ${MPI_C_INCLUDE_PATH}) set_target_properties(${libname} PROPERTIES SOVERSION ${SOVERSION} ) @@ -34,7 +35,7 @@ install(TARGETS ${libname} EXPORT lpf RUNTIME DESTINATION ${INSTALL_BIN} LIBRARY DESTINATION ${INSTALL_LIB} ARCHIVE DESTINATION ${INSTALL_LIB} - ) +) -add_gtest(rwconflict_test rwconflict.t.cpp rwconflict.cpp - $ ) +add_gtest(rwconflict_test "pthread" rwconflict.t.cpp rwconflict.cpp) + #$ ) diff --git a/src/debug/core.cpp b/src/debug/core.cpp index d120b22b..c3d0adec 100644 --- a/src/debug/core.cpp +++ b/src/debug/core.cpp @@ -16,6 +16,8 @@ */ #include "debug/lpf/core.h" +#include "lpf/abort.h" + #undef lpf_get #undef lpf_put #undef lpf_sync @@ -55,6 +57,7 @@ #undef LPF_NONE #undef LPF_INIT_NONE #undef LPF_NO_ARGS +#undef LPF_HAS_ABORT #if __cplusplus >= 201103L #include @@ -78,8 +81,6 @@ #include "memreg.hpp" #include "rwconflict.hpp" - - namespace lpf { namespace debug { @@ -100,9 +101,21 @@ class _LPFLIB_LOCAL Interface { } static void threadInit() { + // in the below we use std::abort as these are critical *internal* + // errors, not errors in the use of LPF core functionality. + // By contrast, errors that appear due to misuse of the LPF core primitives + // should call lpf_abort. This initialiser ensures that the underlying LPF + // engine has support for lpf_abort. + // The above logic about when to std::abort and when to lpf_abort is applied + // consistently in the below implementation. Only (seemingly) exceptions will + // be documented henceforth. int rc = pthread_key_create( &s_threadKeyCtxStore, &destroyCtxStore ); if (rc) { - LOG( 0, "Internal error while initializing thread static storage"); + LOG( 0, "Internal error while initializing thread static storage" ); + std::abort(); + } + if( ! LPF_HAS_ABORT ) { + LOG( 0, "Debug layer relies on lpf_abort, but selected engine does not support it" ); std::abort(); } } @@ -220,7 +233,6 @@ class _LPFLIB_LOCAL Interface { } } - Interface( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs ) : m_ctx( ctx ) , m_pid( pid ) @@ -268,6 +280,7 @@ class _LPFLIB_LOCAL Interface { { } + void cleanup() { if ( m_comm_bufs_registered ) { @@ -429,27 +442,27 @@ class _LPFLIB_LOCAL Interface { if ( P <= 0 && P != LPF_MAX_P ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid argument passed to lpf_exec: P = " << P ); - std::abort(); + lpf_abort(m_ctx); } if ( spmd == NULL ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid argument passed to lpf_exec: NULL spmd argument" ); - std::abort(); + lpf_abort(m_ctx); } if ( args.input_size != 0 && args.input == NULL ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid argument passed to lpf_spmd_t: NULL input argument while input_size is non-zero" ); - std::abort(); + lpf_abort(m_ctx); } if ( args.output_size != 0 && args.output == NULL ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid argument passed to lpf_spmd_t: NULL output argument while output_size is non-zero" ); - std::abort(); + lpf_abort(m_ctx); } if ( args.f_size != 0 && args.f_symbols == NULL ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid argument passed to lpf_spmd_t: NULL f_symbols argument while f_size is non-zero" ); - std::abort(); + lpf_abort(m_ctx); } lpf_args_t new_args; @@ -486,6 +499,13 @@ class _LPFLIB_LOCAL Interface { static lpf_err_t hook( const char * file, int line, lpf_init_t init, lpf_spmd_t spmd, lpf_args_t args ) { + // the lpf_hook could arise from any non-LPF context -- this is in fact + // why it exists: hooking from within an LPF context to create a subcontext is + // provided by lpf_rehook instead. + // Because the callee context is potentially not controlled by the underlying + // LPF engine, and because the callee context in the non-trivial case consists + // of multiple distributed processes, we cannot rely on lpf_abort. The only + // thing we can do is rely on the standard abort. if ( spmd == NULL ) { LOG( 0, file << ":" << line << ": Invalid argument passed to lpf_hook: NULL spmd argument" ); @@ -545,22 +565,22 @@ class _LPFLIB_LOCAL Interface { if ( spmd == NULL ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid argument passed to lpf_rehook: NULL spmd argument" ); - std::abort(); + lpf_abort(m_ctx); } if ( args.input_size != 0 && args.input == NULL ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid argument passed to lpf_spmd_t: NULL input argument while input_size is non-zero" ); - std::abort(); + lpf_abort(m_ctx); } if ( args.output_size != 0 && args.output == NULL ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid argument passed to lpf_spmd_t: NULL output argument while output_size is non-zero" ); - std::abort(); + lpf_abort(m_ctx); } if ( args.f_size != 0 && args.f_symbols == NULL ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid argument passed to lpf_spmd_t: NULL f_symbols argument while f_size is non-zero" ); - std::abort(); + lpf_abort(m_ctx); } lpf_args_t new_args; @@ -676,7 +696,7 @@ class _LPFLIB_LOCAL Interface { "which would have taken the " << (m_memreg_size+1) << "-th slot, while only space for " << m_memreg_reserved << " slots has been reserved" ); - std::abort(); + lpf_abort(m_ctx); } Memslot slot; slot.file = file; @@ -707,7 +727,7 @@ class _LPFLIB_LOCAL Interface { "which would have taken the " << (m_memreg_size+1) << "-th slot, while only space for " << m_memreg_reserved << " slots has been reserved" ); - std::abort(); + lpf_abort(m_ctx); } Memslot slot; @@ -732,7 +752,7 @@ class _LPFLIB_LOCAL Interface { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Invalid attempt to deregister a memory slot, " "because it has not been registered before" ); - std::abort(); + lpf_abort(m_ctx); } if ( m_used_regs.find( slot ) != m_used_regs.end() ) { @@ -741,7 +761,7 @@ class _LPFLIB_LOCAL Interface { "because it is in use by the primitive on " << m_used_regs[slot].first << ":" << m_used_regs[slot].second ); - std::abort(); + lpf_abort(m_ctx); } if ( m_memreg.lookup( slot ).kind == Memslot::Global ) { @@ -778,7 +798,7 @@ class _LPFLIB_LOCAL Interface { if ( dst_pid < 0 || dst_pid >= m_nprocs ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": unknown process ID " << dst_pid << " for data destination " ); - std::abort(); + lpf_abort(m_ctx); } LPFLIB_RESTORE_WARNINGS @@ -786,26 +806,26 @@ class _LPFLIB_LOCAL Interface { LOG( 0, file << ":" << line << ": pid " << m_pid << ": numerical overflow while computing src_offset + size = " << src_offset << " + " << size << " > SIZE_MAX" ); - std::abort(); + lpf_abort(m_ctx); } if ( dst_offset > std::numeric_limits::max() - size ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": numerical overflow while computing dst_offset + size = " << dst_offset << " + " << size << " > SIZE_MAX" ); - std::abort(); + lpf_abort(m_ctx); } if ( m_active_regs.find( src_slot ) == m_active_regs.end() ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": source memory slot does not exist" ); - std::abort(); + lpf_abort(m_ctx); } if ( m_active_regs.find( dst_slot ) == m_active_regs.end() ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": destination memory slot does not exist" ); - std::abort(); + lpf_abort(m_ctx); } const Memslot & ss = m_memreg.lookup( src_slot ); @@ -818,7 +838,7 @@ class _LPFLIB_LOCAL Interface { " A synchronisation is necessary to active" " the memory registration at " << ss.file << ":" << ss.line ); - std::abort(); + lpf_abort(m_ctx); } if ( ss.kind == Memslot::Local && ss.size[0] < src_offset + size ) { @@ -827,7 +847,7 @@ class _LPFLIB_LOCAL Interface { << ss.file << ":" << ss.line << " ) is read past the end by " << ( src_offset + size - ss.size[0] ) << " bytes. "); - std::abort(); + lpf_abort(m_ctx); } if ( ss.kind == Memslot::Global && ss.size[m_pid] < src_offset + size ) { @@ -836,7 +856,7 @@ class _LPFLIB_LOCAL Interface { << ss.file << ":" << ss.line << " ) is read past the end by " << ( src_offset + size - ss.size[m_pid] ) << " bytes"); - std::abort(); + lpf_abort(m_ctx); } if ( ! ds.active ) { @@ -846,7 +866,7 @@ class _LPFLIB_LOCAL Interface { "missing. A synchronisation is necessary " "to active the memory registration at " << ds.file << ":" << ds.line ); - std::abort(); + lpf_abort(m_ctx); } if ( ds.kind == Memslot::Local ) { @@ -854,7 +874,7 @@ class _LPFLIB_LOCAL Interface { << ": destination memory must be globally registered. " << "Instead, it was only locally registered at " << ds.file << ":" << ds.line ); - std::abort(); + lpf_abort(m_ctx); } if ( ds.kind == Memslot::Global && ds.size[dst_pid] != size_t(-1) @@ -864,7 +884,7 @@ class _LPFLIB_LOCAL Interface { << ds.file << ":" << ds.line << " ) is written past the end by " << ( dst_offset + size - ds.size[dst_pid] ) << " bytes"); - std::abort(); + lpf_abort(m_ctx); } if ( m_puts.size() + m_gets.size() >= m_mesgq_reserved ) { @@ -874,7 +894,7 @@ class _LPFLIB_LOCAL Interface { << ": This is the " << (m_puts.size() + m_gets.size() + 1) << "-th message, while space for only " << m_mesgq_reserved << " has been reserved. Request queue follows\n" << t.str() ); - std::abort(); + lpf_abort(m_ctx); } m_used_regs[src_slot] = std::make_pair( file, line ); @@ -896,7 +916,7 @@ class _LPFLIB_LOCAL Interface { if ( src_pid < 0 || src_pid >= m_nprocs ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": unknown process ID " << src_pid << " for data source" ); - std::abort(); + lpf_abort(m_ctx); } LPFLIB_RESTORE_WARNINGS @@ -904,26 +924,26 @@ class _LPFLIB_LOCAL Interface { LOG( 0, file << ":" << line << ": pid " << m_pid << ": numerical overflow while computing src_offset + size = " << src_offset << " + " << size << " > SIZE_MAX" ); - std::abort(); + lpf_abort(m_ctx); } if ( dst_offset > std::numeric_limits::max() - size ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": numerical overflow while computing dst_offset + size = " << dst_offset << " + " << size << " > SIZE_MAX" ); - std::abort(); + lpf_abort(m_ctx); } if ( m_active_regs.find( src_slot ) == m_active_regs.end() ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": source memory slot does not exist" ); - std::abort(); + lpf_abort(m_ctx); } if ( m_active_regs.find( dst_slot ) == m_active_regs.end() ) { LOG( 0, file << ":" << line << ": pid " << m_pid << ": destination memory slot does not exist" ); - std::abort(); + lpf_abort(m_ctx); } const Memslot & ss = m_memreg.lookup( src_slot ); @@ -936,7 +956,7 @@ class _LPFLIB_LOCAL Interface { " A synchronisation is necessary to active" " the memory registration at " << ss.file << ":" << ss.line ); - std::abort(); + lpf_abort(m_ctx); } if ( ss.kind == Memslot::Local ) { @@ -945,7 +965,7 @@ class _LPFLIB_LOCAL Interface { "Instead, it was registered only locally at " << ss.file << ":" << ss.line ); - std::abort(); + lpf_abort(m_ctx); } if ( ss.kind == Memslot::Global && ss.size[src_pid] != size_t(-1) @@ -955,7 +975,7 @@ class _LPFLIB_LOCAL Interface { << ss.file << ":" << ss.line << " ) is read past the end by " << ( src_offset + size - ss.size[src_pid] ) << " bytes"); - std::abort(); + lpf_abort(m_ctx); } if ( ! ds.active ) { @@ -965,7 +985,7 @@ class _LPFLIB_LOCAL Interface { "missing. A synchronisation is necessary" "to active the memory registration at " << ds.file << ":" << ds.line ); - std::abort(); + lpf_abort(m_ctx); } if ( ds.kind == Memslot::Local && ds.size[0] < dst_offset + size ) { @@ -974,7 +994,7 @@ class _LPFLIB_LOCAL Interface { << ds.file << ":" << ds.line << " ) is written past the end by " << ( dst_offset + size - ds.size[0] ) << " bytes"); - std::abort(); + lpf_abort(m_ctx); } if ( ds.kind == Memslot::Global && ds.size[m_pid] < dst_offset + size ) { @@ -983,7 +1003,7 @@ class _LPFLIB_LOCAL Interface { << ds.file << ":" << ds.line << " ) is written past the end by " << ( dst_offset + size - ds.size[m_pid] ) << " bytes"); - std::abort(); + lpf_abort(m_ctx); } if ( m_puts.size() + m_gets.size() >= m_mesgq_reserved ) { @@ -993,7 +1013,7 @@ class _LPFLIB_LOCAL Interface { << ": This is the " << (m_puts.size() + m_gets.size() + 1) << "-th message, while space for only " << m_mesgq_reserved << " has been reserved. Request queue follows\n" << t.str() ); - std::abort(); + lpf_abort(m_ctx); } m_used_regs[src_slot] = std::make_pair( file, line ); @@ -1006,6 +1026,13 @@ class _LPFLIB_LOCAL Interface { return LPF_SUCCESS; } + lpf_err_t abort(const char * file, int line) { + (void) file; + (void) line; + lpf_abort(m_ctx); + return LPF_SUCCESS; + } + lpf_err_t sync( const char * file, int line, lpf_sync_attr_t attr = LPF_SYNC_DEFAULT ) { @@ -1019,7 +1046,7 @@ class _LPFLIB_LOCAL Interface { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Could not allocate extra debug messages in message queue" ); - std::abort(); + lpf_abort(m_ctx); } } @@ -1029,7 +1056,7 @@ class _LPFLIB_LOCAL Interface { LOG( 0, file << ":" << line << ": pid " << m_pid << ": Could not allocate extra debug memory slots in memory registration table" ); - std::abort(); + lpf_abort(m_ctx); } } @@ -1089,7 +1116,7 @@ class _LPFLIB_LOCAL Interface { << ": Number of global registrations does not match." " I have " << globregs << ", while pid " << p << " has " << m_glob_regs[p] << " global registrations" ); - std::abort(); + lpf_abort(m_ctx); } if (globderegs != m_glob_deregs[p] ) { @@ -1097,7 +1124,7 @@ class _LPFLIB_LOCAL Interface { << ": Number of deregistrations of global slots does not match." " I have " << globderegs << ", while pid " << p << " has " << m_glob_deregs[p] << " deregistrations" ); - std::abort(); + lpf_abort(m_ctx); } } @@ -1128,7 +1155,7 @@ class _LPFLIB_LOCAL Interface { LOG( 0, file << ":" << line << ": pid " << m_pid << ": the " << i << "-th global deregistration mismatches " " on pid " << p << " and " << m_pid ); - std::abort(); + lpf_abort(m_ctx); } } @@ -1181,7 +1208,7 @@ class _LPFLIB_LOCAL Interface { "somehow (other confused pid " << p << " )" ", which makes me think that this is " "an internal error in the debug layer. Sorry!"); - std::abort(); + lpf_abort(m_ctx); } } @@ -1272,7 +1299,7 @@ class _LPFLIB_LOCAL Interface { "Incoming requests from PIDs 0.." << m_nprocs << " = " << s.str() << ". Local request queue follows (" << m_puts.size() << " puts " << "and " << m_gets.size() << " gets )\n" << t.str() ); - std::abort(); + lpf_abort(m_ctx); } // reallocate access buffers if they were resized. @@ -1316,7 +1343,7 @@ class _LPFLIB_LOCAL Interface { << " ) is written past the end by " << ( put.dstOffset + put.size - ds.size[m_pid] ) << " bytes"); - std::abort(); + lpf_abort(m_ctx); } m_rwconflict.insertRead( @@ -1344,7 +1371,7 @@ class _LPFLIB_LOCAL Interface { << " ) is read past the end by " << ( get.srcOffset + get.size - ss.size[m_pid] ) << " bytes"); - std::abort(); + lpf_abort(m_ctx); } size_t & index = m_remote_access_by_me_offsets_local[ get.srcPid ]; @@ -1398,7 +1425,7 @@ class _LPFLIB_LOCAL Interface { << static_cast(ptr+a.offset+a.size) << "); Reads are " << s.str() ; ); - std::abort(); + lpf_abort(m_ctx); } } } @@ -1422,7 +1449,7 @@ class _LPFLIB_LOCAL Interface { << static_cast(ptr+get.dstOffset+get.size) << "); Reads are " << s.str() ; ); - std::abort(); + lpf_abort(m_ctx); } } @@ -1609,6 +1636,10 @@ lpf_err_t lpf_debug_register_local( const char * file, int line, ) { return Interface::lookupCtx( file, line, ctx )->register_local( file, line, pointer, size, memslot); } +extern _LPFLIB_API +lpf_err_t lpf_debug_abort( const char * file, int line, lpf_t ctx) +{ return Interface::lookupCtx( file, line, ctx )->abort( file, line); } + extern _LPFLIB_API lpf_err_t lpf_debug_deregister( const char * file, int line, lpf_t ctx, lpf_memslot_t memslot @@ -1656,7 +1687,6 @@ lpf_err_t lpf_debug_sync( const char * file, int line, lpf_t ctx, lpf_sync_attr_t attr ) { return Interface::lookupCtx( file, line, ctx )->sync( file, line, attr ); } - } // extern "C" diff --git a/src/hybrid/CMakeLists.txt b/src/hybrid/CMakeLists.txt index c2a87b14..ea1a3885 100644 --- a/src/hybrid/CMakeLists.txt +++ b/src/hybrid/CMakeLists.txt @@ -20,8 +20,10 @@ if (HYBRID_ENGINE_ENABLED) set(LPF_IMPL_ID hybrid) set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) -set(LPFLIB_HYBRID_MPI_ENGINE "ibverbs" CACHE STRING - "Choice of MPI engine to use for inter-process communication") +if( NOT DEFINED LPFLIB_HYBRID_MPI_ENGINE ) + message( FATAL_ERROR "Hybrid engine is enabled but no inter-node engine was selected" ) +endif() + set(mpi_engine "${LPFLIB_HYBRID_MPI_ENGINE}" ) message( STATUS "Hybrid implementation's multi-node layer is '${mpi_engine}'") diff --git a/src/hybrid/core.cpp b/src/hybrid/core.cpp index 12870298..404edda8 100644 --- a/src/hybrid/core.cpp +++ b/src/hybrid/core.cpp @@ -35,9 +35,12 @@ #endif - extern "C" { +// the value 2 in this implementation indicates support for lpf_abort in a way +// that may deviate from the stdlib abort() +_LPFLIB_VAR const int LPF_HAS_ABORT = 2; + _LPFLIB_VAR const lpf_err_t LPF_SUCCESS = 0; _LPFLIB_VAR const lpf_err_t LPF_ERR_OUT_OF_MEMORY = 1; _LPFLIB_VAR const lpf_err_t LPF_ERR_FATAL = 2; @@ -384,4 +387,13 @@ _LPFLIB_API lpf_err_t lpf_resize_memory_register( lpf_t ctx, size_t max_regs ) return LPF_SUCCESS; } +_LPFLIB_API lpf_err_t lpf_abort(lpf_t ctx) +{ + using namespace lpf::hybrid; + ThreadState * const t = realContext(ctx); + MPI mpi = t->nodeState().mpi(); + mpi.abort(); + return LPF_SUCCESS; +} + } // extern "C" diff --git a/src/hybrid/dispatch.hpp b/src/hybrid/dispatch.hpp index 1235e513..c131c412 100644 --- a/src/hybrid/dispatch.hpp +++ b/src/hybrid/dispatch.hpp @@ -19,23 +19,29 @@ #define LPF_CORE_HYBRID_DISPATCH_HPP #undef LPFLIB_CORE_H +#undef LPFLIB_ABORT_H #define LPF_CORE_STATIC_DISPATCH #define LPF_CORE_STATIC_DISPATCH_ID pthread #define LPF_CORE_STATIC_DISPATCH_CONFIG LPF_CORE_IMPL_CONFIG #include +#include #undef LPF_CORE_STATIC_DISPATCH_ID #undef LPF_CORE_STATIC_DISPATCH_CONFIG #undef LPFLIB_CORE_H +#undef LPFLIB_ABORT_H #define LPF_CORE_STATIC_DISPATCH_ID LPF_CORE_MULTI_NODE_ENGINE #define LPF_CORE_STATIC_DISPATCH_CONFIG LPF_CORE_IMPL_CONFIG #include +#include #undef LPF_CORE_STATIC_DISPATCH_ID #undef LPF_CORE_STATIC_DISPATCH_CONFIG #undef LPFLIB_CORE_H +#undef LPFLIB_ABORT_H #undef LPF_CORE_STATIC_DISPATCH #include +#include #define USE_THREAD( symbol ) \ LPF_RENAME_PRIMITIVE4( lpf, pthread, LPF_CORE_IMPL_CONFIG, symbol ) @@ -226,6 +232,9 @@ namespace lpf { namespace hybrid { err_t resize_memory_register( size_t max_regs ) { return USE_MPI(resize_memory_register)(m_ctx, max_regs); } + err_t abort( ) + { return USE_MPI(abort)(m_ctx); } + static bool is_linked_correctly() { return SUCCESS != ERR_OUT_OF_MEMORY diff --git a/src/imp/core.c b/src/imp/core.c index 990e267c..e076b811 100644 --- a/src/imp/core.c +++ b/src/imp/core.c @@ -22,6 +22,8 @@ #include #include +const int LPF_HAS_ABORT = 0; + const lpf_err_t LPF_SUCCESS = 0; const lpf_err_t LPF_ERR_OUT_OF_MEMORY = 1; const lpf_err_t LPF_ERR_FATAL = 2; @@ -179,3 +181,8 @@ lpf_err_t lpf_resize_memory_register( lpf_t lpf, size_t max_regs ) return LPF_SUCCESS; } +lpf_err_t lpf_abort( lpf_t lpf ) +{ + (void) lpf; + return LPF_SUCCESS; +} diff --git a/src/pthreads/core.cpp b/src/pthreads/core.cpp index 1d90588a..080b6a1d 100644 --- a/src/pthreads/core.cpp +++ b/src/pthreads/core.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "threadlocaldata.hpp" #include "machineparams.hpp" @@ -37,6 +38,10 @@ #include // for pthreads +// the value 2 in this implementation indicates support for lpf_abort in a way +// that may deviate from the stdlib abort() +const int LPF_HAS_ABORT = 2; + const lpf_err_t LPF_SUCCESS = 0; const lpf_err_t LPF_ERR_OUT_OF_MEMORY = 1; const lpf_err_t LPF_ERR_FATAL = 2; @@ -378,3 +383,15 @@ lpf_err_t lpf_resize_memory_register( lpf_t ctx, size_t max_regs ) return t->resizeMemreg(max_regs); } +lpf_err_t lpf_abort(lpf_t ctx) { + (void) ctx; + // Using std::abort is not portable + // SIGABRT code 6 is often coverted to code 134. + // Therefore, use std::quick_exit(6) instead + // The reason we do not use std::exit is that + // it implies calling destructors, and this leads to + // segmentation faults for pthread backend and abnormal + // programs. std::quick_exit does not call destructors + std::quick_exit(6); + return LPF_SUCCESS; +} diff --git a/test_launcher.py.in b/test_launcher.py.in new file mode 100644 index 00000000..656e570f --- /dev/null +++ b/test_launcher.py.in @@ -0,0 +1,38 @@ +import argparse +import subprocess +import sys + +parser = argparse.ArgumentParser( description='Death test launcher' ) +parser.add_argument("-e", "--engine", type=str) +parser.add_argument("-L", "--parallel_launcher", type=str) +parser.add_argument("-p", "--min_process_count", type=int) +parser.add_argument("-P", "--max_process_count", type=int) +parser.add_argument("-t", "--lpf_probe_timer", type=float) +parser.add_argument("-R", "--expected_return_code", type=int) +parser.add_argument( 'cmd', nargs=argparse.REMAINDER ) +args = parser.parse_args() + +# This is only for passing Gtest info to CMake +# The parallel launcher is still needed as Open MPI +# binaries terminate without the launcher on our cluster, +# even for single process runs +if args.cmd[-1] == '--gtest_list_tests': + run_cmd = [args.parallel_launcher, '-engine', args.engine, '-n', '1'] + args.cmd + cmd = subprocess.run( run_cmd) + sys.exit(cmd.returncode) +# Actual use of our launcher +else: + for i in range(args.min_process_count, args.max_process_count+1): + if args.lpf_probe_timer > 0.0: + run_cmd = [args.parallel_launcher, '-engine', args.engine, '-probe', str(args.lpf_probe_timer), '-n', str(i)] + args.cmd + else: + run_cmd = [args.parallel_launcher, '-engine', args.engine, '-n', str(i)] + args.cmd + print("Run command: ") + print(run_cmd) + cmd = subprocess.run( run_cmd) + print("Test returned code = " + str(cmd.returncode)) + retcode = cmd.returncode + if (retcode != args.expected_return_code): + print("Test " + args.cmd[0] + args.cmd[1] + "\nreturned\t" + str(retcode) + "\nexpected return code was: " + str(args.expected_return_code)) + sys.exit(1) + print("Test " + args.cmd[0] + args.cmd[1] + " passed") diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 7aadf7e1..0eb7eea6 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -15,58 +15,143 @@ # limitations under the License. # -# All test sources have file names as bla.c -file(GLOB AllTestSources "*.c" ) -# All test sources which are specific to some engine are of the form -# bla.pthread.c -file(GLOB AllSpecificTestSources "*.*.c") -# All generic test sources don't have the two dots in their name -file(GLOB AllGenericTestSources "*.c") -list(REMOVE_ITEM AllGenericTestSources ${AllSpecificTestSources}) +set(test_sources + func_bsplib_example_lpf_sum.cpp + func_bsplib_example_lpf_sum_unsafemode.cpp + func_bsplib_example_put_array.cpp + func_bsplib_example_put_array_unsafemode.cpp + func_bsplib_example_reverse.cpp + func_bsplib_example_reverse_unsafemode.cpp + func_bsplib_get_exceptions.cpp + func_bsplib_get_normal.cpp + func_bsplib_get_normal_unsafemode.cpp + func_bsplib_get_twice_on_same_remote.cpp + func_bsplib_get_twice_on_same_remote_unsafemode.cpp + func_bsplib_getput_same_dest.cpp + func_bsplib_getput_same_dest_unsafemode.cpp + func_bsplib_getput_same_remote.cpp + func_bsplib_getput_same_remote_unsafemode.cpp + func_bsplib_getput_zero_bytes.cpp + func_bsplib_hpget_many.cpp + func_bsplib_hpput_many.cpp + func_bsplib_hpsend_many.cpp + func_bsplib_nprocs.cpp + func_bsplib_pid.cpp + func_bsplib_pushpopreg_ambiguous.cpp + func_bsplib_pushpopreg_different_variables.cpp + func_bsplib_pushpopreg_exceptions.cpp + func_bsplib_pushpopreg_many_same.cpp + func_bsplib_pushpopreg_normal.cpp + func_bsplib_pushpopreg_normal_unsafemode.cpp + func_bsplib_pushpopreg_null.cpp + func_bsplib_pushpopreg_pop_before_put.cpp + func_bsplib_pushpopreg_pop_before_put_unsafemode.cpp + func_bsplib_pushpopreg_pop_on_one_process.cpp + func_bsplib_pushpopreg_push_on_one_process.cpp + func_bsplib_pushpopreg_same_growing_memory.cpp + func_bsplib_pushpopreg_same_shrinking_memory.cpp + func_bsplib_pushpopreg_two_pops_before_two_puts.cpp + func_bsplib_put_exceptions.cpp + func_bsplib_put_normal.cpp + func_bsplib_put_normal_unsafemode.cpp + func_bsplib_send_empty_tag.cpp + func_bsplib_send_non_empty_tag.cpp + func_bsplib_send_none.cpp + func_bsplib_send_null.cpp + func_bsplib_send_one.cpp + func_bsplib_send_one_unsafemode.cpp + func_bsplib_set_different_tag_size.cpp + func_bsplib_set_tag_size.cpp + func_bsplib_sync_except_p0.cpp + func_bsplib_sync_only_p0.cpp + func_bsplib_time.cpp + func_lpf_deregister_parallel_multiple.cpp + func_lpf_deregister_parallel_single.cpp + func_lpf_exec_multiple_call_single_arg_dual_proc.cpp + func_lpf_exec_nested_call_single_arg_dual_proc.cpp + func_lpf_exec_single_call_no_arg_max_proc.cpp + func_lpf_exec_single_call_no_arg_single_proc.cpp + func_lpf_exec_single_call_single_arg_dual_proc.cpp + func_lpf_exec_single_call_single_arg_max_proc_early_exit_one.cpp + func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero.cpp + func_lpf_exec_single_call_single_arg_single_proc.cpp + func_lpf_get_parallel_alltoall.cpp + func_lpf_get_parallel_huge.cpp + func_lpf_get_parallel_overlapping_complete.cpp + func_lpf_get_parallel_overlapping_pyramid.cpp + func_lpf_get_parallel_overlapping_rooftiling.cpp + func_lpf_get_parallel_single.cpp + func_lpf_probe_parallel_full.cpp + func_lpf_probe_parallel_nested.cpp + func_lpf_probe_root.cpp + func_lpf_put_and_get_overlapping.cpp + func_lpf_put_parallel_alltoall.cpp + func_lpf_put_parallel_big.cpp + func_lpf_put_parallel_huge.cpp + func_lpf_put_parallel_overlapping_complete.cpp + func_lpf_put_parallel_overlapping_pyramid.cpp + func_lpf_put_parallel_overlapping_rooftiling.cpp + func_lpf_put_parallel_single.cpp + func_lpf_register_and_deregister_irregularly.cpp + func_lpf_register_and_deregister_many_global.cpp + func_lpf_register_global_parallel_grow.cpp + func_lpf_register_global_parallel_multiple.cpp + func_lpf_register_global_parallel_shrink.cpp + func_lpf_register_global_root_multiple.cpp + func_lpf_register_global_root_single.cpp + func_lpf_register_local_parallel_multiple.cpp + func_lpf_resize_delayed_shrinking_memory_registers.cpp + func_lpf_resize_delayed_shrinking_message_queues.cpp + func_lpf_resize_parallel_five.cpp + func_lpf_resize_root_five.cpp + func_lpf_resize_root_outofmem.cpp + func_lpf_resize_root_zero.cpp + macro_LPF_VERSION.cpp + type_lpf_spmd_t.cpp + type_lpf_t.cpp + ) -foreach(LPF_IMPL_ID ${ENGINES}) -foreach(debug ON OFF) +foreach (LPF_IMPL_ID ${ENGINES}) + set(debug ON) set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) - file(GLOB ThisEngineSources "*.${LPF_IMPL_ID}.c") - set(mode) if (debug) - set(mode "_debug") - endif() + set(mode "_debug") + endif(debug) # add all source files except the ones we don't want - foreach(testSource ${AllGenericTestSources} ${ThisEngineSources}) - string(REGEX REPLACE "(.${LPF_IMPL_ID})?.c$" "" baseName ${testSource}) + foreach(testSource ${test_sources}) + string(REGEX REPLACE "(.${LPF_IMPL_ID})?.cpp$" "" baseName ${testSource}) get_filename_component(baseName ${testSource} NAME_WE ) set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") - set(corelib "lpf_core_univ_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}") - set(hllib "lpf_hl${mode}") - set(debuglib "lpf_debug") + add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${testSource}") - add_executable(${exeName} ${testSource}) - target_link_libraries(${exeName} ${hllib}) - target_link_exe_with_core(${exeName} ${LPF_IMPL_ID}) - target_compile_flags(${exeName} PRIVATE ${hllib} "-DLPF_CORE_IMPL_ID=${LPF_IMPL_ID}" ) - - if (debug) - target_link_libraries(${exeName} ${debuglib}) - target_include_directories( ${exeName} BEFORE PRIVATE ../../include/debug ) - endif() - - endforeach() - endforeach(debug) + endforeach(testSource) +endforeach(LPF_IMPL_ID) - add_test( NAME "API_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}" - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/run.sh" "${LPF_IMPL_ID}" - "${LPF_IMPL_CONFIG}" "${test_output}/api_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}.xml" - ) +# start of engine-specific tests +foreach (LPF_IMPL_ID ${ENGINES}) + if ("${LPF_IMPL_ID}" STREQUAL "pthread" OR "${LPF_IMPL_ID}" STREQUAL "mpirma") + foreach(testSource func_lpf_hook_simple.${LPF_IMPL_ID}.cpp) + string(REGEX REPLACE "(.${LPF_IMPL_ID})?.cpp$" "" baseName ${testSource}) + get_filename_component(baseName ${testSource} NAME_WE ) + set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") + add_gtest(${exeName} ${LPF_IMPL_ID} ON "${CMAKE_CURRENT_SOURCE_DIR}/${testSource}") + endforeach(testSource) + endif() + if ("${LPF_IMPL_ID}" STREQUAL "mpimsg") + add_gtest(func_lpf_hook_subset.mpimsg mpimsg ON "${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_hook_subset.mpimsg.cpp") + endif() + if ("${LPF_IMPL_ID}" STREQUAL "mpirma") + add_gtest(func_lpf_hook_tcp_timeout.mpirma mpirma ON "${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_hook_tcp_timeout.mpirma.cpp") + endif() endforeach(LPF_IMPL_ID) +# end of engine-specific tests include_directories(.) - -add_subdirectory(c99) add_subdirectory(debug) +add_subdirectory(collectives) option(LPFLIB_MAKE_TEST_DOC "Build the test documentation" OFF) diff --git a/tests/functional/Test.h b/tests/functional/Test.h deleted file mode 100644 index 1b1eb807..00000000 --- a/tests/functional/Test.h +++ /dev/null @@ -1,135 +0,0 @@ - -/* - * Copyright 2021 Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef LPF_TESTS_FUNCTIONAL_TEST_H -#define LPF_TESTS_FUNCTIONAL_TEST_H - -#include -#include -#include - -#include "assert.hpp" - -#define EXPECT_EQ( format, expected, actual ) \ - do { LPFLIB_IGNORE_TAUTOLOGIES \ - if ( (expected) != (actual) ) { \ - fprintf(stderr, "TEST FAILURE in " __FILE__ ":%d\n" \ - " Expected (%s) which evaluates to " format ", but\n" \ - " actual (%s) which evaluates to " format ".\n", __LINE__, \ - #expected, (expected), #actual, (actual) ); \ - abort(); } \ - LPFLIB_RESTORE_WARNINGS } while(0) - -#define EXPECT_NE( format, expected, actual ) \ - do { LPFLIB_IGNORE_TAUTOLOGIES \ - if ( (expected) == (actual) ) { \ - fprintf(stderr, "TEST FAILURE in " __FILE__ ":%d\n" \ - " Expected (%s) which evaluates to " format " to be different from\n" \ - " actual (%s) which evaluates to " format ".\n", __LINE__, \ - #expected, (expected), #actual, (actual) ); \ - abort(); } \ - LPFLIB_RESTORE_WARNINGS } while(0) - -#define EXPECT_LE( format, expected, actual ) \ - do { LPFLIB_IGNORE_TAUTOLOGIES \ - if ( !( (expected) <= (actual)) ) { \ - fprintf(stderr, "TEST FAILURE in " __FILE__ ":%d\n" \ - " Expected that (%s) which evaluates to " format ", is less than\n" \ - " or equal to (%s) which evaluates to " format ".\n", __LINE__, \ - #expected, (expected), #actual, (actual) ); \ - abort(); } \ - LPFLIB_RESTORE_WARNINGS } while(0) - -#define EXPECT_GE( format, expected, actual ) \ - do { LPFLIB_IGNORE_TAUTOLOGIES \ - if ( !( (expected) >= (actual) )) { \ - fprintf(stderr, "TEST FAILURE in " __FILE__ ":%d\n" \ - " Expected that (%s) which evaluates to " format ", is greater than\n" \ - " or equal to (%s) which evaluates to " format ".\n", __LINE__, \ - #expected, (expected), #actual, (actual) ); \ - abort(); } \ - LPFLIB_RESTORE_WARNINGS } while(0) - -#define EXPECT_LT( format, expected, actual ) \ - do { LPFLIB_IGNORE_TAUTOLOGIES \ - if ( !( (expected) < (actual)) ) { \ - fprintf(stderr, "TEST FAILURE in " __FILE__ ":%d\n" \ - " Expected that (%s) which evaluates to " format ", is less than\n" \ - " (%s) which evaluates to " format ".\n", __LINE__, \ - #expected, (expected), #actual, (actual) ); \ - abort(); } \ - LPFLIB_RESTORE_WARNINGS } while(0) - -#define EXPECT_GT( format, expected, actual ) \ - do { LPFLIB_IGNORE_TAUTOLOGIES \ - if ( !( (expected) > (actual) )) { \ - fprintf(stderr, "TEST FAILURE in " __FILE__ ":%d\n" \ - " Expected that (%s) which evaluates to " format ", is greater than\n" \ - " (%s) which evaluates to " format ".\n", __LINE__, \ - #expected, (expected), #actual, (actual) ); \ - abort(); } \ - LPFLIB_RESTORE_WARNINGS } while(0) - -#define EXPECT_STREQ( N, expected, actual ) \ - do { LPFLIB_IGNORE_TAUTOLOGIES \ - if ( strncmp( (expected), (actual), (N) ) != 0 ) { \ - fprintf(stderr, "TEST FAILURE in " __FILE__ ":%d\n" \ - " Expected (%s) which evaluates to %s, but\n" \ - " actual (%s) which evaluates to %s.\n", __LINE__, \ - #expected, (expected), #actual, (actual) ); \ - abort(); } \ - LPFLIB_RESTORE_WARNINGS } while(0) - -#ifdef __GNUC__ - #define UNUSED __attribute__((unused)) -#else - #define UNUSED -#endif - -/** \mainpage Test documentation - * - * This documentation lists the tests of the LPF implementation - * - \ref APITests - * - */ - -/** \defgroup APITests API Tests - * A set of small programs to test the LPF API. - */ - -#ifdef DOXYGEN -#define TEST( name ) \ - /** \ingroup APITests */ \ - int name( lpf_pid_t P ) - -#else - -#define TEST( name ) \ - /** \ingroup APITests */ \ - int name(int argc, char ** argv); \ - \ - int main(int argc, char ** argv) \ - { \ - (void) argc; (void) argv; \ - return name (argc, argv); \ - } \ - \ - int name(int argc UNUSED, char ** argv UNUSED) - -#endif - -#endif diff --git a/tests/functional/c99/CMakeLists.txt b/tests/functional/c99/CMakeLists.txt deleted file mode 100644 index 584acb59..00000000 --- a/tests/functional/c99/CMakeLists.txt +++ /dev/null @@ -1,51 +0,0 @@ - -# -# Copyright 2021 Huawei Technologies Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -foreach(LPF_IMPL_ID ${ENGINES}) -foreach(debug ON OFF) - set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) - - set(mode) - if (debug) - set(mode "_debug") - endif() - - file(GLOB TestSources "*.c") - foreach(testSource ${TestSources}) - string(REGEX REPLACE ".c$" "" exeName ${testSource}) - get_filename_component(exeName ${testSource} NAME_WE ) - set(exeName "${exeName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") - - set(corelib "lpf_core_univ_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}") - set(hllib "lpf_hl${mode}") - set(debuglib "lpf_debug") - add_executable(${exeName} ${testSource}) - target_link_exe_with_core(${exeName} ${LPF_IMPL_ID}) - target_link_libraries(${exeName} ${hllib}) - set_target_properties(${exeName} PROPERTIES - C_STANDARD 99 - C_STANDARD_REQUIRED YES - ) - target_compile_flags(${exeName} PRIVATE ${hllib}) - if (debug) - target_link_libraries(${exeName} ${debuglib}) - target_include_directories( ${exeName} BEFORE PRIVATE ../../../include/debug ) - endif() - endforeach() -endforeach(debug) -endforeach(LPF_IMPL_ID) - diff --git a/tests/functional/collectives/CMakeLists.txt b/tests/functional/collectives/CMakeLists.txt new file mode 100644 index 00000000..7047e3e6 --- /dev/null +++ b/tests/functional/collectives/CMakeLists.txt @@ -0,0 +1,54 @@ + +# +# Copyright 2021 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +set(c99_tests_sources + func_lpf_allcombine.cpp + func_lpf_allgather.cpp + func_lpf_allgather_overlapped.cpp + func_lpf_allreduce.cpp + func_lpf_alltoall.cpp + func_lpf_broadcast.cpp + func_lpf_broadcast_prime_size_object.cpp + func_lpf_broadcast_small_prime_size_object.cpp + func_lpf_collectives_init.cpp + func_lpf_collectives_init_overflow.cpp + func_lpf_combine.cpp + func_lpf_gather.cpp + func_lpf_reduce.cpp + func_lpf_scatter.cpp +) + +foreach (LPF_IMPL_ID ${ENGINES}) + set(debug ON) + set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) + + set(mode) + if (debug) + set(mode "_debug") + endif(debug) + + # add all source files except the ones we don't want + foreach(testSource ${c99_tests_sources}) + string(REGEX REPLACE "(.${LPF_IMPL_ID})?.cpp$" "" baseName ${testSource}) + get_filename_component(baseName ${testSource} NAME_WE ) + set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") + + add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${testSource}") + + endforeach(testSource) +endforeach(LPF_IMPL_ID) diff --git a/tests/functional/c99/func_lpf_allcombine.c b/tests/functional/collectives/func_lpf_allcombine.cpp similarity index 78% rename from tests/functional/c99/func_lpf_allcombine.c rename to tests/functional/collectives/func_lpf_allcombine.cpp index bdbc5d71..6e7c20e8 100644 --- a/tests/functional/c99/func_lpf_allcombine.c +++ b/tests/functional/collectives/func_lpf_allcombine.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -37,47 +37,47 @@ void spmd( lpf_t ctx, const lpf_pid_t s, const lpf_pid_t p, const lpf_args_t arg lpf_err_t rc; rc = lpf_resize_message_queue( ctx, 2*p ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); const size_t byte_size = (1 << 19) / sizeof(double); const size_t size = byte_size / sizeof(double); - double * data = malloc( byte_size ); - EXPECT_NE( "%p", NULL, data ); + double * data = new double[size]; + EXPECT_NE( nullptr, data ); for( size_t i = 0; i < size; ++i ) { data[ i ] = s; } rc = lpf_register_global( ctx, data, byte_size, &data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, byte_size, &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_allcombine( coll, data, data_slot, size, sizeof(double), &elementwise_add ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for( size_t i = 0; i < size; ++i ) { const double num = (double)(coll.P) / 2.0; const double max = (double)(coll.P-1); - EXPECT_EQ( "%lf", num * max, data[i] ); + EXPECT_EQ( num * max, data[i] ); } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -85,10 +85,9 @@ void spmd( lpf_t ctx, const lpf_pid_t s, const lpf_pid_t p, const lpf_args_t arg * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_allcombine ) +TEST(COLL, func_lpf_allcombine ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS ); - EXPECT_EQ("%d", LPF_SUCCESS, rc); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc); } diff --git a/tests/functional/c99/func_lpf_allgather.c b/tests/functional/collectives/func_lpf_allgather.cpp similarity index 71% rename from tests/functional/c99/func_lpf_allgather.c rename to tests/functional/collectives/func_lpf_allgather.cpp index ced82f8a..9a82b701 100644 --- a/tests/functional/c99/func_lpf_allgather.c +++ b/tests/functional/collectives/func_lpf_allgather.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) @@ -31,66 +31,66 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) lpf_err_t rc; rc = lpf_resize_message_queue( ctx, 2*p); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 3 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - char * src = malloc( size ); - EXPECT_NE( "%p", NULL, src ); + char * src = new char[size] ; + EXPECT_NE( nullptr, src ); - char * dst = malloc( p * size ); - EXPECT_NE( "%p", NULL, dst ); + char * dst = new char[p * size]; + EXPECT_NE( nullptr, dst ); for( size_t i = 0; i < size; ++i ) { src[ i ] = (char)s; } rc = lpf_register_global( ctx, src, size, &src_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ(LPF_SUCCESS, rc ); for( size_t i = 0; i < p * size; ++i ) { dst[ i ] = -1; } rc = lpf_register_global( ctx, dst, p * size, &dst_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, p * size, &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_allgather( coll, src_slot, dst_slot, size, true ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for( size_t i = 0; i < size; ++i ) { - EXPECT_EQ( "%c", (char)s, src[ i ] ); + EXPECT_EQ( (char)s, src[ i ] ); } for( lpf_pid_t k = 0; k < p; ++k ) { for( size_t i = 0; i < size; ++i ) { const size_t index = k * size + i; if( k == s ) { - EXPECT_EQ( "%c", (char) -1, dst[ index ] ); + EXPECT_EQ( (char) -1, dst[ index ] ); } else { - EXPECT_EQ( "%c", (char)k, dst[ index ] ); + EXPECT_EQ( (char)k, dst[ index ] ); } } } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, src_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, dst_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( src ); - free( dst ); + delete[] src; + delete[] dst; } /** @@ -98,10 +98,9 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_allgather ) +TEST(COLL, func_lpf_allgather ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ("%d", LPF_SUCCESS, rc); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc); } diff --git a/tests/functional/c99/func_lpf_allgather_overlapped.c b/tests/functional/collectives/func_lpf_allgather_overlapped.cpp similarity index 75% rename from tests/functional/c99/func_lpf_allgather_overlapped.c rename to tests/functional/collectives/func_lpf_allgather_overlapped.cpp index a3a475c4..f4ad2e21 100644 --- a/tests/functional/c99/func_lpf_allgather_overlapped.c +++ b/tests/functional/collectives/func_lpf_allgather_overlapped.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) @@ -31,15 +31,15 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) lpf_err_t rc; rc = lpf_resize_message_queue( ctx, 2*p); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 3); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - char * data = malloc( p * size ); - EXPECT_NE( "%p", NULL, data ); + char * data = new char[ p * size]; + EXPECT_NE( nullptr, data ); for( lpf_pid_t k = 0; k < p; ++k ) { for( size_t i = 0; i < size; ++i ) { @@ -51,37 +51,37 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) } } rc = lpf_register_global( ctx, data, p * size, &data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( ctx, data + s * size, size, &src_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, p * size, &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_allgather( coll, src_slot, data_slot, size, true ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for( lpf_pid_t k = 0; k < p; ++k ) { for( size_t i = 0; i < size; ++i ) { const size_t index = k * size + i; - EXPECT_EQ( "%c", (char)k, data[ index ] ); + EXPECT_EQ( (char)k, data[ index ] ); } } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, src_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -89,10 +89,9 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_allgather_overlapped ) +TEST( COLL, func_lpf_allgather_overlapped ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_allreduce.c b/tests/functional/collectives/func_lpf_allreduce.cpp similarity index 78% rename from tests/functional/c99/func_lpf_allreduce.c rename to tests/functional/collectives/func_lpf_allreduce.cpp index c7d65b78..7c707c29 100644 --- a/tests/functional/c99/func_lpf_allreduce.c +++ b/tests/functional/collectives/func_lpf_allreduce.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -40,45 +40,45 @@ void spmd( lpf_t ctx, const lpf_pid_t s, const lpf_pid_t p, const lpf_args_t arg lpf_err_t rc; rc = lpf_resize_message_queue( ctx, 2*p - 2); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); double reduced_value = INFINITY; const size_t byte_size = (1 << 19) / sizeof(double); const size_t size = byte_size / sizeof(double); - double * data = malloc( byte_size ); - EXPECT_NE( "%p", NULL, data ); + double * data = new double[size]; + EXPECT_NE( nullptr, data ); for( size_t i = 0; i < size; ++i ) { data[ i ] = s * size + i; } rc = lpf_register_global( ctx, &reduced_value, sizeof(double), &elem_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, sizeof(double), 0, &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); min( size, data, &reduced_value ); rc = lpf_allreduce( coll, &reduced_value, elem_slot, sizeof(double), &min ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%lf", 0.0, reduced_value ); + EXPECT_EQ( 0.0, reduced_value ); rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, elem_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -86,10 +86,9 @@ void spmd( lpf_t ctx, const lpf_pid_t s, const lpf_pid_t p, const lpf_args_t arg * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_allreduce ) +TEST( COLL, func_lpf_allreduce ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_alltoall.c b/tests/functional/collectives/func_lpf_alltoall.cpp similarity index 70% rename from tests/functional/c99/func_lpf_alltoall.c rename to tests/functional/collectives/func_lpf_alltoall.cpp index 157056db..8589146d 100644 --- a/tests/functional/c99/func_lpf_alltoall.c +++ b/tests/functional/collectives/func_lpf_alltoall.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) @@ -31,18 +31,18 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) lpf_err_t rc; rc = lpf_resize_message_queue( ctx, 2 * p - 2); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 3 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - char * src = malloc( p * size ); - EXPECT_NE( "%p", NULL, src ); + char * src = new char[p * size]; + EXPECT_NE( nullptr, src ); - char * dst = malloc( p * size ); - EXPECT_NE( "%p", NULL, dst ); + char * dst = new char[p * size]; + EXPECT_NE( nullptr, dst ); for( size_t i = 0; i < p * size; ++i ) { src[ i ] = (char)s; @@ -50,46 +50,46 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) } rc = lpf_register_global( ctx, src, p * size, &src_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( ctx, dst, p * size, &dst_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, size, &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_alltoall( coll, src_slot, dst_slot, size ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for( size_t i = 0; i < size; ++i ) { - EXPECT_EQ( "%c", (char)s, src[ i ] ); + EXPECT_EQ( (char)s, src[ i ] ); } for( lpf_pid_t k = 0; k < p; ++k ) { for( size_t i = 0; i < size; ++i ) { const size_t index = k * size + i; if( k == s ) { - EXPECT_EQ( "%c", (char) (-s), dst[ index ] ); + EXPECT_EQ( (char) (-s), dst[ index ] ); } else { - EXPECT_EQ( "%c", (char)k, dst[ index ] ); + EXPECT_EQ( (char)k, dst[ index ] ); } } } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, src_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, dst_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( src ); - free( dst ); + delete[] src; + delete[] dst; } /** @@ -97,10 +97,9 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_alltoall ) +TEST( COLL, func_lpf_alltoall ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_broadcast.c b/tests/functional/collectives/func_lpf_broadcast.cpp similarity index 76% rename from tests/functional/c99/func_lpf_broadcast.c rename to tests/functional/collectives/func_lpf_broadcast.cpp index 77e4664d..33bce636 100644 --- a/tests/functional/c99/func_lpf_broadcast.c +++ b/tests/functional/collectives/func_lpf_broadcast.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" long max( long a, long b) { return a < b ? b : a; } @@ -30,16 +30,16 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) lpf_err_t rc; rc = lpf_resize_message_queue( ctx, max( p+1, 2*((long)p)-3)); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); const long size = (1 << 19); - char * data = malloc( size ); - EXPECT_NE( "%p", NULL, data ); + char * data = new char[size]; + EXPECT_NE( nullptr, data ); if( s == p / 2 ) { for( long i = 0; i < size; ++i ) { @@ -52,28 +52,28 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) } rc = lpf_register_global( ctx, data, size, &data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, (1<<19), &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_broadcast( coll, data_slot, data_slot, size, p/2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for( long i = 0; i < size; ++i ) { - EXPECT_EQ( "%c", (char) -1, data[i] ); + EXPECT_EQ( (char) -1, data[i] ); } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -81,10 +81,9 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_broadcast ) +TEST( COLL, func_lpf_broadcast ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_broadcast_prime_size_object.c b/tests/functional/collectives/func_lpf_broadcast_prime_size_object.cpp similarity index 75% rename from tests/functional/c99/func_lpf_broadcast_prime_size_object.c rename to tests/functional/collectives/func_lpf_broadcast_prime_size_object.cpp index 6869063c..06114d52 100644 --- a/tests/functional/c99/func_lpf_broadcast_prime_size_object.c +++ b/tests/functional/collectives/func_lpf_broadcast_prime_size_object.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" long max( long a, long b) { return a < b ? b : a; } @@ -30,16 +30,16 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) lpf_err_t rc; rc = lpf_resize_message_queue( ctx, max( p+1, 2*((long)p)-3)); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); const long size = 197; - char * data = malloc( size ); - EXPECT_NE( "%p", NULL, data ); + char * data = new char[size]; + EXPECT_NE( nullptr, data ); if( s == p / 2 ) { for( long i = 0; i < size; ++i ) { @@ -52,28 +52,28 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) } rc = lpf_register_global( ctx, data, size, &data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, size, &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_broadcast( coll, data_slot, data_slot, size, p/2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for( long i = 0; i < size; ++i ) { - EXPECT_EQ( "%c", (char) -1, data[i] ); + EXPECT_EQ( (char) -1, data[i] ); } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -81,10 +81,9 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_lpf_broadcast_prime_size_object ) +TEST( COLL, func_lpf_broadcast_prime_size_object ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_broadcast_small_prime_size_object.c b/tests/functional/collectives/func_lpf_broadcast_small_prime_size_object.cpp similarity index 76% rename from tests/functional/c99/func_lpf_broadcast_small_prime_size_object.c rename to tests/functional/collectives/func_lpf_broadcast_small_prime_size_object.cpp index 3b043cb3..416a9046 100644 --- a/tests/functional/c99/func_lpf_broadcast_small_prime_size_object.c +++ b/tests/functional/collectives/func_lpf_broadcast_small_prime_size_object.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" long max( long a, long b) { return a < b ? b : a; } @@ -30,16 +30,16 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) lpf_err_t rc; rc = lpf_resize_message_queue( ctx, max( p+1, 2*((long)p)-3)); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); const long size = 11; - char * data = malloc( size ); - EXPECT_NE( "%p", NULL, data ); + char * data = new char[size]; + EXPECT_NE( nullptr, data ); if( s == p / 2 ) { for( long i = 0; i < size; ++i ) { @@ -52,28 +52,28 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) } rc = lpf_register_global( ctx, data, size, &data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, size, &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_broadcast( coll, data_slot, data_slot, size, p/2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for( long i = 0; i < size; ++i ) { - EXPECT_EQ( "%c", (char) -1, data[i] ); + EXPECT_EQ( (char) -1, data[i] ); } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -81,10 +81,9 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_lpf_broadcast_small_prime_size_object ) +TEST( COLL, func_lpf_broadcast_small_prime_size_object ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_collectives_init.c b/tests/functional/collectives/func_lpf_collectives_init.cpp similarity index 75% rename from tests/functional/c99/func_lpf_collectives_init.c rename to tests/functional/collectives/func_lpf_collectives_init.cpp index 0e504f08..5d7e2d9e 100644 --- a/tests/functional/c99/func_lpf_collectives_init.c +++ b/tests/functional/collectives/func_lpf_collectives_init.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args) @@ -28,34 +28,34 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args) lpf_err_t rc; rc = lpf_resize_memory_register( ctx, 4 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, 0, &coll1 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 8, 0, &coll2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, (1<<7), 0, (1<<19), &coll3 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, (1<<4), 8, (1<<25), &coll4 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_destroy( coll1 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_destroy( coll2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_destroy( coll3 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_destroy( coll4 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -63,10 +63,9 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_collectives_init ) +TEST( COLL, func_lpf_collectives_init ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_collectives_init_overflow.c b/tests/functional/collectives/func_lpf_collectives_init_overflow.cpp similarity index 82% rename from tests/functional/c99/func_lpf_collectives_init_overflow.c rename to tests/functional/collectives/func_lpf_collectives_init_overflow.cpp index 7b74da8e..fc1e5e12 100644 --- a/tests/functional/c99/func_lpf_collectives_init_overflow.c +++ b/tests/functional/collectives/func_lpf_collectives_init_overflow.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -29,14 +29,14 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args) lpf_err_t rc; rc = lpf_resize_memory_register( ctx, 5 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); //make sure the base case is OK rc = lpf_collectives_init( ctx, s, p, (1<<7), (1<<7), (1<<7), &coll1 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); //now let us create some overflows const size_t tooBig = (size_t)(-1); @@ -44,34 +44,34 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args) //overflow in the number of calls: may or may not be encountered by an implementation: const lpf_err_t rc1 = lpf_collectives_init( ctx, s, p, tooBig, (1<<7), (1<<7), &coll2 ); bool success = (rc1 == LPF_SUCCESS) || (rc1 == LPF_ERR_OUT_OF_MEMORY); - EXPECT_EQ( "%d", true, success ); + EXPECT_EQ( true, success ); //overflow in the element size required for reduction buffers: an implementation MUST detect this: rc = lpf_collectives_init( ctx, s, p, (1<<7), tooBig, (1<<7), &coll3 ); - EXPECT_EQ( "%d", LPF_ERR_OUT_OF_MEMORY, rc ); + EXPECT_EQ( LPF_ERR_OUT_OF_MEMORY, rc ); //overflow in the collective buffer size: may or may not be encountered by an implementation: const lpf_err_t rc2 = lpf_collectives_init( ctx, s, p, (1<<7), (1<<7), tooBig, &coll4 ); success = (rc2 == LPF_SUCCESS) || (rc2 == LPF_ERR_OUT_OF_MEMORY); - EXPECT_EQ( "%d", true, success ); + EXPECT_EQ( true, success ); //overflow that if not detected would lead to a very small buffer: an implementation MUST detect this: if( p > 1 ) { rc = lpf_collectives_init( ctx, s, p, (1<<7), tooBig / p + 1, (1<<7), &coll5 ); - EXPECT_EQ( "%d", LPF_ERR_OUT_OF_MEMORY, rc ); + EXPECT_EQ( LPF_ERR_OUT_OF_MEMORY, rc ); } rc = lpf_collectives_destroy( coll1 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if( rc1 == LPF_SUCCESS ) { rc = lpf_collectives_destroy( coll2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } if( rc2 == LPF_SUCCESS ) { rc = lpf_collectives_destroy( coll4 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } } @@ -80,10 +80,9 @@ void spmd( lpf_t ctx, lpf_pid_t s, lpf_pid_t p, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_collectives_init_overflow ) +TEST( COLL, func_lpf_collectives_init_overflow ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_combine.c b/tests/functional/collectives/func_lpf_combine.cpp similarity index 79% rename from tests/functional/c99/func_lpf_combine.c rename to tests/functional/collectives/func_lpf_combine.cpp index a3ebc808..8bb5b1e7 100644 --- a/tests/functional/c99/func_lpf_combine.c +++ b/tests/functional/collectives/func_lpf_combine.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -38,51 +38,51 @@ void spmd( lpf_t ctx, const lpf_pid_t s, const lpf_pid_t p, const lpf_args_t arg lpf_err_t rc; rc = lpf_resize_message_queue( ctx, 2*p ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); const size_t byte_size = (1 << 19) / sizeof(double); const size_t size = byte_size / sizeof(double); - double * data = malloc( byte_size ); - EXPECT_NE( "%p", NULL, data ); + double * data = new double[size]; + EXPECT_NE( nullptr, data ); for( size_t i = 0; i < size; ++i ) { data[ i ] = s; } rc = lpf_register_global( ctx, data, byte_size, &data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, byte_size, &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_combine( coll, data, data_slot, size, sizeof(double), &elementwise_add, p / 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if( s == p / 2 ) { for( size_t i = 0; i < size; ++i ) { const double num = (double)(coll.P) / 2.0; const double max = (double)(coll.P-1); - EXPECT_EQ( "%lf", num * max, data[i] ); + EXPECT_EQ( num * max, data[i] ); } } else { //standard declares contents of data as undefined } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -90,10 +90,9 @@ void spmd( lpf_t ctx, const lpf_pid_t s, const lpf_pid_t p, const lpf_args_t arg * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_combine ) +TEST( COLL, func_lpf_combine ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_gather.c b/tests/functional/collectives/func_lpf_gather.cpp similarity index 74% rename from tests/functional/c99/func_lpf_gather.c rename to tests/functional/collectives/func_lpf_gather.cpp index 7f3b95cf..c4c7e6b1 100644 --- a/tests/functional/c99/func_lpf_gather.c +++ b/tests/functional/collectives/func_lpf_gather.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) @@ -29,21 +29,21 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) lpf_err_t rc; rc = lpf_resize_message_queue( ctx, p-1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); const size_t size = (1 << 19); - char * data = NULL; + char * data = nullptr; if( s == p / 2 ) { - data = malloc( size * p ); + data = new char[size * p]; } else { - data = malloc( size ); + data = new char[size]; } - EXPECT_NE( "%p", NULL, data ); + EXPECT_NE( nullptr, data ); if( s == p / 2 ) { for( size_t i = 0; i < size * p; ++i ) { @@ -56,41 +56,41 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) } rc = lpf_register_global( ctx, data, size, &data_slot ); } - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, (1<<19), &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_gather( coll, data_slot, data_slot, size, p / 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if( s == p / 2 ) { for( lpf_pid_t source = 0; source < p; ++source ) { for( size_t i = 0; i < size; ++i ) { const size_t index = source * size + i; if( source == s ) { - EXPECT_EQ( "%c", (char) -1, data[ index ] ); + EXPECT_EQ( (char) -1, data[ index ] ); } else { - EXPECT_EQ( "%c", (char) source, data[ index ] ); + EXPECT_EQ( (char) source, data[ index ] ); } } } } else { for( size_t i = 0; i < size; ++i ) { - EXPECT_EQ( "%c", (char) s, data[i] ); + EXPECT_EQ( (char) s, data[i] ); } } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -98,10 +98,9 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_gather ) +TEST( COLL, func_lpf_gather ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_reduce.c b/tests/functional/collectives/func_lpf_reduce.cpp similarity index 77% rename from tests/functional/c99/func_lpf_reduce.c rename to tests/functional/collectives/func_lpf_reduce.cpp index 404e8f8c..ac970aeb 100644 --- a/tests/functional/c99/func_lpf_reduce.c +++ b/tests/functional/collectives/func_lpf_reduce.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -40,50 +40,50 @@ void spmd( lpf_t ctx, const lpf_pid_t s, const lpf_pid_t p, const lpf_args_t arg lpf_err_t rc; rc = lpf_resize_message_queue( ctx, p - 1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); double reduced_value = INFINITY; const size_t byte_size = (1 << 19) / sizeof(double); const size_t size = byte_size / sizeof(double); - double * data = malloc( byte_size ); - EXPECT_NE( "%p", NULL, data ); + double * data = new double[size]; + EXPECT_NE( nullptr, data ); for( size_t i = 0; i < size; ++i ) { data[ i ] = s * size + i; } rc = lpf_register_global( ctx, &reduced_value, sizeof(double), &element_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, sizeof(double), 0, &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); min( size, data, &reduced_value ); const double local_reduce_value = reduced_value; rc = lpf_reduce( coll, &reduced_value, element_slot, sizeof(double), &min, p / 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if( s == p / 2 ) { - EXPECT_EQ( "%lf", 0.0, reduced_value ); + EXPECT_EQ( 0.0, reduced_value ); } else { - EXPECT_EQ( "%lf", local_reduce_value, reduced_value ); + EXPECT_EQ( local_reduce_value, reduced_value ); } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, element_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -91,10 +91,9 @@ void spmd( lpf_t ctx, const lpf_pid_t s, const lpf_pid_t p, const lpf_args_t arg * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_reduce ) +TEST( COLL, func_lpf_reduce ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/c99/func_lpf_scatter.c b/tests/functional/collectives/func_lpf_scatter.cpp similarity index 75% rename from tests/functional/c99/func_lpf_scatter.c rename to tests/functional/collectives/func_lpf_scatter.cpp index ade4fbab..96f3f9fe 100644 --- a/tests/functional/c99/func_lpf_scatter.c +++ b/tests/functional/collectives/func_lpf_scatter.cpp @@ -18,7 +18,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) @@ -29,21 +29,21 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) lpf_err_t rc; rc = lpf_resize_message_queue( ctx, p-1 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); const size_t size = (1 << 19); char * data = NULL; if( s == p / 2 ) { - data = malloc( size * p ); + data = new char[size * p ]; } else { - data = malloc( size ); + data = new char[size]; } - EXPECT_NE( "%p", NULL, data ); + EXPECT_NE( nullptr, data ); if( s == p / 2 ) { for( size_t i = 0; i < size * p; ++i ) { @@ -56,34 +56,34 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) } rc = lpf_register_global( ctx, data, size, &data_slot ); } - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_collectives_init( ctx, s, p, 1, 0, (1<<19), &coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_scatter( coll, data_slot, data_slot, size, p / 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if( s == p / 2 ) { for( size_t i = 0; i < size * p; ++i ) { - EXPECT_EQ( "%c", (char)i, data[i] ); + EXPECT_EQ( (char)i, data[i] ); } } else { for( size_t i = 0; i < size; ++i ) { - EXPECT_EQ( "%c", (char)(s * size + i), data[i] ); + EXPECT_EQ( (char)(s * size + i), data[i] ); } } rc = lpf_collectives_destroy( coll ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( ctx, data_slot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - free( data ); + delete[] data; } /** @@ -91,10 +91,9 @@ void spmd( lpf_t ctx, const lpf_pid_t s, lpf_pid_t p, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_scatter ) +TEST( COLL, func_lpf_scatter ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/CMakeLists.txt b/tests/functional/debug/CMakeLists.txt index e9b8e5c7..67ffcb5d 100644 --- a/tests/functional/debug/CMakeLists.txt +++ b/tests/functional/debug/CMakeLists.txt @@ -14,35 +14,90 @@ # See the License for the specific language governing permissions and # limitations under the License. # +set(debug_test_sources + func_lpf_debug_deregister_non_existing_slot.cpp + func_lpf_debug_exec_null_f_symbols.cpp + func_lpf_debug_exec_null_input.cpp + func_lpf_debug_exec_null_output.cpp + func_lpf_debug_exec_null_spmd.cpp + func_lpf_debug_get_local_src_slot.cpp + func_lpf_debug_get_overflow_dst_offset.cpp + func_lpf_debug_get_overflow_src_offset.cpp + func_lpf_debug_get_read_past_source_memory_global_known_at_sync.cpp + func_lpf_debug_get_read_past_source_memory_global_known_before_sync.cpp + func_lpf_debug_get_too_many_requests.cpp + func_lpf_debug_get_too_many_requests_remote.cpp + func_lpf_debug_get_too_many_requests_self.cpp + func_lpf_debug_get_unknown_dest_slot.cpp + func_lpf_debug_get_unknown_source_pid.cpp + func_lpf_debug_get_unknown_source_slot.cpp + func_lpf_debug_get_write_past_dest_memory_global.cpp + func_lpf_debug_get_write_past_dest_memory_local.cpp + func_lpf_debug_global_deregister_mismatch.cpp + func_lpf_debug_global_deregister_order_mismatch.cpp + func_lpf_debug_global_deregister_unequal.cpp + func_lpf_debug_global_register_null_memreg.cpp + func_lpf_debug_local_register_null_memreg.cpp + func_lpf_debug_put_after_deregister_dest_after_sync.cpp + func_lpf_debug_put_after_deregister_dest.cpp + func_lpf_debug_put_after_deregister_source_after_sync.cpp + func_lpf_debug_put_after_deregister_source.cpp + func_lpf_debug_put_get_too_many_requests.cpp + func_lpf_debug_put_get_too_many_requests_remote.cpp + func_lpf_debug_put_local_dest_slot.cpp + func_lpf_debug_put_overflow_dst_offset.cpp + func_lpf_debug_put_overflow_src_offset.cpp + func_lpf_debug_put_read_past_source_memory_global.cpp + func_lpf_debug_put_read_past_source_memory_local.cpp + func_lpf_debug_put_read_write_conflict_among_many.cpp + func_lpf_debug_put_read_write_conflict.cpp + func_lpf_debug_put_too_many_requests.cpp + func_lpf_debug_put_too_many_requests_remote.cpp + func_lpf_debug_put_too_many_requests_self.cpp + func_lpf_debug_put_unknown_dest_pid.cpp + func_lpf_debug_put_unknown_dest_slot.cpp + func_lpf_debug_put_unknown_source_slot.cpp + func_lpf_debug_put_write_past_dest_memory_global_known_at_sync.cpp + func_lpf_debug_put_write_past_dest_memory_global_known_before_sync.cpp + func_lpf_debug_register_global_dst_unsynced.cpp + func_lpf_debug_register_global_src_unsynced.cpp + func_lpf_debug_register_global_unequal.cpp + func_lpf_debug_rehook_null_f_symbols.cpp + func_lpf_debug_rehook_null_input.cpp + func_lpf_debug_rehook_null_output.cpp + func_lpf_debug_rehook_null_spmd.cpp + func_lpf_debug_resize_memory_register_with_size_max_minus_three.cpp + ) -# All test sources have file names as bla.c -file(GLOB AllTestSources "*.c" ) -# All test sources which are specific to some engine are of the form -# bla.pthread.c -file(GLOB AllSpecificTestSources "*.*.c") -# All generic test sources don't have the two dots in their name -file(GLOB AllGenericTestSources "*.c") -list(REMOVE_ITEM AllGenericTestSources ${AllSpecificTestSources}) -foreach(LPF_IMPL_ID ${ENGINES}) - set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) +set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) +set(debug ON) +set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) +set(mode) +if (debug) + set(mode "_debug") +endif(debug) +foreach (LPF_IMPL_ID ${ENGINES}) + foreach(testSource ${debug_test_sources}) - file(GLOB ThisEngineSources "*.${LPF_IMPL_ID}.c") - - # add all source files except the ones we don't want - foreach(testSource ${AllGenericTestSources} ${ThisEngineSources}) - string(REGEX REPLACE ".c$" "" baseName ${testSource}) + string(REGEX REPLACE "(.${LPF_IMPL_ID})?.cpp$" "" baseName ${testSource}) get_filename_component(baseName ${testSource} NAME_WE ) - set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}") - set(corelib "lpf_core_univ_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}") - set(debuglib "lpf_debug") + set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") - add_executable(${exeName} ${testSource}) - target_include_directories( ${exeName} BEFORE PRIVATE ../../../include/debug ) - target_link_libraries(${exeName} ${debuglib}) - target_link_exe_with_core(${exeName} ${LPF_IMPL_ID}) - target_compile_flags(${exeName} PRIVATE "-DLPF_CORE_IMPL_ID=${LPF_IMPL_ID}" ) - endforeach() + add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${testSource}" ) + endforeach(testSource) endforeach(LPF_IMPL_ID) +add_gtest(func_lpf_debug_hook_f_symbols_pthread "pthread" ON + ${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_debug_hook_null_f_symbols.pthread.cpp) + +add_gtest(func_lpf_debug_hook_null_input_pthread "pthread" ON + ${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_debug_hook_null_input.pthread.cpp) + +add_gtest(func_lpf_debug_hook_null_output_pthread "pthread" ON + ${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_debug_hook_null_output.pthread.cpp) + +add_gtest(func_lpf_debug_hook_null_spmd_pthread "pthread" ON + ${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_debug_hook_null_spmd.pthread.cpp) + diff --git a/tests/functional/debug/func_lpf_debug_deregister_non_existing_slot.c b/tests/functional/debug/func_lpf_debug_deregister_non_existing_slot.cpp similarity index 90% rename from tests/functional/debug/func_lpf_debug_deregister_non_existing_slot.c rename to tests/functional/debug/func_lpf_debug_deregister_non_existing_slot.cpp index 7bf36563..5afa95a2 100644 --- a/tests/functional/debug/func_lpf_debug_deregister_non_existing_slot.c +++ b/tests/functional/debug/func_lpf_debug_deregister_non_existing_slot.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -34,10 +34,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Invalid attempt to deregister a memory slot, because it has not been registered before * \return Exit code: 6 */ -TEST( func_lpf_debug_deregister_non_existing_slot ) +TEST(API, func_lpf_debug_deregister_non_existing_slot ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ(LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_exec_null_f_symbols.c b/tests/functional/debug/func_lpf_debug_exec_null_f_symbols.cpp similarity index 84% rename from tests/functional/debug/func_lpf_debug_exec_null_f_symbols.c rename to tests/functional/debug/func_lpf_debug_exec_null_f_symbols.cpp index ac7d0ac7..80aad5b8 100644 --- a/tests/functional/debug/func_lpf_debug_exec_null_f_symbols.c +++ b/tests/functional/debug/func_lpf_debug_exec_null_f_symbols.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t a, lpf_pid_t b, lpf_pid_t c, lpf_args_t d) { @@ -30,9 +30,8 @@ void spmd( lpf_t a, lpf_pid_t b, lpf_pid_t c, lpf_args_t d) * \return Message: NULL f_symbols argument while f_size is non-zero * \return Exit code: 6 */ -TEST( func_lpf_debug_exec_null_f_symbols ) +TEST(API, func_lpf_debug_exec_null_f_symbols ) { - lpf_err_t rc = LPF_SUCCESS; lpf_args_t args; args.input = NULL; args.input_size = 0; @@ -40,7 +39,5 @@ TEST( func_lpf_debug_exec_null_f_symbols ) args.output_size = 0; args.f_symbols = NULL; args.f_size = 4; - rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ(lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, args ), LPF_SUCCESS); } diff --git a/tests/functional/debug/func_lpf_debug_exec_null_input.c b/tests/functional/debug/func_lpf_debug_exec_null_input.cpp similarity index 87% rename from tests/functional/debug/func_lpf_debug_exec_null_input.c rename to tests/functional/debug/func_lpf_debug_exec_null_input.cpp index fdc246f3..8b49a423 100644 --- a/tests/functional/debug/func_lpf_debug_exec_null_input.c +++ b/tests/functional/debug/func_lpf_debug_exec_null_input.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t a, lpf_pid_t b, lpf_pid_t c, lpf_args_t d) { @@ -31,7 +31,7 @@ void spmd( lpf_t a, lpf_pid_t b, lpf_pid_t c, lpf_args_t d) * \return Message: NULL input argument while input_size is non-zero * \return Exit code: 6 */ -TEST( func_lpf_debug_exec_null_input ) +TEST( API, func_lpf_debug_exec_null_input ) { lpf_err_t rc = LPF_SUCCESS; lpf_args_t args; @@ -41,7 +41,6 @@ TEST( func_lpf_debug_exec_null_input ) args.output_size = 0; args.f_symbols = NULL; args.f_size = 0; - rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ(lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, args ), rc); + FAIL(); } diff --git a/tests/functional/debug/func_lpf_debug_exec_null_output.c b/tests/functional/debug/func_lpf_debug_exec_null_output.cpp similarity index 87% rename from tests/functional/debug/func_lpf_debug_exec_null_output.c rename to tests/functional/debug/func_lpf_debug_exec_null_output.cpp index cdd09557..dff1181d 100644 --- a/tests/functional/debug/func_lpf_debug_exec_null_output.c +++ b/tests/functional/debug/func_lpf_debug_exec_null_output.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t a, lpf_pid_t b, lpf_pid_t c, lpf_args_t d) { @@ -31,7 +31,7 @@ void spmd( lpf_t a, lpf_pid_t b, lpf_pid_t c, lpf_args_t d) * \return Message: NULL output argument while output_size is non-zero * \return Exit code: 6 */ -TEST( func_lpf_debug_exec_null_output ) +TEST( API, func_lpf_debug_exec_null_output ) { lpf_err_t rc = LPF_SUCCESS; lpf_args_t args; @@ -41,7 +41,6 @@ TEST( func_lpf_debug_exec_null_output ) args.output_size = 10; args.f_symbols = NULL; args.f_size = 0; - rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ(lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, args ), rc); + FAIL(); } diff --git a/tests/functional/debug/func_lpf_debug_exec_null_spmd.c b/tests/functional/debug/func_lpf_debug_exec_null_spmd.cpp similarity index 83% rename from tests/functional/debug/func_lpf_debug_exec_null_spmd.c rename to tests/functional/debug/func_lpf_debug_exec_null_spmd.cpp index a58a868b..d8cd995f 100644 --- a/tests/functional/debug/func_lpf_debug_exec_null_spmd.c +++ b/tests/functional/debug/func_lpf_debug_exec_null_spmd.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" /** @@ -26,10 +26,9 @@ * \return Message: NULL spmd argument * \return Exit code: 6 */ -TEST( func_lpf_debug_exec_null_spmd ) +TEST( API, func_lpf_debug_exec_null_spmd ) { lpf_err_t rc = LPF_SUCCESS; - rc = lpf_exec( LPF_ROOT, LPF_MAX_P, NULL, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ(lpf_exec( LPF_ROOT, LPF_MAX_P, NULL, LPF_NO_ARGS ), rc); + FAIL(); } diff --git a/tests/functional/debug/func_lpf_debug_get_local_src_slot.c b/tests/functional/debug/func_lpf_debug_get_local_src_slot.cpp similarity index 71% rename from tests/functional/debug/func_lpf_debug_get_local_src_slot.c rename to tests/functional/debug/func_lpf_debug_get_local_src_slot.cpp index 391e84db..99b94740 100644 --- a/tests/functional/debug/func_lpf_debug_get_local_src_slot.c +++ b/tests/functional/debug/func_lpf_debug_get_local_src_slot.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,27 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ(LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ(LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ(LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ(LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ(LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ(LPF_SUCCESS, rc ); - rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 0, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ(lpf_get( lpf, (pid+1)%nprocs, xSlot, 0, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ), rc); + FAIL(); - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - EXPECT_EQ("%d", 3, y ); } /** @@ -59,10 +56,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: source memory must be globally registered. Instead, it was registered only locally * \return Exit code: 6 */ -TEST( func_lpf_debug_get_local_src_slot ) +TEST( API, func_lpf_debug_get_local_src_slot ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_overflow_dst_offset.c b/tests/functional/debug/func_lpf_debug_get_overflow_dst_offset.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_get_overflow_dst_offset.c rename to tests/functional/debug/func_lpf_debug_get_overflow_dst_offset.cpp index ff397d6e..f6062667 100644 --- a/tests/functional/debug/func_lpf_debug_get_overflow_dst_offset.c +++ b/tests/functional/debug/func_lpf_debug_get_overflow_dst_offset.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 0, ySlot, 2, -1, LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); } /** @@ -59,10 +55,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: numerical overflow while computing dst_offset * \return Exit code: 6 */ -TEST( func_lpf_debug_get_overflow_dst_offset ) +TEST( API, func_lpf_debug_get_overflow_dst_offset ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_overflow_src_offset.c b/tests/functional/debug/func_lpf_debug_get_overflow_src_offset.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_get_overflow_src_offset.c rename to tests/functional/debug/func_lpf_debug_get_overflow_src_offset.cpp index 01e66483..0e70005e 100644 --- a/tests/functional/debug/func_lpf_debug_get_overflow_src_offset.c +++ b/tests/functional/debug/func_lpf_debug_get_overflow_src_offset.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 2, ySlot, 0, -1, LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); } /** @@ -59,10 +55,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: numerical overflow while computing src_offset * \return Exit code: 6 */ -TEST( func_lpf_debug_get_overflow_src_offset ) +TEST( API, func_lpf_debug_get_overflow_src_offset ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_at_sync.c b/tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_at_sync.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_at_sync.c rename to tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_at_sync.cpp index 5336977b..dc17a89c 100644 --- a/tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_at_sync.c +++ b/tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_at_sync.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,31 +27,31 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 3, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // the write error will be detected at this sync rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ("%d", 3, y ); + EXPECT_EQ( 3, y ); } /** @@ -60,10 +60,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: source memory .* is read past the end by 3 bytes * \return Exit code: 6 */ -TEST( func_lpf_debug_get_read_past_source_memory_global_known_at_sync ) +TEST( API, func_lpf_debug_get_read_past_source_memory_global_known_at_sync ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_before_sync.c b/tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_before_sync.cpp similarity index 70% rename from tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_before_sync.c rename to tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_before_sync.cpp index 11244431..c5b84679 100644 --- a/tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_before_sync.c +++ b/tests/functional/debug/func_lpf_debug_get_read_past_source_memory_global_known_before_sync.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 1, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + lpf_get( lpf, (pid+1)%nprocs, xSlot, 1, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); + FAIL(); - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); } /** @@ -59,10 +55,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: source memory .* is read past the end by 1 bytes * \return Exit code: 6 */ -TEST( func_lpf_debug_get_read_past_source_memory_global_known_before_sync ) +TEST( API, func_lpf_debug_get_read_past_source_memory_global_known_before_sync ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_too_many_requests.c b/tests/functional/debug/func_lpf_debug_get_too_many_requests.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_get_too_many_requests.c rename to tests/functional/debug/func_lpf_debug_get_too_many_requests.cpp index 740fbf41..895260c9 100644 --- a/tests/functional/debug/func_lpf_debug_get_too_many_requests.c +++ b/tests/functional/debug/func_lpf_debug_get_too_many_requests.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,34 +28,33 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 0, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_get( lpf, (pid+2)%nprocs, xSlot, sizeof(int), ySlot, sizeof(int), sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); + rc = lpf_get( lpf, (pid+2)%nprocs, xSlot, sizeof(int), ySlot, sizeof(int), sizeof(int), LPF_MSG_DEFAULT); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ(LPF_SUCCESS, rc ); - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + EXPECT_EQ(3, y[0] ); + EXPECT_EQ(4, y[1] ); } /** @@ -64,10 +63,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: This is the 2-th message, while space for only 1 has been reserved * \return Exit code: 6 */ -TEST( func_lpf_debug_get_too_many_requests ) +TEST( API, func_lpf_debug_get_too_many_requests ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_too_many_requests_remote.c b/tests/functional/debug/func_lpf_debug_get_too_many_requests_remote.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_get_too_many_requests_remote.c rename to tests/functional/debug/func_lpf_debug_get_too_many_requests_remote.cpp index 4adf89b0..c197a749 100644 --- a/tests/functional/debug/func_lpf_debug_get_too_many_requests_remote.c +++ b/tests/functional/debug/func_lpf_debug_get_too_many_requests_remote.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,38 +28,38 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if (pid % 2 == 0 && pid != 0) { rc = lpf_get( lpf, 0, xSlot, 0, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } if (pid % 2 == 1) { rc = lpf_get( lpf, 0, xSlot, sizeof(int), ySlot, sizeof(int), sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + EXPECT_EQ( 3, y[0] ); + EXPECT_EQ( 4, y[1] ); } /** @@ -68,10 +68,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Too many messages on pid 0. Reserved was 1 while there were actually * \return Exit code: 6 */ -TEST( func_lpf_debug_get_too_many_requests_remote ) +TEST( API, func_lpf_debug_get_too_many_requests_remote ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_too_many_requests_self.c b/tests/functional/debug/func_lpf_debug_get_too_many_requests_self.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_get_too_many_requests_self.c rename to tests/functional/debug/func_lpf_debug_get_too_many_requests_self.cpp index 29718213..9a75dc77 100644 --- a/tests/functional/debug/func_lpf_debug_get_too_many_requests_self.c +++ b/tests/functional/debug/func_lpf_debug_get_too_many_requests_self.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,31 +28,30 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); + rc = lpf_get( lpf, 0, xSlot, 0, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); } /** @@ -62,10 +61,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Too many messages on pid 0. Reserved was 1 while there were actually 2 in total * \return Exit code: 6 */ -TEST( func_lpf_debug_get_too_many_requests_self ) +TEST( API, func_lpf_debug_get_too_many_requests_self ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_unknown_dest_slot.c b/tests/functional/debug/func_lpf_debug_get_unknown_dest_slot.cpp similarity index 76% rename from tests/functional/debug/func_lpf_debug_get_unknown_dest_slot.c rename to tests/functional/debug/func_lpf_debug_get_unknown_dest_slot.cpp index 3e0af8ed..eb543ef0 100644 --- a/tests/functional/debug/func_lpf_debug_get_unknown_dest_slot.c +++ b/tests/functional/debug/func_lpf_debug_get_unknown_dest_slot.cpp @@ -17,37 +17,33 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) args; int x = 3, y = 6; + (void) y; // this test purposefully tests for the (erroneous) not-use of y lpf_memslot_t xSlot = LPF_INVALID_MEMSLOT; lpf_memslot_t ySlot = xSlot + 2; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 0, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + FAIL(); } /** @@ -56,10 +52,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: destination memory slot does not exist * \return Exit code: 6 */ -TEST( func_lpf_debug_get_unknown_dest_slot ) +TEST( API, func_lpf_debug_get_unknown_dest_slot ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_unknown_source_pid.c b/tests/functional/debug/func_lpf_debug_get_unknown_source_pid.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_get_unknown_source_pid.c rename to tests/functional/debug/func_lpf_debug_get_unknown_source_pid.cpp index f143ec2a..a356339d 100644 --- a/tests/functional/debug/func_lpf_debug_get_unknown_source_pid.c +++ b/tests/functional/debug/func_lpf_debug_get_unknown_source_pid.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,31 +28,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, 6 , xSlot, 0, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); } /** @@ -62,10 +57,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: unknown process ID 6 for data source * \return Exit code: 6 */ -TEST( func_lpf_debug_get_unknown_source_pid ) +TEST( API, func_lpf_debug_get_unknown_source_pid ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_unknown_source_slot.c b/tests/functional/debug/func_lpf_debug_get_unknown_source_slot.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_get_unknown_source_slot.c rename to tests/functional/debug/func_lpf_debug_get_unknown_source_slot.cpp index 92753779..b80ccc51 100644 --- a/tests/functional/debug/func_lpf_debug_get_unknown_source_slot.c +++ b/tests/functional/debug/func_lpf_debug_get_unknown_source_slot.cpp @@ -17,37 +17,33 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) args; int x = 3, y = 6; + (void) y; // this test purposefully tests for the (erroneous) not-use of y lpf_memslot_t xSlot = LPF_INVALID_MEMSLOT; lpf_memslot_t ySlot = xSlot + 2; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+1)%nprocs, ySlot, 0, xSlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + FAIL(); } /** @@ -56,10 +52,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: source memory slot does not exist * \return Exit code: 6 */ -TEST( func_lpf_debug_get_unknown_source_slot ) +TEST( API, func_lpf_debug_get_unknown_source_slot ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_global.c b/tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_global.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_global.c rename to tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_global.cpp index f7491522..c0fbfcb7 100644 --- a/tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_global.c +++ b/tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_global.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,25 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 0, ySlot, 1, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + FAIL(); } /** @@ -59,10 +54,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: destination memory .* is written past the end by 1 bytes * \return Exit code: 6 */ -TEST( func_lpf_debug_get_write_past_dest_memory_global ) +TEST( API, func_lpf_debug_get_write_past_dest_memory_global ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_local.c b/tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_local.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_local.c rename to tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_local.cpp index b5bab7c5..26f76f34 100644 --- a/tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_local.c +++ b/tests/functional/debug/func_lpf_debug_get_write_past_dest_memory_local.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,25 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 0, ySlot, 2, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + FAIL(); } /** @@ -59,10 +54,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: destination memory .* is written past the end by 2 bytes * \return Exit code: 6 */ -TEST( func_lpf_debug_get_write_past_dest_memory_local ) +TEST( API, func_lpf_debug_get_write_past_dest_memory_local ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_global_deregister_mismatch.c b/tests/functional/debug/func_lpf_debug_global_deregister_mismatch.cpp similarity index 78% rename from tests/functional/debug/func_lpf_debug_global_deregister_mismatch.c rename to tests/functional/debug/func_lpf_debug_global_deregister_mismatch.cpp index 29b2836b..661cc266 100644 --- a/tests/functional/debug/func_lpf_debug_global_deregister_mismatch.c +++ b/tests/functional/debug/func_lpf_debug_global_deregister_mismatch.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,28 +28,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, pid == 0 ? xSlot : ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - + EXPECT_EQ( LPF_SUCCESS, rc ); + rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); } /** @@ -58,10 +58,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: global deregistration mismatches * \return Exit code: 6 */ -TEST( func_lpf_debug_global_deregister_mismatch ) +TEST( API, func_lpf_debug_global_deregister_mismatch ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_global_deregister_order_mismatch.c b/tests/functional/debug/func_lpf_debug_global_deregister_order_mismatch.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_global_deregister_order_mismatch.c rename to tests/functional/debug/func_lpf_debug_global_deregister_order_mismatch.cpp index 90e12664..ee9727de 100644 --- a/tests/functional/debug/func_lpf_debug_global_deregister_order_mismatch.c +++ b/tests/functional/debug/func_lpf_debug_global_deregister_order_mismatch.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,31 +28,29 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, pid == 0 ? xSlot : ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, pid == 0 ? ySlot : xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); } /** @@ -61,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: global deregistration mismatches * \return Exit code: 6 */ -TEST( func_lpf_debug_global_deregister_order_mismatch ) +TEST( API, func_lpf_debug_global_deregister_order_mismatch ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_global_deregister_unequal.c b/tests/functional/debug/func_lpf_debug_global_deregister_unequal.cpp similarity index 79% rename from tests/functional/debug/func_lpf_debug_global_deregister_unequal.c rename to tests/functional/debug/func_lpf_debug_global_deregister_unequal.cpp index 9ae4ea00..6b0433ee 100644 --- a/tests/functional/debug/func_lpf_debug_global_deregister_unequal.c +++ b/tests/functional/debug/func_lpf_debug_global_deregister_unequal.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,30 +28,30 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if (pid == 0) { rc = lpf_deregister( lpf, xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); } /** @@ -60,10 +60,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Number of deregistrations of global slots does not match. * \return Exit code: 6 */ -TEST( func_lpf_debug_deregister_global_unequal ) +TEST( API, func_lpf_debug_deregister_global_unequal ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_global_register_null_memreg.c b/tests/functional/debug/func_lpf_debug_global_register_null_memreg.cpp similarity index 90% rename from tests/functional/debug/func_lpf_debug_global_register_null_memreg.c rename to tests/functional/debug/func_lpf_debug_global_register_null_memreg.cpp index 25f4641a..f20f405a 100644 --- a/tests/functional/debug/func_lpf_debug_global_register_null_memreg.c +++ b/tests/functional/debug/func_lpf_debug_global_register_null_memreg.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -25,6 +25,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) int x = 0; lpf_memslot_t xSlot = LPF_INVALID_MEMSLOT; lpf_register_global( lpf, &x, sizeof(x), &xSlot ); + FAIL(); } /** @@ -33,10 +34,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Invalid global memory registration, which would have taken the 1-th slot, while only space for 0 slots has been reserved * \return Exit code: 6 */ -TEST( func_lpf_debug_global_register_null_memreg ) +TEST( API, func_lpf_debug_global_register_null_memreg ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_hook_null_f_symbols.pthread.c b/tests/functional/debug/func_lpf_debug_hook_null_f_symbols.pthread.cpp similarity index 81% rename from tests/functional/debug/func_lpf_debug_hook_null_f_symbols.pthread.c rename to tests/functional/debug/func_lpf_debug_hook_null_f_symbols.pthread.cpp index ecaad199..51eb6a5e 100644 --- a/tests/functional/debug/func_lpf_debug_hook_null_f_symbols.pthread.c +++ b/tests/functional/debug/func_lpf_debug_hook_null_f_symbols.pthread.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -32,7 +32,7 @@ void lpf_spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) ctx; (void) pid; (void) nprocs; (void) args; } void * pthread_spmd( void * _data ) { - EXPECT_NE( "%p", _data, NULL ); + EXPECT_NE( _data, nullptr); const struct thread_local_data data = * ((struct thread_local_data*) _data); const int pts_rc = pthread_setspecific( pid_key, _data ); @@ -46,61 +46,63 @@ void * pthread_spmd( void * _data ) { lpf_init_t init; lpf_err_t rc = LPF_SUCCESS; - EXPECT_EQ( "%d", pts_rc, 0 ); + EXPECT_EQ( pts_rc, 0 ); rc = lpf_pthread_initialize( (lpf_pid_t)data.s, (lpf_pid_t)data.P, &init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_hook( init, &lpf_spmd, args ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_pthread_finalize( init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); return NULL; } +// the below tests for return code 134 as this is what aborted programs return +// as an error code on modern systems + /** * \test Tests lpf_hook on pthread implementation with NULL f_symbols * \pre P <= 1 * \pre P >= 1 * \return Message: NULL f_symbols argument while f_size is non-zero - * \return Exit code: 6 + * \return Exit code: 134 */ -TEST( func_lpf_hook_null_f_symbols ) +TEST( API, func_lpf_hook_null_f_symbols ) { long k = 0; const long P = sysconf( _SC_NPROCESSORS_ONLN ); const int ptc_rc = pthread_key_create( &pid_key, NULL ); - EXPECT_EQ( "%d", ptc_rc, 0 ); + EXPECT_EQ( ptc_rc, 0 ); pthread_t * const threads = (pthread_t*) malloc( P * sizeof(pthread_t) ); - EXPECT_NE( "%p", threads, NULL ); + EXPECT_NE( threads, nullptr ); struct thread_local_data * const data = (struct thread_local_data*) malloc( P * sizeof(struct thread_local_data) ); - EXPECT_NE( "%p", data, NULL ); + EXPECT_NE( data, nullptr ); for( k = 0; k < P; ++k ) { data[ k ].P = P; data[ k ].s = k; const int rval = pthread_create( threads + k, NULL, &pthread_spmd, data + k ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } for( k = 0; k < P; ++k ) { const int rval = pthread_join( threads[ k ], NULL ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } const int ptd_rc = pthread_key_delete( pid_key ); - EXPECT_EQ( "%d", ptd_rc, 0 ); + EXPECT_EQ( ptd_rc, 0 ); - return 0; } diff --git a/tests/functional/debug/func_lpf_debug_hook_null_input.pthread.c b/tests/functional/debug/func_lpf_debug_hook_null_input.pthread.cpp similarity index 80% rename from tests/functional/debug/func_lpf_debug_hook_null_input.pthread.c rename to tests/functional/debug/func_lpf_debug_hook_null_input.pthread.cpp index 04c7c355..051f8542 100644 --- a/tests/functional/debug/func_lpf_debug_hook_null_input.pthread.c +++ b/tests/functional/debug/func_lpf_debug_hook_null_input.pthread.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -32,7 +32,7 @@ void lpf_spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) ctx; (void) pid; (void) nprocs; (void) args; } void * pthread_spmd( void * _data ) { - EXPECT_NE( "%p", _data, NULL ); + EXPECT_NE( _data, (void*)NULL ); const struct thread_local_data data = * ((struct thread_local_data*) _data); const int pts_rc = pthread_setspecific( pid_key, _data ); @@ -46,61 +46,62 @@ void * pthread_spmd( void * _data ) { lpf_init_t init; lpf_err_t rc = LPF_SUCCESS; - EXPECT_EQ( "%d", pts_rc, 0 ); + EXPECT_EQ( pts_rc, 0 ); rc = lpf_pthread_initialize( (lpf_pid_t)data.s, (lpf_pid_t)data.P, &init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_hook( init, &lpf_spmd, args ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_pthread_finalize( init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); return NULL; } +// the below tests for return code 134 as this is what aborted programs return +// as an error code on modern systems + /** * \test Tests lpf_hook on pthread implementation with NULL input * \pre P <= 1 * \pre P >= 1 * \return Message: NULL input argument while input_size is non-zero - * \return Exit code: 6 + * \return Exit code: 134 */ -TEST( func_lpf_hook_null_input ) +TEST( API, func_lpf_hook_null_input ) { long k = 0; const long P = sysconf( _SC_NPROCESSORS_ONLN ); const int ptc_rc = pthread_key_create( &pid_key, NULL ); - EXPECT_EQ( "%d", ptc_rc, 0 ); + EXPECT_EQ( ptc_rc, 0 ); pthread_t * const threads = (pthread_t*) malloc( P * sizeof(pthread_t) ); - EXPECT_NE( "%p", threads, NULL ); + EXPECT_NE( threads, (pthread_t*)NULL ); struct thread_local_data * const data = (struct thread_local_data*) malloc( P * sizeof(struct thread_local_data) ); - EXPECT_NE( "%p", data, NULL ); + EXPECT_NE( data, (struct thread_local_data*)NULL ); for( k = 0; k < P; ++k ) { data[ k ].P = P; data[ k ].s = k; const int rval = pthread_create( threads + k, NULL, &pthread_spmd, data + k ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } for( k = 0; k < P; ++k ) { const int rval = pthread_join( threads[ k ], NULL ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } const int ptd_rc = pthread_key_delete( pid_key ); - EXPECT_EQ( "%d", ptd_rc, 0 ); - - return 0; + EXPECT_EQ( ptd_rc, 0 ); } diff --git a/tests/functional/debug/func_lpf_debug_hook_null_output.pthread.c b/tests/functional/debug/func_lpf_debug_hook_null_output.pthread.cpp similarity index 80% rename from tests/functional/debug/func_lpf_debug_hook_null_output.pthread.c rename to tests/functional/debug/func_lpf_debug_hook_null_output.pthread.cpp index 02268258..eec3be9a 100644 --- a/tests/functional/debug/func_lpf_debug_hook_null_output.pthread.c +++ b/tests/functional/debug/func_lpf_debug_hook_null_output.pthread.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -32,7 +32,7 @@ void lpf_spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) ctx; (void) pid; (void) nprocs; (void) args; } void * pthread_spmd( void * _data ) { - EXPECT_NE( "%p", _data, NULL ); + EXPECT_NE( _data, (void*)NULL ); const struct thread_local_data data = * ((struct thread_local_data*) _data); const int pts_rc = pthread_setspecific( pid_key, _data ); @@ -46,61 +46,62 @@ void * pthread_spmd( void * _data ) { lpf_init_t init; lpf_err_t rc = LPF_SUCCESS; - EXPECT_EQ( "%d", pts_rc, 0 ); + EXPECT_EQ( pts_rc, 0 ); rc = lpf_pthread_initialize( (lpf_pid_t)data.s, (lpf_pid_t)data.P, &init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_hook( init, &lpf_spmd, args ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_pthread_finalize( init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); return NULL; } +// the below tests for return code 134 as this is what aborted programs return +// as an error code on modern systems + /** * \test Tests lpf_hook on pthread implementation with NULL output * \pre P <= 1 * \pre P >= 1 * \return Message: NULL output argument while output_size is non-zero - * \return Exit code: 6 + * \return Exit code: 134 */ -TEST( func_lpf_hook_null_output ) +TEST( API, func_lpf_hook_null_output ) { long k = 0; const long P = sysconf( _SC_NPROCESSORS_ONLN ); const int ptc_rc = pthread_key_create( &pid_key, NULL ); - EXPECT_EQ( "%d", ptc_rc, 0 ); + EXPECT_EQ( ptc_rc, 0 ); pthread_t * const threads = (pthread_t*) malloc( P * sizeof(pthread_t) ); - EXPECT_NE( "%p", threads, NULL ); + EXPECT_NE( threads, (pthread_t *)NULL ); struct thread_local_data * const data = (struct thread_local_data*) malloc( P * sizeof(struct thread_local_data) ); - EXPECT_NE( "%p", data, NULL ); + EXPECT_NE( data, (struct thread_local_data*)NULL ); for( k = 0; k < P; ++k ) { data[ k ].P = P; data[ k ].s = k; const int rval = pthread_create( threads + k, NULL, &pthread_spmd, data + k ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } for( k = 0; k < P; ++k ) { const int rval = pthread_join( threads[ k ], NULL ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } const int ptd_rc = pthread_key_delete( pid_key ); - EXPECT_EQ( "%d", ptd_rc, 0 ); - - return 0; + EXPECT_EQ( ptd_rc, 0 ); } diff --git a/tests/functional/debug/func_lpf_debug_hook_null_spmd.pthread.c b/tests/functional/debug/func_lpf_debug_hook_null_spmd.pthread.cpp similarity index 78% rename from tests/functional/debug/func_lpf_debug_hook_null_spmd.pthread.c rename to tests/functional/debug/func_lpf_debug_hook_null_spmd.pthread.cpp index 20209c16..00bcc0c7 100644 --- a/tests/functional/debug/func_lpf_debug_hook_null_spmd.pthread.c +++ b/tests/functional/debug/func_lpf_debug_hook_null_spmd.pthread.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -30,7 +30,7 @@ struct thread_local_data { void * pthread_spmd( void * _data ) { - EXPECT_NE( "%p", _data, NULL ); + EXPECT_NE( _data, (void*)NULL ); const struct thread_local_data data = * ((struct thread_local_data*) _data); const int pts_rc = pthread_setspecific( pid_key, _data ); @@ -44,61 +44,62 @@ void * pthread_spmd( void * _data ) { lpf_init_t init; lpf_err_t rc = LPF_SUCCESS; - EXPECT_EQ( "%d", pts_rc, 0 ); + EXPECT_EQ( pts_rc, 0 ); rc = lpf_pthread_initialize( (lpf_pid_t)data.s, (lpf_pid_t)data.P, &init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_hook( init, NULL, args ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_pthread_finalize( init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); return NULL; } +// the below tests for return code 134 as this is what aborted programs return +// as an error code on modern systems + /** * \test Tests lpf_hook on pthread implementation with NULL spmd * \pre P <= 1 * \pre P >= 1 * \return Message: NULL spmd argument - * \return Exit code: 6 + * \return Exit code: 134 */ -TEST( func_lpf_hook_null_spmd ) +TEST( API, func_lpf_hook_null_spmd ) { long k = 0; const long P = sysconf( _SC_NPROCESSORS_ONLN ); const int ptc_rc = pthread_key_create( &pid_key, NULL ); - EXPECT_EQ( "%d", ptc_rc, 0 ); + EXPECT_EQ( ptc_rc, 0 ); pthread_t * const threads = (pthread_t*) malloc( P * sizeof(pthread_t) ); - EXPECT_NE( "%p", threads, NULL ); + EXPECT_NE( threads, (pthread_t*)NULL ); struct thread_local_data * const data = (struct thread_local_data*) malloc( P * sizeof(struct thread_local_data) ); - EXPECT_NE( "%p", data, NULL ); + EXPECT_NE( data, (struct thread_local_data *)NULL ); for( k = 0; k < P; ++k ) { data[ k ].P = P; data[ k ].s = k; const int rval = pthread_create( threads + k, NULL, &pthread_spmd, data + k ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } for( k = 0; k < P; ++k ) { const int rval = pthread_join( threads[ k ], NULL ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } const int ptd_rc = pthread_key_delete( pid_key ); - EXPECT_EQ( "%d", ptd_rc, 0 ); - - return 0; + EXPECT_EQ( ptd_rc, 0 ); } diff --git a/tests/functional/debug/func_lpf_debug_local_register_null_memreg.c b/tests/functional/debug/func_lpf_debug_local_register_null_memreg.cpp similarity index 84% rename from tests/functional/debug/func_lpf_debug_local_register_null_memreg.c rename to tests/functional/debug/func_lpf_debug_local_register_null_memreg.cpp index b4fd8ea1..74638e10 100644 --- a/tests/functional/debug/func_lpf_debug_local_register_null_memreg.c +++ b/tests/functional/debug/func_lpf_debug_local_register_null_memreg.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -33,10 +33,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Invalid local memory registration, which would have taken the 1-th slot, while only space for 0 slots has been reserved * \return Exit code: 6 */ -TEST( func_lpf_debug_local_register_null_memreg ) +TEST( API, func_lpf_debug_local_register_null_memreg ) { - lpf_err_t rc = LPF_SUCCESS; - rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); + FAIL(); } diff --git a/tests/functional/debug/func_lpf_debug_put_after_deregister_dest_after_sync.c b/tests/functional/debug/func_lpf_debug_put_after_deregister_dest.cpp similarity index 73% rename from tests/functional/debug/func_lpf_debug_put_after_deregister_dest_after_sync.c rename to tests/functional/debug/func_lpf_debug_put_after_deregister_dest.cpp index 1374428d..d48877e9 100644 --- a/tests/functional/debug/func_lpf_debug_put_after_deregister_dest_after_sync.c +++ b/tests/functional/debug/func_lpf_debug_put_after_deregister_dest.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,34 +28,29 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -64,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Invalid attempt to deregister a memory slot, because it is in use * \return Exit code: 6 */ -TEST( func_lpf_debug_put_after_deregister_dest_after_sync ) +TEST( API, func_lpf_debug_put_after_deregister_dest ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_after_deregister_dest.c b/tests/functional/debug/func_lpf_debug_put_after_deregister_dest_after_sync.cpp similarity index 74% rename from tests/functional/debug/func_lpf_debug_put_after_deregister_dest.c rename to tests/functional/debug/func_lpf_debug_put_after_deregister_dest_after_sync.cpp index 8862f3ef..e86c3a46 100644 --- a/tests/functional/debug/func_lpf_debug_put_after_deregister_dest.c +++ b/tests/functional/debug/func_lpf_debug_put_after_deregister_dest_after_sync.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,34 +28,29 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -64,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Invalid attempt to deregister a memory slot, because it is in use * \return Exit code: 6 */ -TEST( func_lpf_debug_put_after_deregister_dest ) +TEST( API, func_lpf_debug_put_after_deregister_dest_after_sync ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_after_deregister_source.c b/tests/functional/debug/func_lpf_debug_put_after_deregister_source.cpp similarity index 74% rename from tests/functional/debug/func_lpf_debug_put_after_deregister_source.c rename to tests/functional/debug/func_lpf_debug_put_after_deregister_source.cpp index b6283b00..cf40895c 100644 --- a/tests/functional/debug/func_lpf_debug_put_after_deregister_source.c +++ b/tests/functional/debug/func_lpf_debug_put_after_deregister_source.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,34 +28,29 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -64,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Invalid attempt to deregister a memory slot, because it is in use * \return Exit code: 6 */ -TEST( func_lpf_debug_put_after_deregister_source ) +TEST( API, func_lpf_debug_put_after_deregister_source ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_after_deregister_source_after_sync.c b/tests/functional/debug/func_lpf_debug_put_after_deregister_source_after_sync.cpp similarity index 73% rename from tests/functional/debug/func_lpf_debug_put_after_deregister_source_after_sync.c rename to tests/functional/debug/func_lpf_debug_put_after_deregister_source_after_sync.cpp index bbfd5abc..ae24d981 100644 --- a/tests/functional/debug/func_lpf_debug_put_after_deregister_source_after_sync.c +++ b/tests/functional/debug/func_lpf_debug_put_after_deregister_source_after_sync.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,34 +28,29 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -64,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Invalid attempt to deregister a memory slot, because it is in use * \return Exit code: 6 */ -TEST( func_lpf_debug_put_after_deregister_source_after_sync ) +TEST( API, func_lpf_debug_put_after_deregister_source_after_sync ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_get_too_many_requests.c b/tests/functional/debug/func_lpf_debug_put_get_too_many_requests.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_put_get_too_many_requests.c rename to tests/functional/debug/func_lpf_debug_put_get_too_many_requests.cpp index cba34714..317e8749 100644 --- a/tests/functional/debug/func_lpf_debug_put_get_too_many_requests.c +++ b/tests/functional/debug/func_lpf_debug_put_get_too_many_requests.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,34 +28,31 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+2)%nprocs, xSlot, sizeof(int), ySlot, sizeof(int), sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + FAIL(); } /** @@ -64,10 +61,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: This is the 2-th message, while space for only 1 has been reserved * \return Exit code: 6 */ -TEST( func_lpf_debug_put_get_too_many_requests ) +TEST( API, func_lpf_debug_put_get_too_many_requests ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_get_too_many_requests_remote.c b/tests/functional/debug/func_lpf_debug_put_get_too_many_requests_remote.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_put_get_too_many_requests_remote.c rename to tests/functional/debug/func_lpf_debug_put_get_too_many_requests_remote.cpp index b8c78d74..f3bcc52d 100644 --- a/tests/functional/debug/func_lpf_debug_put_get_too_many_requests_remote.c +++ b/tests/functional/debug/func_lpf_debug_put_get_too_many_requests_remote.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,38 +28,35 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if (pid % 2 == 0) { rc = lpf_put( lpf, xSlot, 0, 0, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } if (pid % 2 == 1 ) { rc = lpf_get( lpf, 0, xSlot, sizeof(int), ySlot, sizeof(int), sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); } /** @@ -68,10 +65,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Too many messages on pid 0. Reserved was 2 while there were actually * \return Exit code: 6 */ -TEST( func_lpf_debug_put_get_too_many_requests_remote ) +TEST( API, func_lpf_debug_put_get_too_many_requests_remote ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_local_dest_slot.c b/tests/functional/debug/func_lpf_debug_put_local_dest_slot.cpp similarity index 76% rename from tests/functional/debug/func_lpf_debug_put_local_dest_slot.c rename to tests/functional/debug/func_lpf_debug_put_local_dest_slot.cpp index 4bca087f..0e25ccfa 100644 --- a/tests/functional/debug/func_lpf_debug_put_local_dest_slot.c +++ b/tests/functional/debug/func_lpf_debug_put_local_dest_slot.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,27 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); } /** @@ -59,10 +56,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: destination memory must be globally registered. Instead, it was only locally registered * \return Exit code: 6 */ -TEST( func_lpf_debug_put_local_dest_slot ) +TEST( API, func_lpf_debug_put_local_dest_slot ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_overflow_dst_offset.c b/tests/functional/debug/func_lpf_debug_put_overflow_dst_offset.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_put_overflow_dst_offset.c rename to tests/functional/debug/func_lpf_debug_put_overflow_dst_offset.cpp index 210e8828..ec6ea4e5 100644 --- a/tests/functional/debug/func_lpf_debug_put_overflow_dst_offset.c +++ b/tests/functional/debug/func_lpf_debug_put_overflow_dst_offset.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,29 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 2, -1, LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); - EXPECT_EQ("%d", 3, y ); } /** @@ -59,10 +58,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: numerical overflow while computing dst_offset * \return Exit code: 6 */ -TEST( func_lpf_debug_put_overflow_dst_offset ) +TEST( API, func_lpf_debug_put_overflow_dst_offset ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_overflow_src_offset.c b/tests/functional/debug/func_lpf_debug_put_overflow_src_offset.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_put_overflow_src_offset.c rename to tests/functional/debug/func_lpf_debug_put_overflow_src_offset.cpp index 58c92f55..7507f417 100644 --- a/tests/functional/debug/func_lpf_debug_put_overflow_src_offset.c +++ b/tests/functional/debug/func_lpf_debug_put_overflow_src_offset.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,27 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 2, (pid+1)%nprocs, ySlot, 0, -1, LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); } /** @@ -59,10 +56,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: numerical overflow while computing src_offset * \return Exit code: 6 */ -TEST( func_lpf_debug_put_overflow_src_offset ) +TEST( API, func_lpf_debug_put_overflow_src_offset ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_read_past_source_memory_global.c b/tests/functional/debug/func_lpf_debug_put_read_past_source_memory_global.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_put_read_past_source_memory_global.c rename to tests/functional/debug/func_lpf_debug_put_read_past_source_memory_global.cpp index ecb33959..9fd15ff2 100644 --- a/tests/functional/debug/func_lpf_debug_put_read_past_source_memory_global.c +++ b/tests/functional/debug/func_lpf_debug_put_read_past_source_memory_global.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 1, (pid+1)%nprocs, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -59,10 +55,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: source memory .* is read past the end by 1 bytes * \return Exit code: 6 */ -TEST( func_lpf_debug_put_read_past_source_memory_global ) +TEST( API, func_lpf_debug_put_read_past_source_memory_global ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_read_past_source_memory_local.c b/tests/functional/debug/func_lpf_debug_put_read_past_source_memory_local.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_put_read_past_source_memory_local.c rename to tests/functional/debug/func_lpf_debug_put_read_past_source_memory_local.cpp index beba4d76..77a124aa 100644 --- a/tests/functional/debug/func_lpf_debug_put_read_past_source_memory_local.c +++ b/tests/functional/debug/func_lpf_debug_put_read_past_source_memory_local.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 2, (pid+1)%nprocs, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -59,10 +55,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: source memory .* is read past the end by 2 bytes * \return Exit code: 6 */ -TEST( func_lpf_debug_put_read_past_source_memory_local ) +TEST( API, func_lpf_debug_put_read_past_source_memory_local ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_read_write_conflict.c b/tests/functional/debug/func_lpf_debug_put_read_write_conflict.cpp similarity index 74% rename from tests/functional/debug/func_lpf_debug_put_read_write_conflict.c rename to tests/functional/debug/func_lpf_debug_put_read_write_conflict.cpp index bbd979fa..d237995e 100644 --- a/tests/functional/debug/func_lpf_debug_put_read_write_conflict.c +++ b/tests/functional/debug/func_lpf_debug_put_read_write_conflict.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,36 +27,30 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, pid%2?&y:&x, sizeof(x), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // ySlot and xSlot are aliases of 'x' // The following put will have a read-write conflict rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_deregister( lpf, xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_deregister( lpf, ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); } /** @@ -65,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Read-write conflict detected * \return Exit code: 6 */ -TEST( func_lpf_debug_put_read_write_conflict ) +TEST( API, func_lpf_debug_put_read_write_conflict ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_read_write_conflict_among_many.c b/tests/functional/debug/func_lpf_debug_put_read_write_conflict_among_many.cpp similarity index 73% rename from tests/functional/debug/func_lpf_debug_put_read_write_conflict_among_many.c rename to tests/functional/debug/func_lpf_debug_put_read_write_conflict_among_many.cpp index 6430757d..d31498b3 100644 --- a/tests/functional/debug/func_lpf_debug_put_read_write_conflict_among_many.c +++ b/tests/functional/debug/func_lpf_debug_put_read_write_conflict_among_many.cpp @@ -17,57 +17,50 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) args; const int N = 10; - int * xs = calloc( N, sizeof(int)); - int * ys = calloc( N, sizeof(int)); + int * xs = new int[N]; + int * ys = new int[N]; lpf_memslot_t xSlot = LPF_INVALID_MEMSLOT; lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, N+2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, xs, sizeof(int)*N, &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, ys, sizeof(int)*N, &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); int i; for ( i = 0; i < N/2; ++i) { rc = lpf_put( lpf, xSlot, sizeof(int)*2*i, (pid+1)%nprocs, ySlot, sizeof(int)*i, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } // this causes a read-write conflict on elements xs[1] and xs[2] rc = lpf_get( lpf, (pid+nprocs-1)%nprocs, ySlot, sizeof(int)*(N-3), xSlot, sizeof(int)+2, sizeof(int)*3, LPF_MSG_DEFAULT ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); - rc = lpf_deregister( lpf, xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_deregister( lpf, ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - free(xs); - free(ys); } /** @@ -76,10 +69,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Read-write conflict detected * \return Exit code: 6 */ -TEST( func_lpf_debug_put_read_write_conflict_among_many ) +TEST( API, func_lpf_debug_put_read_write_conflict_among_many ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } + + diff --git a/tests/functional/debug/func_lpf_debug_put_too_many_requests.c b/tests/functional/debug/func_lpf_debug_put_too_many_requests.cpp similarity index 75% rename from tests/functional/debug/func_lpf_debug_put_too_many_requests.c rename to tests/functional/debug/func_lpf_debug_put_too_many_requests.cpp index aaa5cda4..35570a89 100644 --- a/tests/functional/debug/func_lpf_debug_put_too_many_requests.c +++ b/tests/functional/debug/func_lpf_debug_put_too_many_requests.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,34 +28,29 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, sizeof(int), (pid+2)%nprocs, ySlot, sizeof(int), sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -64,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: This is the 2-th message, while space for only 1 has been reserved * \return Exit code: 6 */ -TEST( func_lpf_debug_put_too_many_requests ) +TEST( API, func_lpf_debug_put_too_many_requests ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_too_many_requests_remote.c b/tests/functional/debug/func_lpf_debug_put_too_many_requests_remote.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_put_too_many_requests_remote.c rename to tests/functional/debug/func_lpf_debug_put_too_many_requests_remote.cpp index ade556d0..d13150d6 100644 --- a/tests/functional/debug/func_lpf_debug_put_too_many_requests_remote.c +++ b/tests/functional/debug/func_lpf_debug_put_too_many_requests_remote.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,38 +28,35 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if (pid % 2 == 0 ) { rc = lpf_put( lpf, xSlot, 0, (pid+1) % 2, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } if (pid % 2 == 1) { rc = lpf_put( lpf, xSlot, sizeof(int), pid % 2, ySlot, sizeof(int), sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); } /** @@ -68,10 +65,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Too many messages on pid 1. Reserved was 1 while there were actually * \return Exit code: 6 */ -TEST( func_lpf_debug_put_too_many_requests_remote ) +TEST( API, func_lpf_debug_put_too_many_requests_remote ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_too_many_requests_self.c b/tests/functional/debug/func_lpf_debug_put_too_many_requests_self.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_put_too_many_requests_self.c rename to tests/functional/debug/func_lpf_debug_put_too_many_requests_self.cpp index 3e6690e1..c482e88c 100644 --- a/tests/functional/debug/func_lpf_debug_put_too_many_requests_self.c +++ b/tests/functional/debug/func_lpf_debug_put_too_many_requests_self.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,31 +28,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, 0, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + FAIL(); } /** @@ -62,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Too many messages on pid 0. Reserved was 1 while there were actually 2 in total * \return Exit code: 6 */ -TEST( func_lpf_debug_put_too_many_requests_self ) +TEST( API, func_lpf_debug_put_too_many_requests_self ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_unknown_dest_pid.c b/tests/functional/debug/func_lpf_debug_put_unknown_dest_pid.cpp similarity index 77% rename from tests/functional/debug/func_lpf_debug_put_unknown_dest_pid.c rename to tests/functional/debug/func_lpf_debug_put_unknown_dest_pid.cpp index 56142f4f..9c78be73 100644 --- a/tests/functional/debug/func_lpf_debug_put_unknown_dest_pid.c +++ b/tests/functional/debug/func_lpf_debug_put_unknown_dest_pid.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,31 +28,32 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, 6, ySlot, 0, sizeof(int), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + FAIL(); - EXPECT_EQ("%d", 3, y[0] ); - EXPECT_EQ("%d", 4, y[1] ); + EXPECT_EQ( 3, y[0] ); + EXPECT_EQ( 4, y[1] ); } /** @@ -62,10 +63,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: unknown process ID 6 for data destination * \return Exit code: 6 */ -TEST( func_lpf_debug_put_unknown_dest_pid ) +TEST( API, func_lpf_debug_put_unknown_dest_pid ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_unknown_dest_slot.c b/tests/functional/debug/func_lpf_debug_put_unknown_dest_slot.cpp similarity index 76% rename from tests/functional/debug/func_lpf_debug_put_unknown_dest_slot.c rename to tests/functional/debug/func_lpf_debug_put_unknown_dest_slot.cpp index 153f1177..d26523c1 100644 --- a/tests/functional/debug/func_lpf_debug_put_unknown_dest_slot.c +++ b/tests/functional/debug/func_lpf_debug_put_unknown_dest_slot.cpp @@ -17,37 +17,35 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) args; int x = 3, y = 6; + (void) y; // this field is (erroneously) not used, and the test checks for + // finding precisely that error lpf_memslot_t xSlot = LPF_INVALID_MEMSLOT; lpf_memslot_t ySlot = xSlot + 2; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -56,10 +54,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: destination memory slot does not exist * \return Exit code: 6 */ -TEST( func_lpf_debug_put_unknown_dest_slot ) +TEST( API, func_lpf_debug_put_unknown_dest_slot ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_unknown_source_slot.c b/tests/functional/debug/func_lpf_debug_put_unknown_source_slot.cpp similarity index 78% rename from tests/functional/debug/func_lpf_debug_put_unknown_source_slot.c rename to tests/functional/debug/func_lpf_debug_put_unknown_source_slot.cpp index 9b274863..deebdcbd 100644 --- a/tests/functional/debug/func_lpf_debug_put_unknown_source_slot.c +++ b/tests/functional/debug/func_lpf_debug_put_unknown_source_slot.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,27 +27,27 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = xSlot + 2; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, ySlot, 0, (pid+1)%nprocs, xSlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ("%d", 3, y ); + EXPECT_EQ( 3, y ); } /** @@ -56,10 +56,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: source memory slot does not exist * \return Exit code: 6 */ -TEST( func_lpf_debug_put_unknown_source_slot ) +TEST(API, func_lpf_debug_put_unknown_source_slot ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_at_sync.c b/tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_at_sync.cpp similarity index 73% rename from tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_at_sync.c rename to tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_at_sync.cpp index 38771cbb..d07059a3 100644 --- a/tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_at_sync.c +++ b/tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_at_sync.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,31 +27,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 3, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - // the write error will be detected at this sync - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -60,10 +55,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: destination memory .* is written past the end by 3 bytes * \return Exit code: 6 */ -TEST( func_lpf_debug_put_write_past_dest_memory_global_known_at_sync ) +TEST( API, func_lpf_debug_put_write_past_dest_memory_global_known_at_sync ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_before_sync.c b/tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_before_sync.cpp similarity index 74% rename from tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_before_sync.c rename to tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_before_sync.cpp index e98cb529..5aad9441 100644 --- a/tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_before_sync.c +++ b/tests/functional/debug/func_lpf_debug_put_write_past_dest_memory_global_known_before_sync.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,30 +27,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xSlot, 0, (pid+1)%nprocs, ySlot, 1, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -59,10 +55,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: destination memory .* is written past the end by 1 bytes * \return Exit code: 6 */ -TEST( func_lpf_debug_put_write_past_dest_memory_global_known_before_sync ) +TEST( API, func_lpf_debug_put_write_past_dest_memory_global_known_before_sync ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_register_global_dst_unsynced.c b/tests/functional/debug/func_lpf_debug_register_global_dst_unsynced.cpp similarity index 76% rename from tests/functional/debug/func_lpf_debug_register_global_dst_unsynced.c rename to tests/functional/debug/func_lpf_debug_register_global_dst_unsynced.cpp index 8a4ec260..93741937 100644 --- a/tests/functional/debug/func_lpf_debug_register_global_dst_unsynced.c +++ b/tests/functional/debug/func_lpf_debug_register_global_dst_unsynced.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,27 +27,23 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, &y, sizeof(x), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, ySlot, 0, (pid+1)%nprocs, xSlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -56,10 +52,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: destination memory slot was not yet active * \return Exit code: 6 */ -TEST( func_lpf_debug_put_unknown_source_slot ) +TEST( API, func_lpf_debug_register_global_dst_unsynced ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_register_global_src_unsynced.c b/tests/functional/debug/func_lpf_debug_register_global_src_unsynced.cpp similarity index 76% rename from tests/functional/debug/func_lpf_debug_register_global_src_unsynced.c rename to tests/functional/debug/func_lpf_debug_register_global_src_unsynced.cpp index 79ddcdff..796bab73 100644 --- a/tests/functional/debug/func_lpf_debug_register_global_src_unsynced.c +++ b/tests/functional/debug/func_lpf_debug_register_global_src_unsynced.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -27,27 +27,23 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, &y, sizeof(x), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_get( lpf, (pid+1)%nprocs, xSlot, 0, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - - EXPECT_EQ("%d", 3, y ); + EXPECT_EQ( LPF_SUCCESS, rc ); + FAIL(); } /** @@ -56,10 +52,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: source memory slot was not yet active * \return Exit code: 6 */ -TEST( func_lpf_debug_put_unknown_source_slot ) +TEST( API, func_lpf_debug_register_global_src_unsynced ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_register_global_unequal.c b/tests/functional/debug/func_lpf_debug_register_global_unequal.cpp similarity index 81% rename from tests/functional/debug/func_lpf_debug_register_global_unequal.c rename to tests/functional/debug/func_lpf_debug_register_global_unequal.cpp index 4efeadef..d5d186c9 100644 --- a/tests/functional/debug/func_lpf_debug_register_global_unequal.c +++ b/tests/functional/debug/func_lpf_debug_register_global_unequal.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -28,24 +28,24 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if (pid != 0) { rc = lpf_register_global( lpf, &y, sizeof(y), &ySlot ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -54,10 +54,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \return Message: Number of global registrations does not match. * \return Exit code: 6 */ -TEST( func_lpf_debug_register_global_unequal ) +TEST( API, func_lpf_debug_register_global_unequal ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_rehook_null_f_symbols.c b/tests/functional/debug/func_lpf_debug_rehook_null_f_symbols.cpp similarity index 89% rename from tests/functional/debug/func_lpf_debug_rehook_null_f_symbols.c rename to tests/functional/debug/func_lpf_debug_rehook_null_f_symbols.cpp index 8ee0e0cb..a958fa37 100644 --- a/tests/functional/debug/func_lpf_debug_rehook_null_f_symbols.c +++ b/tests/functional/debug/func_lpf_debug_rehook_null_f_symbols.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) { @@ -31,7 +31,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) args.f_symbols = NULL; args.f_size = 2; rc = lpf_rehook( lpf, &spmd, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -40,10 +40,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) * \return Message: NULL f_symbols argument while f_size is non-zero * \return Exit code: 6 */ -TEST( func_lpf_debug_rehook_null_f_symbols ) +TEST( API, func_lpf_debug_rehook_null_f_symbols ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_rehook_null_input.c b/tests/functional/debug/func_lpf_debug_rehook_null_input.cpp similarity index 89% rename from tests/functional/debug/func_lpf_debug_rehook_null_input.c rename to tests/functional/debug/func_lpf_debug_rehook_null_input.cpp index ad265bdd..aa800029 100644 --- a/tests/functional/debug/func_lpf_debug_rehook_null_input.c +++ b/tests/functional/debug/func_lpf_debug_rehook_null_input.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) { @@ -31,7 +31,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) args.f_symbols = NULL; args.f_size = 0; rc = lpf_rehook( lpf, &spmd, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -40,10 +40,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) * \return Message: NULL input argument while input_size is non-zero * \return Exit code: 6 */ -TEST( func_lpf_debug_rehook_null_input ) +TEST( API, func_lpf_debug_rehook_null_input ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_rehook_null_output.c b/tests/functional/debug/func_lpf_debug_rehook_null_output.cpp similarity index 89% rename from tests/functional/debug/func_lpf_debug_rehook_null_output.c rename to tests/functional/debug/func_lpf_debug_rehook_null_output.cpp index f809c4d6..504e0fc5 100644 --- a/tests/functional/debug/func_lpf_debug_rehook_null_output.c +++ b/tests/functional/debug/func_lpf_debug_rehook_null_output.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) { @@ -31,7 +31,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) args.f_symbols = NULL; args.f_size = 0; rc = lpf_rehook( lpf, &spmd, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -40,10 +40,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) * \return Message: NULL output argument while output_size is non-zero * \return Exit code: 6 */ -TEST( func_lpf_debug_rehook_null_output ) +TEST( API, func_lpf_debug_rehook_null_output ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_rehook_null_spmd.c b/tests/functional/debug/func_lpf_debug_rehook_null_spmd.cpp similarity index 87% rename from tests/functional/debug/func_lpf_debug_rehook_null_spmd.c rename to tests/functional/debug/func_lpf_debug_rehook_null_spmd.cpp index eafc39b7..d3d00a72 100644 --- a/tests/functional/debug/func_lpf_debug_rehook_null_spmd.c +++ b/tests/functional/debug/func_lpf_debug_rehook_null_spmd.cpp @@ -17,14 +17,14 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) { (void) pid; (void) nprocs; (void) a; lpf_err_t rc = LPF_SUCCESS; rc = lpf_rehook( lpf, NULL, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -33,10 +33,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t a) * \return Message: NULL spmd argument * \return Exit code: 6 */ -TEST( func_lpf_debug_rehook_null_spmd ) +TEST( API, func_lpf_debug_rehook_null_spmd ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/debug/func_lpf_debug_resize_memory_register_with_size_max_minus_three.c b/tests/functional/debug/func_lpf_debug_resize_memory_register_with_size_max_minus_three.cpp similarity index 85% rename from tests/functional/debug/func_lpf_debug_resize_memory_register_with_size_max_minus_three.c rename to tests/functional/debug/func_lpf_debug_resize_memory_register_with_size_max_minus_three.cpp index 05c21b8f..04159041 100644 --- a/tests/functional/debug/func_lpf_debug_resize_memory_register_with_size_max_minus_three.c +++ b/tests/functional/debug/func_lpf_debug_resize_memory_register_with_size_max_minus_three.cpp @@ -17,14 +17,14 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) pid; (void) nprocs; (void) args; lpf_err_t rc = LPF_SUCCESS; rc = lpf_resize_memory_register( lpf, ((size_t) -1) - 3 ); - EXPECT_EQ( "%d", LPF_ERR_OUT_OF_MEMORY , rc ); + EXPECT_EQ( LPF_ERR_OUT_OF_MEMORY , rc ); } /** @@ -32,10 +32,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_debug_resize_memory_register_with_size_max_minus_three ) +TEST( API, func_lpf_debug_resize_memory_register_with_size_max_minus_three ) { lpf_err_t rc = LPF_SUCCESS; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/exception_list b/tests/functional/exception_list deleted file mode 100644 index c7590fc1..00000000 --- a/tests/functional/exception_list +++ /dev/null @@ -1,5 +0,0 @@ -func_lpf_put_parallel_bad_pattern_.* -func_lpf_hook_tcp_mpi..._[^_]*_mvapich2 -func_lpf_hook_tcp_mpi..._[^_]*_openmpi_gcc_64_1_10_7 -func_lpf_hook_tcp_timeout_mpi..._[^_]*_openmpi_gcc_64_1_10_7 -func_lpf_hook_tcp_mpi..._[^_]*_mpich_ge_gcc_64_3_2rc2 diff --git a/tests/functional/func_bsplib_example_lpf_sum.c b/tests/functional/func_bsplib_example_lpf_sum.cpp similarity index 78% rename from tests/functional/func_bsplib_example_lpf_sum.c rename to tests/functional/func_bsplib_example_lpf_sum.cpp index 68677450..91cf356e 100644 --- a/tests/functional/func_bsplib_example_lpf_sum.c +++ b/tests/functional/func_bsplib_example_lpf_sum.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,7 +28,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int i, j; int n = 5; @@ -46,29 +46,27 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) result += xs[j]; rc = bsplib_push_reg(bsplib, &result, sizeof( result ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < p; ++i ) { rc = bsplib_hpget(bsplib, i, &result, 0, &local_sums[i], sizeof( int ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); result = 0; for ( i = 0; i < p; ++i ) result += local_sums[i]; rc = bsplib_pop_reg(bsplib, &result ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", - p * ( n - 1 ) * n / 2 + n * ( p - 1 ) * p / 2, - result ); + EXPECT_EQ( p * ( n - 1 ) * n / 2 + n * ( p - 1 ) * p / 2, result ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -76,10 +74,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_example_bsp_sum) +TEST(API, func_bsplib_example_bsp_sum) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_example_lpf_sum_unsafemode.c b/tests/functional/func_bsplib_example_lpf_sum_unsafemode.cpp similarity index 78% rename from tests/functional/func_bsplib_example_lpf_sum_unsafemode.c rename to tests/functional/func_bsplib_example_lpf_sum_unsafemode.cpp index e81c1576..8e433085 100644 --- a/tests/functional/func_bsplib_example_lpf_sum_unsafemode.c +++ b/tests/functional/func_bsplib_example_lpf_sum_unsafemode.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,7 +28,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 2, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int i, j; int n = 5; @@ -46,29 +46,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) result += xs[j]; rc = bsplib_push_reg(bsplib, &result, sizeof( result ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < p; ++i ) { rc = bsplib_hpget(bsplib, i, &result, 0, &local_sums[i], sizeof( int ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); result = 0; for ( i = 0; i < p; ++i ) result += local_sums[i]; rc = bsplib_pop_reg(bsplib, &result ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", - p * ( n - 1 ) * n / 2 + n * ( p - 1 ) * p / 2, + EXPECT_EQ( p * ( n - 1 ) * n / 2 + n * ( p - 1 ) * p / 2, result ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -76,10 +75,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_example_bsp_sum_unsafemode ) +TEST( API, func_bsplib_example_bsp_sum_unsafemode ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_example_put_array.c b/tests/functional/func_bsplib_example_put_array.cpp similarity index 78% rename from tests/functional/func_bsplib_example_put_array.c rename to tests/functional/func_bsplib_example_put_array.cpp index 3d448091..4d494156 100644 --- a/tests/functional/func_bsplib_example_put_array.c +++ b/tests/functional/func_bsplib_example_put_array.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,7 +27,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int n = 5 * bsplib_nprocs(bsplib); int i, dst_pid, dst_idx, p = bsplib_nprocs(bsplib), n_over_p = n / p; @@ -38,11 +38,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) xs[i] = n - ( i + bsplib_pid(bsplib) * n_over_p ) - 1; } - EXPECT_EQ("%d", 0, n % p ); + EXPECT_EQ( 0, n % p ); rc = bsplib_push_reg(bsplib, xs, n_over_p * sizeof( int ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n_over_p; ++i ) { @@ -51,21 +51,21 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = bsplib_put(bsplib, dst_pid, &xs[i], xs, dst_idx * sizeof( int ), sizeof( int ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg(bsplib, xs ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n_over_p; ++i ) { - EXPECT_EQ("%d", i + (int) bsplib_pid(bsplib) * n_over_p, xs[i] ); + EXPECT_EQ(i + (int) bsplib_pid(bsplib) * n_over_p, xs[i] ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -73,10 +73,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_put_array) +TEST(API, func_bsplib_put_array) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_example_put_array_unsafemode.c b/tests/functional/func_bsplib_example_put_array_unsafemode.cpp similarity index 78% rename from tests/functional/func_bsplib_example_put_array_unsafemode.c rename to tests/functional/func_bsplib_example_put_array_unsafemode.cpp index e4adb988..29e45a3b 100644 --- a/tests/functional/func_bsplib_example_put_array_unsafemode.c +++ b/tests/functional/func_bsplib_example_put_array_unsafemode.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,7 +27,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int n = 5 * bsplib_nprocs(bsplib); int i, dst_pid, dst_idx, p = bsplib_nprocs(bsplib), n_over_p = n / p; @@ -38,11 +38,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) xs[i] = n - ( i + bsplib_pid(bsplib) * n_over_p ) - 1; } - EXPECT_EQ("%d", 0, n % p ); + EXPECT_EQ( 0, n % p ); rc = bsplib_push_reg(bsplib, xs, n_over_p * sizeof( int ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n_over_p; ++i ) { @@ -51,21 +51,21 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = bsplib_put(bsplib, dst_pid, &xs[i], xs, dst_idx * sizeof( int ), sizeof( int ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg(bsplib, xs ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n_over_p; ++i ) { - EXPECT_EQ("%d", i + (int) bsplib_pid(bsplib) * n_over_p, xs[i] ); + EXPECT_EQ( i + (int) bsplib_pid(bsplib) * n_over_p, xs[i] ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -73,10 +73,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_put_array_unsafemode ) +TEST( API, func_bsplib_put_array_unsafemode ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_example_reverse.c b/tests/functional/func_bsplib_example_reverse.cpp similarity index 73% rename from tests/functional/func_bsplib_example_reverse.c rename to tests/functional/func_bsplib_example_reverse.cpp index d170bccf..eb155f1f 100644 --- a/tests/functional/func_bsplib_example_reverse.c +++ b/tests/functional/func_bsplib_example_reverse.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,31 +27,31 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); lpf_pid_t x = bsplib_pid(bsplib); rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put(bsplib, bsplib_nprocs(bsplib) - bsplib_pid(bsplib) - 1, &x, &x, 0, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%u", bsplib_pid(bsplib), x ); + EXPECT_EQ( bsplib_pid(bsplib), x ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg(bsplib, &x ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%u", bsplib_nprocs(bsplib) - bsplib_pid(bsplib) - 1, x ); + EXPECT_EQ( bsplib_nprocs(bsplib) - bsplib_pid(bsplib) - 1, x ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -59,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_exampl_reverse ) +TEST(API, func_bsplib_exampl_reverse ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_example_reverse_unsafemode.c b/tests/functional/func_bsplib_example_reverse_unsafemode.cpp similarity index 73% rename from tests/functional/func_bsplib_example_reverse_unsafemode.c rename to tests/functional/func_bsplib_example_reverse_unsafemode.cpp index 09d338b8..a33d5ae1 100644 --- a/tests/functional/func_bsplib_example_reverse_unsafemode.c +++ b/tests/functional/func_bsplib_example_reverse_unsafemode.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,31 +27,31 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); lpf_pid_t x = bsplib_pid(bsplib); rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put(bsplib, bsplib_nprocs(bsplib) - bsplib_pid(bsplib) - 1, &x, &x, 0, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%u", bsplib_pid(bsplib), x ); + EXPECT_EQ( bsplib_pid(bsplib), x ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg(bsplib, &x ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%u", bsplib_nprocs(bsplib) - bsplib_pid(bsplib) - 1, x ); + EXPECT_EQ( bsplib_nprocs(bsplib) - bsplib_pid(bsplib) - 1, x ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -59,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_exampl_reverse_unsafemode ) +TEST(API, func_bsplib_exampl_reverse_unsafemode ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_get_exceptions.c b/tests/functional/func_bsplib_get_exceptions.cpp similarity index 74% rename from tests/functional/func_bsplib_get_exceptions.c rename to tests/functional/func_bsplib_get_exceptions.cpp index 4fa597e8..89779139 100644 --- a/tests/functional/func_bsplib_get_exceptions.c +++ b/tests/functional/func_bsplib_get_exceptions.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,33 +27,33 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char a = 'a'; char b = 'b'; rc = bsplib_push_reg( bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_get( bsplib, bsplib_nprocs( bsplib ) + 1, &a, 0, &b, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_ERR_PID_OUT_OF_RANGE, rc ); + EXPECT_EQ( BSPLIB_ERR_PID_OUT_OF_RANGE, rc ); rc = bsplib_get( bsplib, -1, &a, 0, &b, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_ERR_PID_OUT_OF_RANGE, rc ); + EXPECT_EQ( BSPLIB_ERR_PID_OUT_OF_RANGE, rc ); rc = bsplib_get( bsplib, 0, &a, 1, &b, sizeof(a) ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); rc = bsplib_get( bsplib, 0, &a, 0, &b, 2*sizeof(a) ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -61,10 +61,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_get_exceptions ) +TEST(API, func_bsplib_get_exceptions ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_get_normal.c b/tests/functional/func_bsplib_get_normal.cpp similarity index 79% rename from tests/functional/func_bsplib_get_normal.c rename to tests/functional/func_bsplib_get_normal.cpp index 71299665..c08b3a3f 100644 --- a/tests/functional/func_bsplib_get_normal.c +++ b/tests/functional/func_bsplib_get_normal.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,7 +27,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 1, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int i; int p = bsplib_nprocs(bsplib); @@ -41,9 +41,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = bsplib_push_reg(bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < p; ++i ) { @@ -53,21 +53,21 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = bsplib_get(bsplib, srcPid, a, srcOffset * sizeof( a[0] ), b + i, sizeof( a[0] ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_pop_reg(bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < p; ++i ) { - EXPECT_EQ( "%d", i * i, b[i] ); + EXPECT_EQ( i * i, b[i] ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -75,10 +75,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_get_normal) +TEST(API, func_bsplib_get_normal) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_get_normal_unsafemode.c b/tests/functional/func_bsplib_get_normal_unsafemode.cpp similarity index 79% rename from tests/functional/func_bsplib_get_normal_unsafemode.c rename to tests/functional/func_bsplib_get_normal_unsafemode.cpp index e7377df1..7a214d07 100644 --- a/tests/functional/func_bsplib_get_normal_unsafemode.c +++ b/tests/functional/func_bsplib_get_normal_unsafemode.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,7 +27,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int i; int p = bsplib_nprocs(bsplib); @@ -41,9 +41,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = bsplib_push_reg(bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < p; ++i ) { @@ -53,21 +53,21 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = bsplib_get(bsplib, srcPid, a, srcOffset * sizeof( a[0] ), b + i, sizeof( a[0] ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_pop_reg(bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < p; ++i ) { - EXPECT_EQ( "%d", i * i, b[i] ); + EXPECT_EQ( i * i, b[i] ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -75,10 +75,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_get_normal_unsafemode ) +TEST( API, func_bsplib_get_normal_unsafemode ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_get_twice_on_same_remote.c b/tests/functional/func_bsplib_get_twice_on_same_remote.cpp similarity index 66% rename from tests/functional/func_bsplib_get_twice_on_same_remote.c rename to tests/functional/func_bsplib_get_twice_on_same_remote.cpp index d57efaa3..229ce1de 100644 --- a/tests/functional/func_bsplib_get_twice_on_same_remote.c +++ b/tests/functional/func_bsplib_get_twice_on_same_remote.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -29,7 +29,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char x = 'x'; @@ -37,30 +37,30 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) char z = 'z'; rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg(bsplib, &y, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if ( bsplib_pid(bsplib) == 0 ) rc = bsplib_get(bsplib, 1, &x, 0, &y, sizeof( x ) ); else if ( bsplib_pid(bsplib) == 1 ) rc = bsplib_get(bsplib, 0, &y, 0, &z, sizeof( y ) ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 0 ? 'x' : 'y', y ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 1 ? 'y' : 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 'x' : 'y', y ); + EXPECT_EQ( bsplib_pid(bsplib) == 1 ? 'y' : 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // redo the previous but now the order of pid 0 and 1 reversed @@ -69,30 +69,30 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) z = 'z'; rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg(bsplib, &y, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if ( bsplib_pid(bsplib) == 1 ) rc = bsplib_get(bsplib, 0, &x, 0, &y, sizeof( x ) ); else if ( bsplib_pid(bsplib) == 0 ) rc = bsplib_get(bsplib, 1, &y, 0, &z, sizeof( y ) ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 1 ? 'x' : 'y', y ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 0 ? 'y' : 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( bsplib_pid(bsplib) == 1 ? 'x' : 'y', y ); + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 'y' : 'z', z ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -100,10 +100,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_get_twice_on_same_remote ) +TEST(API, func_bsplib_get_twice_on_same_remote ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_get_twice_on_same_remote_unsafemode.c b/tests/functional/func_bsplib_get_twice_on_same_remote_unsafemode.cpp similarity index 66% rename from tests/functional/func_bsplib_get_twice_on_same_remote_unsafemode.c rename to tests/functional/func_bsplib_get_twice_on_same_remote_unsafemode.cpp index 0553d7f7..f7b1ea83 100644 --- a/tests/functional/func_bsplib_get_twice_on_same_remote_unsafemode.c +++ b/tests/functional/func_bsplib_get_twice_on_same_remote_unsafemode.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -29,7 +29,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char x = 'x'; @@ -37,30 +37,30 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) char z = 'z'; rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg(bsplib, &y, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if ( bsplib_pid(bsplib) == 0 ) rc = bsplib_get(bsplib, 1, &x, 0, &y, sizeof( x ) ); else if ( bsplib_pid(bsplib) == 1 ) rc = bsplib_get(bsplib, 0, &y, 0, &z, sizeof( y ) ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 0 ? 'x' : 'y', y ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 1 ? 'y' : 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 'x' : 'y', y ); + EXPECT_EQ( bsplib_pid(bsplib) == 1 ? 'y' : 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // redo the previous but now the order of pid 0 and 1 reversed @@ -69,30 +69,30 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) z = 'z'; rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg(bsplib, &y, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if ( bsplib_pid(bsplib) == 1 ) rc = bsplib_get(bsplib, 0, &x, 0, &y, sizeof( x ) ); else if ( bsplib_pid(bsplib) == 0 ) rc = bsplib_get(bsplib, 1, &y, 0, &z, sizeof( y ) ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 1 ? 'x' : 'y', y ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 0 ? 'y' : 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( bsplib_pid(bsplib) == 1 ? 'x' : 'y', y ); + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 'y' : 'z', z ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -100,10 +100,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_get_twice_on_same_remote_unsafemode ) +TEST( API, func_bsplib_get_twice_on_same_remote_unsafemode ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_getput_same_dest.c b/tests/functional/func_bsplib_getput_same_dest.cpp similarity index 69% rename from tests/functional/func_bsplib_getput_same_dest.c rename to tests/functional/func_bsplib_getput_same_dest.cpp index d4915613..d48e1054 100644 --- a/tests/functional/func_bsplib_getput_same_dest.c +++ b/tests/functional/func_bsplib_getput_same_dest.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,37 +27,37 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 2, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char x = 'x'; char y = 'y'; char z = 'z'; rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg(bsplib, &z, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_get(bsplib, 0, &x, 0, &z, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put(bsplib, 0, &y, &z, 0, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 0 ? 'y' : 'x', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 'y' : 'x', z ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -65,10 +65,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_getput_same_dest ) +TEST( API, func_bsplib_getput_same_dest ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_getput_same_dest_unsafemode.c b/tests/functional/func_bsplib_getput_same_dest_unsafemode.cpp similarity index 68% rename from tests/functional/func_bsplib_getput_same_dest_unsafemode.c rename to tests/functional/func_bsplib_getput_same_dest_unsafemode.cpp index 05a62af2..01bd5e20 100644 --- a/tests/functional/func_bsplib_getput_same_dest_unsafemode.c +++ b/tests/functional/func_bsplib_getput_same_dest_unsafemode.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,37 +27,37 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char x = 'x'; char y = 'y'; char z = 'z'; rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg(bsplib, &z, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_get(bsplib, 0, &x, 0, &z, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put(bsplib, 0, &y, &z, 0, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 0 ? 'y' : 'x', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 'y' : 'x', z ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -65,10 +65,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_getput_same_dest_unsafemode ) +TEST( API, func_bsplib_getput_same_dest_unsafemode ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_getput_same_remote.c b/tests/functional/func_bsplib_getput_same_remote.cpp similarity index 69% rename from tests/functional/func_bsplib_getput_same_remote.c rename to tests/functional/func_bsplib_getput_same_remote.cpp index 8c796925..416bc2c5 100644 --- a/tests/functional/func_bsplib_getput_same_remote.c +++ b/tests/functional/func_bsplib_getput_same_remote.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,35 +27,35 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, -1, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char x = 'x'; char y = 'y'; char z = 'z'; rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_get(bsplib, 0, &x, 0, &z, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put(bsplib, 0, &z, &x, 0, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 0 ? 'z' : 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'x', z ); + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 'z' : 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'x', z ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -63,10 +63,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_getput_same_remote ) +TEST( API, func_bsplib_getput_same_remote ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_getput_same_remote_unsafemode.c b/tests/functional/func_bsplib_getput_same_remote_unsafemode.cpp similarity index 69% rename from tests/functional/func_bsplib_getput_same_remote_unsafemode.c rename to tests/functional/func_bsplib_getput_same_remote_unsafemode.cpp index fb8eb18e..8b8f9a2e 100644 --- a/tests/functional/func_bsplib_getput_same_remote_unsafemode.c +++ b/tests/functional/func_bsplib_getput_same_remote_unsafemode.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,35 +27,35 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char x = 'x'; char y = 'y'; char z = 'z'; rc = bsplib_push_reg(bsplib, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_get(bsplib, 0, &x, 0, &z, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put(bsplib, 0, &z, &x, 0, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'z', z ); + EXPECT_EQ( 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'z', z ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", bsplib_pid(bsplib) == 0 ? 'z' : 'x', x ); - EXPECT_EQ( "%c", 'y', y ); - EXPECT_EQ( "%c", 'x', z ); + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 'z' : 'x', x ); + EXPECT_EQ( 'y', y ); + EXPECT_EQ( 'x', z ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -63,10 +63,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_getput_same_remote_unsafemode ) +TEST( API, func_bsplib_getput_same_remote_unsafemode ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_getput_zero_bytes.c b/tests/functional/func_bsplib_getput_zero_bytes.cpp similarity index 72% rename from tests/functional/func_bsplib_getput_zero_bytes.c rename to tests/functional/func_bsplib_getput_zero_bytes.cpp index 4403462c..7297fd81 100644 --- a/tests/functional/func_bsplib_getput_zero_bytes.c +++ b/tests/functional/func_bsplib_getput_zero_bytes.cpp @@ -16,7 +16,8 @@ */ #include -#include "Test.h" + +#include "gtest/gtest.h" #include @@ -28,7 +29,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 3, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char x = 'x'; char y = 'y'; @@ -40,44 +41,44 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // the following puts and gets are no-ops, despite some // other illegal arguments, because they all write zero bytes rc = bsplib_put(bsplib, 0, &y, NULL, 10, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put(bsplib, 0, &y, &x, -5, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put(bsplib, 0, &y, &y, 0, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put(bsplib, 0, &y, &x, sizeof(x)+1, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_hpput(bsplib, 0, &y, NULL, 10, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_hpput(bsplib, 0, &y, &x, -5, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_hpput(bsplib, 0, &y, &y, 0, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_hpput(bsplib, 0, &y, &x, sizeof(x)+1, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_get(bsplib, 0, NULL, 10, &y, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_get(bsplib, 0, &x, -5, &y, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_get(bsplib, 0, &y, 0, &y, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_get(bsplib, 0, &x, sizeof(x)+1, &y, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_hpget(bsplib, 0, NULL, 10, &y, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_hpget(bsplib, 0, &x, -5, &y, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_hpget(bsplib, 0, &y, 0, &y, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_hpget(bsplib, 0, &x, sizeof(x)+1, &y, zero_bytes); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -85,10 +86,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_getput_zero_bytes ) +TEST( API, func_bsplib_getput_zero_bytes ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_hpget_many.c b/tests/functional/func_bsplib_hpget_many.cpp similarity index 75% rename from tests/functional/func_bsplib_hpget_many.c rename to tests/functional/func_bsplib_hpget_many.cpp index d46bb231..3b387bd0 100644 --- a/tests/functional/func_bsplib_hpget_many.c +++ b/tests/functional/func_bsplib_hpget_many.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -29,16 +29,16 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int i, j; - const int m = 1000; + const int m = 100; const int n = m*(m+1)/2; - uint32_t * memory = malloc( 2 + n *sizeof(uint32_t) ); + uint32_t * memory = (uint32_t *) malloc( 2 + n *sizeof(uint32_t) ); uint32_t *array = memory + 2; uint32_t value[m]; rc = bsplib_push_reg(bsplib, value, sizeof(value)); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { @@ -51,7 +51,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for (i = 1, j=0; i <= m; j += i, ++i) { @@ -59,33 +59,33 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) ( bsplib_pid(bsplib) + 1 ) % bsplib_nprocs(bsplib), value, 0, array + j, i*sizeof( uint32_t ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_pop_reg(bsplib, value ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { if ( i < 2) { - EXPECT_EQ( "%u", 0xAAAAAAAAu, memory[i] ); + EXPECT_EQ( 0xAAAAAAAAu, memory[i] ); } else { - EXPECT_EQ( "%u", 0x12345678u, memory[i] ); + EXPECT_EQ( 0x12345678u, memory[i] ); } } for ( i = 0; i < m; ++i ) { - EXPECT_EQ( "%u", 0x12345678u, value[i] ); + EXPECT_EQ( 0x12345678u, value[i] ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); free(memory); } @@ -95,10 +95,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_hpget_many) +TEST(API, func_bsplib_hpget_many) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_hpput_many.c b/tests/functional/func_bsplib_hpput_many.cpp similarity index 75% rename from tests/functional/func_bsplib_hpput_many.c rename to tests/functional/func_bsplib_hpput_many.cpp index 8c92a5ec..8284178a 100644 --- a/tests/functional/func_bsplib_hpput_many.c +++ b/tests/functional/func_bsplib_hpput_many.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -29,15 +29,15 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 10, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int i, j; - const int m = 1000; + const int m = 100; const int n = m*(m+1)/2; - uint32_t * memory = malloc( 2 + n *sizeof(uint32_t) ); + uint32_t * memory = (uint32_t *) malloc( 2 + n *sizeof(uint32_t) ); uint32_t *array = memory + 2; rc = bsplib_push_reg(bsplib, array, n*sizeof(uint32_t)); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { @@ -51,7 +51,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for (i = 1, j=0; i <= m; j += i, ++i) { @@ -59,33 +59,33 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) ( bsplib_pid(bsplib) + 1 ) % bsplib_nprocs(bsplib), value, array, j*sizeof(uint32_t), i*sizeof( uint32_t ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_pop_reg(bsplib, array ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { if ( i < 2) { - EXPECT_EQ( "%u", 0xAAAAAAAAu, memory[i] ); + EXPECT_EQ( 0xAAAAAAAAu, memory[i] ); } else { - EXPECT_EQ( "%u", 0x12345678u, memory[i] ); + EXPECT_EQ( 0x12345678u, memory[i] ); } } for ( i = 0; i < m; ++i ) { - EXPECT_EQ( "%u", 0x12345678u, value[i] ); + EXPECT_EQ( 0x12345678u, value[i] ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); free(memory); } @@ -95,10 +95,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_hpput_many) +TEST( API, func_bsplib_hpput_many) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_hpsend_many.c b/tests/functional/func_bsplib_hpsend_many.cpp similarity index 76% rename from tests/functional/func_bsplib_hpsend_many.c rename to tests/functional/func_bsplib_hpsend_many.cpp index fc1f5089..d531eea8 100644 --- a/tests/functional/func_bsplib_hpsend_many.c +++ b/tests/functional/func_bsplib_hpsend_many.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -33,24 +33,22 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const int pthread = 1, mpirma = 2, mpimsg = 3, hybrid = 4, ibverbs=5; (void) pthread; (void) mpirma; (void) mpimsg; (void) hybrid; (void) ibverbs; - LPFLIB_IGNORE_TAUTOLOGIES if (LPF_CORE_IMPL_ID == mpirma ) { maxhpregs = 10; // because MPI RMA only supports a limited number // of memory registrations } - LPFLIB_RESTORE_WARNINGS rc = bsplib_create( lpf, pid, nprocs, 1, maxhpregs, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int i, j; size_t size; - const int m = 1000; + const int m = 100; const int n = m*(m+1)/2; - uint32_t * memory = malloc( 2 + n *sizeof(uint32_t) ); + uint32_t * memory = (uint32_t *) malloc( 2 + n *sizeof(uint32_t) ); uint32_t *array = memory + 2; - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { @@ -64,55 +62,55 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } size = bsplib_set_tagsize( bsplib, sizeof(j)); - EXPECT_EQ( "%zu", (size_t) 0, size); + EXPECT_EQ( (size_t) 0, size); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for (i = 1, j=0; i <= m; j += i, ++i) { rc = bsplib_hpsend(bsplib, ( bsplib_pid(bsplib) + 1 ) % bsplib_nprocs(bsplib), &j, value, i*sizeof( uint32_t ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); const void * tag, *payload; for ( i = 1; i <= m; ++i) { size = bsplib_hpmove( bsplib, &tag, &payload); - EXPECT_NE("%zu", (size_t) -1, size ); + EXPECT_NE( (size_t) -1, size ); memcpy( &j, tag, sizeof(j)); double size_approx = (1 + sqrt(1 + 8*j))/2; size_t k = (size_t) (size_approx + 0.5*(1.0 - 1e-15)); - EXPECT_EQ("%zu", k*sizeof(uint32_t), size ); + EXPECT_EQ( k*sizeof(uint32_t), size ); memcpy( array + j, payload, sizeof(uint32_t)*k); } size =bsplib_hpmove( bsplib, &tag, &payload); - EXPECT_EQ( "%zu", (size_t) -1, size ); + EXPECT_EQ( (size_t) -1, size ); for ( i = 0; i < n; ++i ) { if ( i < 2) { - EXPECT_EQ( "%u", 0xAAAAAAAAu, memory[i] ); + EXPECT_EQ( 0xAAAAAAAAu, memory[i] ); } else { - EXPECT_EQ( "%u", 0x12345678u, memory[i] ); + EXPECT_EQ( 0x12345678u, memory[i] ); } } for ( i = 0; i < m; ++i ) { - EXPECT_EQ( "%u", 0x12345678u, value[i] ); + EXPECT_EQ( 0x12345678u, value[i] ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); free(memory); } @@ -122,10 +120,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_hpsend_many) +TEST( API, func_bsplib_hpsend_many) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_nprocs.c b/tests/functional/func_bsplib_nprocs.cpp similarity index 83% rename from tests/functional/func_bsplib_nprocs.c rename to tests/functional/func_bsplib_nprocs.cpp index 441123ee..ceca6c66 100644 --- a/tests/functional/func_bsplib_nprocs.c +++ b/tests/functional/func_bsplib_nprocs.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,13 +27,13 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 10, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); lpf_pid_t nprocs2 = bsplib_nprocs( bsplib ); - EXPECT_EQ( "%u", nprocs, nprocs2); + EXPECT_EQ( nprocs, nprocs2); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -41,10 +41,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_nprocs ) +TEST(API, func_bsplib_nprocs ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pid.c b/tests/functional/func_bsplib_pid.cpp similarity index 84% rename from tests/functional/func_bsplib_pid.c rename to tests/functional/func_bsplib_pid.cpp index c4b40958..ae9a0617 100644 --- a/tests/functional/func_bsplib_pid.c +++ b/tests/functional/func_bsplib_pid.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,13 +27,13 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); lpf_pid_t pid2 = bsplib_pid( bsplib ); - EXPECT_EQ( "%u", pid, pid2); + EXPECT_EQ( pid, pid2); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -41,10 +41,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pid ) +TEST( API, func_bsplib_pid ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_ambiguous.c b/tests/functional/func_bsplib_pushpopreg_ambiguous.cpp similarity index 77% rename from tests/functional/func_bsplib_pushpopreg_ambiguous.c rename to tests/functional/func_bsplib_pushpopreg_ambiguous.cpp index fc1c44f6..5c51bea5 100644 --- a/tests/functional/func_bsplib_pushpopreg_ambiguous.c +++ b/tests/functional/func_bsplib_pushpopreg_ambiguous.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,7 +27,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // This example is a variation of an example in @@ -35,27 +35,27 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) int a, b; rc = bsplib_push_reg(bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if ( bsplib_pid(bsplib) == 0 ) { rc = bsplib_push_reg(bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } else { rc = bsplib_push_reg(bsplib, &b, sizeof( b ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg(bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_ERR_POPREG_MISMATCH, rc ); + EXPECT_EQ( BSPLIB_ERR_POPREG_MISMATCH, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -63,10 +63,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_ambiguous ) +TEST( API, func_bsplib_pushpopreg_ambiguous ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_different_variables.c b/tests/functional/func_bsplib_pushpopreg_different_variables.cpp similarity index 76% rename from tests/functional/func_bsplib_pushpopreg_different_variables.c rename to tests/functional/func_bsplib_pushpopreg_different_variables.cpp index 086ceac7..684b444f 100644 --- a/tests/functional/func_bsplib_pushpopreg_different_variables.c +++ b/tests/functional/func_bsplib_pushpopreg_different_variables.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,32 +27,32 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 10, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // This example comes from the BSPlib paper (Hill et al. 1998) int a, b; rc = bsplib_push_reg(bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg(bsplib, &b, sizeof( b ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if ( bsplib_pid(bsplib) == 0 ) { rc = bsplib_pop_reg(bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } else { rc = bsplib_pop_reg(bsplib, &b ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_ERR_POPREG_MISMATCH, rc ); + EXPECT_EQ( BSPLIB_ERR_POPREG_MISMATCH, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -60,10 +60,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_different_variables) +TEST( API, func_bsplib_pushpopreg_different_variables) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_exceptions.c b/tests/functional/func_bsplib_pushpopreg_exceptions.cpp similarity index 73% rename from tests/functional/func_bsplib_pushpopreg_exceptions.c rename to tests/functional/func_bsplib_pushpopreg_exceptions.cpp index 16b469cb..97f63398 100644 --- a/tests/functional/func_bsplib_pushpopreg_exceptions.c +++ b/tests/functional/func_bsplib_pushpopreg_exceptions.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,38 +27,38 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, (size_t) -1, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int a; // Use of variable without definition rc = bsplib_put( bsplib, 0, &a, &a, 0, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_NOT_REGISTERED, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_NOT_REGISTERED, rc ); // Tests use of put directly after registration before sync rc = bsplib_push_reg( bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put( bsplib, 0, &a, &a, 0, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_NOT_REGISTERED, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_NOT_REGISTERED, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put( bsplib, 0, &a, &a, 0, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // Tests detection of NULL ptr rc = bsplib_push_reg( bsplib, NULL, 1); - EXPECT_EQ( "%d", BSPLIB_ERR_NULL_POINTER, rc ); + EXPECT_EQ( BSPLIB_ERR_NULL_POINTER, rc ); // Tests deregistration of non-existent registration rc = bsplib_pop_reg( bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_NOT_REGISTERED, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_NOT_REGISTERED, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -66,10 +66,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_exception ) +TEST( API, func_bsplib_pushpopreg_exception ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_many_same.c b/tests/functional/func_bsplib_pushpopreg_many_same.cpp similarity index 79% rename from tests/functional/func_bsplib_pushpopreg_many_same.c rename to tests/functional/func_bsplib_pushpopreg_many_same.cpp index d478cd4a..5f47e5b8 100644 --- a/tests/functional/func_bsplib_pushpopreg_many_same.c +++ b/tests/functional/func_bsplib_pushpopreg_many_same.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -36,11 +36,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) while (1) { rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { rc = bsplib_push_reg( bsplib, a, i ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync( bsplib ); @@ -53,7 +53,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { // reinitialize BSPlib rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // reduce number of registers n /= 2; @@ -63,21 +63,21 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) break; } } - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { rc = bsplib_pop_reg( bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_pop_reg( bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_NOT_REGISTERED, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_NOT_REGISTERED, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -85,10 +85,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_many_same) +TEST( API, func_bsplib_pushpopreg_many_same) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_normal.c b/tests/functional/func_bsplib_pushpopreg_normal.cpp similarity index 68% rename from tests/functional/func_bsplib_pushpopreg_normal.c rename to tests/functional/func_bsplib_pushpopreg_normal.cpp index 905b5c79..778a8a58 100644 --- a/tests/functional/func_bsplib_pushpopreg_normal.c +++ b/tests/functional/func_bsplib_pushpopreg_normal.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,41 +27,41 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int a = 0; int c = -1; rc = bsplib_push_reg( bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg( bsplib, &c, sizeof( c ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int b = 2; rc = bsplib_put( bsplib, 0, &b, &a, 0, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", 0, a ); - EXPECT_EQ( "%d", 2, b ); - EXPECT_EQ( "%d", -1, c ); + EXPECT_EQ( 0, a ); + EXPECT_EQ( 2, b ); + EXPECT_EQ( -1, c ); rc = bsplib_pop_reg( bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, &c ); // non-stack order! - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", bsplib_pid( bsplib ) == 0 ? 2 : 0, a ); - EXPECT_EQ( "%d", 2, b ); - EXPECT_EQ( "%d", -1, c ); + EXPECT_EQ( bsplib_pid( bsplib ) == 0 ? 2 : 0, a ); + EXPECT_EQ( 2, b ); + EXPECT_EQ( -1, c ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -69,10 +69,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_normal ) +TEST( API, func_bsplib_pushpopreg_normal ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_normal_unsafemode.c b/tests/functional/func_bsplib_pushpopreg_normal_unsafemode.cpp similarity index 68% rename from tests/functional/func_bsplib_pushpopreg_normal_unsafemode.c rename to tests/functional/func_bsplib_pushpopreg_normal_unsafemode.cpp index 8ffac504..f55b6df4 100644 --- a/tests/functional/func_bsplib_pushpopreg_normal_unsafemode.c +++ b/tests/functional/func_bsplib_pushpopreg_normal_unsafemode.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,41 +27,41 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int a = 0; int c = -1; rc = bsplib_push_reg( bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg( bsplib, &c, sizeof( c ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int b = 2; rc = bsplib_put( bsplib, 0, &b, &a, 0, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", 0, a ); - EXPECT_EQ( "%d", 2, b ); - EXPECT_EQ( "%d", -1, c ); + EXPECT_EQ( 0, a ); + EXPECT_EQ( 2, b ); + EXPECT_EQ( -1, c ); rc = bsplib_pop_reg( bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, &c ); // non-stack order! - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", bsplib_pid( bsplib ) == 0 ? 2 : 0, a ); - EXPECT_EQ( "%d", 2, b ); - EXPECT_EQ( "%d", -1, c ); + EXPECT_EQ( bsplib_pid( bsplib ) == 0 ? 2 : 0, a ); + EXPECT_EQ( 2, b ); + EXPECT_EQ( -1, c ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -69,10 +69,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_normal_unsafemode ) +TEST( API, func_bsplib_pushpopreg_normal_unsafemode ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_null.c b/tests/functional/func_bsplib_pushpopreg_null.cpp similarity index 67% rename from tests/functional/func_bsplib_pushpopreg_null.c rename to tests/functional/func_bsplib_pushpopreg_null.cpp index 51370136..4191225d 100644 --- a/tests/functional/func_bsplib_pushpopreg_null.c +++ b/tests/functional/func_bsplib_pushpopreg_null.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,38 +27,38 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // register NULL once rc = bsplib_push_reg( bsplib, NULL, 0 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, NULL ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // register NULL twice rc = bsplib_push_reg( bsplib, NULL, 0 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg( bsplib, NULL, 0 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, NULL ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, NULL ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // use of NULL with comm primitives @@ -67,41 +67,41 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) char *p = bsplib_pid(bsplib) == 0 ? &x : NULL; rc = bsplib_push_reg(bsplib, p, bsplib_pid(bsplib) == 0 ? 1 : 0 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if ( bsplib_pid(bsplib) == 1 ) { rc = bsplib_put(bsplib, 0, &y, p, 0, 1 ); - EXPECT_EQ( "%d", BSPLIB_ERR_NULL_POINTER , rc ); + EXPECT_EQ( BSPLIB_ERR_NULL_POINTER , rc ); rc = bsplib_hpput(bsplib, 0, &y, p, 0, 1 ); - EXPECT_EQ( "%d", BSPLIB_ERR_NULL_POINTER , rc ); + EXPECT_EQ( BSPLIB_ERR_NULL_POINTER , rc ); rc = bsplib_get(bsplib, 0, p, 0, &y, 1 ); - EXPECT_EQ( "%d", BSPLIB_ERR_NULL_POINTER , rc ); + EXPECT_EQ( BSPLIB_ERR_NULL_POINTER , rc ); rc = bsplib_hpget(bsplib, 0, p, 0, &y, 1 ); - EXPECT_EQ( "%d", BSPLIB_ERR_NULL_POINTER , rc ); + EXPECT_EQ( BSPLIB_ERR_NULL_POINTER , rc ); } if ( bsplib_pid(bsplib) == 0 ) { - EXPECT_EQ( "%c", 'x', *p ); + EXPECT_EQ( 'x', *p ); rc = bsplib_put(bsplib, 0, &y, p, 0, 1 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if ( bsplib_pid(bsplib) == 0 ) { - EXPECT_EQ( "%c", 'y', *p ); + EXPECT_EQ( 'y', *p ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -109,10 +109,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_null ) +TEST( API, func_bsplib_pushpopreg_null ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_pop_before_put.c b/tests/functional/func_bsplib_pushpopreg_pop_before_put.cpp similarity index 71% rename from tests/functional/func_bsplib_pushpopreg_pop_before_put.c rename to tests/functional/func_bsplib_pushpopreg_pop_before_put.cpp index c9733fc4..45e99624 100644 --- a/tests/functional/func_bsplib_pushpopreg_pop_before_put.c +++ b/tests/functional/func_bsplib_pushpopreg_pop_before_put.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,33 +27,33 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, (size_t) -1, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int a = 0; rc = bsplib_push_reg( bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int b = 2; rc = bsplib_put( bsplib, 0, &b, &a, 0, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", 0, a ); - EXPECT_EQ( "%d", 2, b ); + EXPECT_EQ( 0, a ); + EXPECT_EQ( 2, b ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", bsplib_pid( bsplib ) == 0 ? 2 : 0, a ); - EXPECT_EQ( "%d", 2, b ); + EXPECT_EQ( bsplib_pid( bsplib ) == 0 ? 2 : 0, a ); + EXPECT_EQ( 2, b ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -61,10 +61,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_pop_before_put ) +TEST( API, func_bsplib_pushpopreg_pop_before_put ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_pop_before_put_unsafemode.c b/tests/functional/func_bsplib_pushpopreg_pop_before_put_unsafemode.cpp similarity index 71% rename from tests/functional/func_bsplib_pushpopreg_pop_before_put_unsafemode.c rename to tests/functional/func_bsplib_pushpopreg_pop_before_put_unsafemode.cpp index 9d901e13..3a1a1a65 100644 --- a/tests/functional/func_bsplib_pushpopreg_pop_before_put_unsafemode.c +++ b/tests/functional/func_bsplib_pushpopreg_pop_before_put_unsafemode.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,33 +27,33 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 2, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int a = 0; rc = bsplib_push_reg( bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int b = 2; rc = bsplib_put( bsplib, 0, &b, &a, 0, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", 0, a ); - EXPECT_EQ( "%d", 2, b ); + EXPECT_EQ( 0, a ); + EXPECT_EQ( 2, b ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", bsplib_pid( bsplib ) == 0 ? 2 : 0, a ); - EXPECT_EQ( "%d", 2, b ); + EXPECT_EQ( bsplib_pid( bsplib ) == 0 ? 2 : 0, a ); + EXPECT_EQ( 2, b ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -61,10 +61,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_pop_before_put_unsafemode ) +TEST( API, func_bsplib_pushpopreg_pop_before_put_unsafemode ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_pop_on_one_process.c b/tests/functional/func_bsplib_pushpopreg_pop_on_one_process.cpp similarity index 77% rename from tests/functional/func_bsplib_pushpopreg_pop_on_one_process.c rename to tests/functional/func_bsplib_pushpopreg_pop_on_one_process.cpp index 62c121f7..68bf2599 100644 --- a/tests/functional/func_bsplib_pushpopreg_pop_on_one_process.c +++ b/tests/functional/func_bsplib_pushpopreg_pop_on_one_process.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,26 +27,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int a; rc = bsplib_push_reg( bsplib, &a, sizeof(a) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if ( bsplib_pid( bsplib ) != 0 ) { rc = bsplib_pop_reg( bsplib, &a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_ERR_POPREG_MISMATCH, rc ); + EXPECT_EQ( BSPLIB_ERR_POPREG_MISMATCH, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -54,10 +54,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_pop_on_one_process ) +TEST( API, func_bsplib_pushpopreg_pop_on_one_process ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_push_on_one_process.c b/tests/functional/func_bsplib_pushpopreg_push_on_one_process.cpp similarity index 81% rename from tests/functional/func_bsplib_pushpopreg_push_on_one_process.c rename to tests/functional/func_bsplib_pushpopreg_push_on_one_process.cpp index 617c843d..cad70fda 100644 --- a/tests/functional/func_bsplib_pushpopreg_push_on_one_process.c +++ b/tests/functional/func_bsplib_pushpopreg_push_on_one_process.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,21 +27,21 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int a; if ( bsplib_pid( bsplib ) != 0 ) { rc = bsplib_push_reg( bsplib, &a, sizeof(a) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_ERR_PUSHREG_MISMATCH, rc ); + EXPECT_EQ( BSPLIB_ERR_PUSHREG_MISMATCH, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -49,10 +49,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_on_one_process ) +TEST( API, func_bsplib_pushpopreg_on_one_process ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_same_growing_memory.c b/tests/functional/func_bsplib_pushpopreg_same_growing_memory.cpp similarity index 66% rename from tests/functional/func_bsplib_pushpopreg_same_growing_memory.c rename to tests/functional/func_bsplib_pushpopreg_same_growing_memory.cpp index fc13c316..5ac4321f 100644 --- a/tests/functional/func_bsplib_pushpopreg_same_growing_memory.c +++ b/tests/functional/func_bsplib_pushpopreg_same_growing_memory.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,65 +27,65 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, (size_t) -1, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // first register a bit of memory char memory[10]; memset( memory, 0, sizeof( memory ) ); rc = bsplib_push_reg( bsplib, &memory[0], 3 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char x = 'x'; rc = bsplib_put( bsplib, ( bsplib_pid( bsplib ) + 1 ) % bsplib_nprocs( bsplib ), &x, memory, 0, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", '\0', memory[0] ); - EXPECT_EQ( "%c", 'x', x ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( '\0', memory[0] ); + EXPECT_EQ( 'x', x ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", 'x', memory[0] ); - EXPECT_EQ( "%d", 'x', x ); + EXPECT_EQ( 'x', memory[0] ); + EXPECT_EQ( 'x', x ); - EXPECT_EQ( "%d", '\0', memory[4] ); + EXPECT_EQ( '\0', memory[4] ); rc = bsplib_put( bsplib, ( bsplib_pid( bsplib ) + 1 ) % bsplib_nprocs( bsplib ), &x, memory, 4, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); - EXPECT_EQ( "%c", '\0', memory[4] ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); + EXPECT_EQ( '\0', memory[4] ); // now register the memory again, but with larger extent rc = bsplib_push_reg( bsplib, &memory[0], 5 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put( bsplib, ( bsplib_pid( bsplib ) + 1 ) % bsplib_nprocs( bsplib ), &x, memory, 4, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", '\0', memory[4] ); - EXPECT_EQ( "%c", 'x', x ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( '\0', memory[4] ); + EXPECT_EQ( 'x', x ); rc = bsplib_pop_reg( bsplib, &memory[0] ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, &memory[0] ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', memory[4] ); - EXPECT_EQ( "%c", 'x', x ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( 'x', memory[4] ); + EXPECT_EQ( 'x', x ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -93,10 +93,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_same_growing_memory) +TEST( API, func_bsplib_pushpopreg_same_growing_memory) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_same_shrinking_memory.c b/tests/functional/func_bsplib_pushpopreg_same_shrinking_memory.cpp similarity index 66% rename from tests/functional/func_bsplib_pushpopreg_same_shrinking_memory.c rename to tests/functional/func_bsplib_pushpopreg_same_shrinking_memory.cpp index f6a0ef56..6d9fb24f 100644 --- a/tests/functional/func_bsplib_pushpopreg_same_shrinking_memory.c +++ b/tests/functional/func_bsplib_pushpopreg_same_shrinking_memory.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,45 +27,45 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 2, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // first register a bit of memory char memory[10]; memset( memory, 0, sizeof( memory ) ); rc = bsplib_push_reg(bsplib, &memory[0], 8 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char x = 'x'; rc = bsplib_put(bsplib, ( bsplib_pid(bsplib) + 1 ) % bsplib_nprocs(bsplib), &x, memory, 0, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", '\0', memory[0] ); - EXPECT_EQ( "%c", 'x', x ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( '\0', memory[0] ); + EXPECT_EQ( 'x', x ); rc = bsplib_put(bsplib, ( bsplib_pid(bsplib) + 1 ) % bsplib_nprocs(bsplib), &x, memory, 4, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", '\0', memory[4] ); - EXPECT_EQ( "%c", 'x', x ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( '\0', memory[4] ); + EXPECT_EQ( 'x', x ); rc = bsplib_sync(bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', memory[0] ); - EXPECT_EQ( "%c", 'x', x ); + EXPECT_EQ( 'x', memory[0] ); + EXPECT_EQ( 'x', x ); - EXPECT_EQ( "%c", 'x', memory[4] ); - EXPECT_EQ( "%c", 'x', x ); + EXPECT_EQ( 'x', memory[4] ); + EXPECT_EQ( 'x', x ); // now register the memory again, but with smaller extent rc = bsplib_push_reg(bsplib, &memory[0], 2 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib ); @@ -74,34 +74,34 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = bsplib_put(bsplib, ( bsplib_pid(bsplib) + 1 ) % bsplib_nprocs(bsplib), &x, memory, 4, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); - EXPECT_EQ( "%c", 'x', memory[4] ); - EXPECT_EQ( "%c", 'a', x ); + EXPECT_EQ( 'x', memory[4] ); + EXPECT_EQ( 'a', x ); rc = bsplib_pop_reg(bsplib, &memory[0] ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // Stack order of registering the same memory! rc = bsplib_put(bsplib, ( bsplib_pid(bsplib) + 1 ) % bsplib_nprocs(bsplib), &x, memory, 4, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg(bsplib, &memory[0] ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'x', memory[4] ); + EXPECT_EQ( 'x', memory[4] ); rc = bsplib_sync(bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%c", 'a', x ); - EXPECT_EQ( "%c", 'a', memory[4] ); + EXPECT_EQ( 'a', x ); + EXPECT_EQ( 'a', memory[4] ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -109,10 +109,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_same_shrinking_memory) +TEST( API, func_bsplib_pushpopreg_same_shrinking_memory) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_pushpopreg_two_pops_before_two_puts.c b/tests/functional/func_bsplib_pushpopreg_two_pops_before_two_puts.cpp similarity index 68% rename from tests/functional/func_bsplib_pushpopreg_two_pops_before_two_puts.c rename to tests/functional/func_bsplib_pushpopreg_two_pops_before_two_puts.cpp index 29cdea32..1df12587 100644 --- a/tests/functional/func_bsplib_pushpopreg_two_pops_before_two_puts.c +++ b/tests/functional/func_bsplib_pushpopreg_two_pops_before_two_puts.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,44 +27,44 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int c[2] = { 0, 0}; int a[2]; memset( a, 0, sizeof(a)); rc = bsplib_push_reg( bsplib, a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_push_reg( bsplib, a, sizeof( int ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg( bsplib, a ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int b = 2; rc = bsplib_put( bsplib, 0, &b, a, 0, sizeof( int ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_put( bsplib, 0, c, a, 0, sizeof( c) ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); - EXPECT_EQ( "%d", 0, a[0] ); - EXPECT_EQ( "%d", 2, b ); + EXPECT_EQ( 0, a[0] ); + EXPECT_EQ( 2, b ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", bsplib_pid( bsplib ) == 0 ? 2 : 0, a[0] ); - EXPECT_EQ( "%d", 2, b ); + EXPECT_EQ( bsplib_pid( bsplib ) == 0 ? 2 : 0, a[0] ); + EXPECT_EQ( 2, b ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -72,10 +72,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_pushpopreg_two_pops_before_two_puts ) +TEST( API, func_bsplib_pushpopreg_two_pops_before_two_puts ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_put_exceptions.c b/tests/functional/func_bsplib_put_exceptions.cpp similarity index 76% rename from tests/functional/func_bsplib_put_exceptions.c rename to tests/functional/func_bsplib_put_exceptions.cpp index da7102c7..4d70c972 100644 --- a/tests/functional/func_bsplib_put_exceptions.c +++ b/tests/functional/func_bsplib_put_exceptions.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,26 +26,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_err_t rc = BSPLIB_SUCCESS; bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 1, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); char a = 'a'; char b = 'b'; rc = bsplib_push_reg( bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc =bsplib_put( bsplib, 0, &b, &a, 1, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); rc =bsplib_put( bsplib, 0, &b, &a, 0, sizeof( a ) * 2 ); - EXPECT_EQ( "%d", BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); + EXPECT_EQ( BSPLIB_ERR_MEMORY_ACCESS_OUT_OF_RANGE, rc ); rc = bsplib_put( bsplib, bsplib_nprocs( bsplib ), &b, &a, 0, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_ERR_PID_OUT_OF_RANGE, rc ); + EXPECT_EQ( BSPLIB_ERR_PID_OUT_OF_RANGE, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -53,10 +53,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_put_exceptions ) +TEST( API, func_bsplib_put_exceptions ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_put_normal.c b/tests/functional/func_bsplib_put_normal.cpp similarity index 73% rename from tests/functional/func_bsplib_put_normal.c rename to tests/functional/func_bsplib_put_normal.cpp index f5a72d3c..4f527919 100644 --- a/tests/functional/func_bsplib_put_normal.c +++ b/tests/functional/func_bsplib_put_normal.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -29,7 +29,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int i; const int n = 10; @@ -37,19 +37,19 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) uint32_t *array = memory + 2; int length = 5; rc = bsplib_push_reg(bsplib, array, length ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); uint32_t value = 0x12345678; rc = bsplib_put(bsplib, ( bsplib_pid(bsplib) + 1 ) % bsplib_nprocs(bsplib), &value, array, 0, sizeof( value ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg(bsplib, array ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { @@ -58,28 +58,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) for ( i = 0; i < n; ++i ) { - EXPECT_EQ( "%u", 0xAAAAAAAAu, memory[i] ); + EXPECT_EQ( 0xAAAAAAAAu, memory[i] ); } - EXPECT_EQ( "%u", 0x12345678u, value ); + EXPECT_EQ( 0x12345678u, value ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { if ( 2 != i ) { - EXPECT_EQ( "%u", 0xAAAAAAAAu, memory[i] ); + EXPECT_EQ( 0xAAAAAAAAu, memory[i] ); } else { - EXPECT_EQ( "%u", 0x12345678u, memory[i] ); + EXPECT_EQ( 0x12345678u, memory[i] ); } } - EXPECT_EQ( "%u", 0x12345678u, value ); + EXPECT_EQ( 0x12345678u, value ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -87,10 +87,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_put_normal) +TEST( API, func_bsplib_put_normal) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_put_normal_unsafemode.c b/tests/functional/func_bsplib_put_normal_unsafemode.cpp similarity index 73% rename from tests/functional/func_bsplib_put_normal_unsafemode.c rename to tests/functional/func_bsplib_put_normal_unsafemode.cpp index ebce8aa7..ec5150b6 100644 --- a/tests/functional/func_bsplib_put_normal_unsafemode.c +++ b/tests/functional/func_bsplib_put_normal_unsafemode.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -29,7 +29,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); int i; const int n = 10; @@ -37,19 +37,19 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) uint32_t *array = memory + 2; int length = 5; rc = bsplib_push_reg(bsplib, array, length ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); uint32_t value = 0x12345678; rc = bsplib_put(bsplib, ( bsplib_pid(bsplib) + 1 ) % bsplib_nprocs(bsplib), &value, array, 0, sizeof( value ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_pop_reg(bsplib, array ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { @@ -58,28 +58,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) for ( i = 0; i < n; ++i ) { - EXPECT_EQ( "%u", 0xAAAAAAAAu, memory[i] ); + EXPECT_EQ( 0xAAAAAAAAu, memory[i] ); } - EXPECT_EQ( "%u", 0x12345678u, value ); + EXPECT_EQ( 0x12345678u, value ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); for ( i = 0; i < n; ++i ) { if ( 2 != i ) { - EXPECT_EQ( "%u", 0xAAAAAAAAu, memory[i] ); + EXPECT_EQ( 0xAAAAAAAAu, memory[i] ); } else { - EXPECT_EQ( "%u", 0x12345678u, memory[i] ); + EXPECT_EQ( 0x12345678u, memory[i] ); } } - EXPECT_EQ( "%u", 0x12345678u, value ); + EXPECT_EQ( 0x12345678u, value ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -87,10 +87,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_put_normal_unsafemode) +TEST( API, func_bsplib_put_normal_unsafemode) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_send_empty_tag.c b/tests/functional/func_bsplib_send_empty_tag.cpp similarity index 63% rename from tests/functional/func_bsplib_send_empty_tag.c rename to tests/functional/func_bsplib_send_empty_tag.cpp index 78f64daf..68f5576a 100644 --- a/tests/functional/func_bsplib_send_empty_tag.c +++ b/tests/functional/func_bsplib_send_empty_tag.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,7 +28,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); size_t tagSize = sizeof( int ); size_t oldTagSize = 0; @@ -37,89 +37,89 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // set tag size which go in effect next super-step oldTagSize = bsplib_set_tagsize(bsplib, tagSize ); - EXPECT_EQ( "%zu", ( size_t ) 0, oldTagSize ); + EXPECT_EQ( ( size_t ) 0, oldTagSize ); // assert that messages queue is empty rc = bsplib_get_tag(bsplib, &status, NULL ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) - 1, status ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) - 1, status ); rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) 0, nmsg ); - EXPECT_EQ( "%zu", ( size_t ) 0, bytes ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) 0, nmsg ); + EXPECT_EQ( ( size_t ) 0, bytes ); // send two messages const int x = 0x12345678; const int y = 0x87654321; rc = bsplib_send(bsplib, 0, &x, &y, sizeof( y ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_send(bsplib, 0, &x, &y, 0 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // message queue is still empty, of course rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) 0, nmsg ); - EXPECT_EQ( "%zu", ( size_t ) 0, bytes ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) 0, nmsg ); + EXPECT_EQ( ( size_t ) 0, bytes ); // Barrier synchronization rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == 0 ? 2 * bsplib_nprocs(bsplib) : 0 ), + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? 2 * bsplib_nprocs(bsplib) : 0 ), nmsg ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) * sizeof( y ) : 0 ), bytes ); int z = 0; size_t nMessages = 0; while ( rc = bsplib_get_tag(bsplib, &status, &z ), status != (size_t) -1 ) { - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", 0, z ); - EXPECT_NE( "%zu", ( size_t ) -1, status ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( 0, z ); + EXPECT_NE( ( size_t ) -1, status ); // before the move qsize should return size_t msgs2 = -1; size_t bytes2 = -1; rc = bsplib_qsize(bsplib, &msgs2, &bytes2 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", bytes, bytes2 ); - EXPECT_EQ( "%zu", msgs2, 2 * bsplib_nprocs(bsplib) - nMessages ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( bytes, bytes2 ); + EXPECT_EQ( msgs2, 2 * bsplib_nprocs(bsplib) - nMessages ); // dequeue the message int a = -1; rc = bsplib_move(bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); ++nMessages; // after the move the values returned by qsize decrease bytes -= status; rc = bsplib_qsize(bsplib, &msgs2, &bytes2 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", bytes, bytes2 ); - EXPECT_EQ( "%zu", msgs2, 2 * bsplib_nprocs(bsplib) - nMessages ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( bytes, bytes2 ); + EXPECT_EQ( msgs2, 2 * bsplib_nprocs(bsplib) - nMessages ); if ( status == sizeof( y ) ) { - EXPECT_EQ( "%d", y, a ); + EXPECT_EQ( y, a ); } else { - EXPECT_EQ( "%zu", ( size_t ) 0, status ); - EXPECT_EQ( "%d", -1, a ); + EXPECT_EQ( ( size_t ) 0, status ); + EXPECT_EQ( -1, a ); } } - EXPECT_EQ( "%u", + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 2 * bsplib_nprocs(bsplib) : 0, (lpf_pid_t) nMessages ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -127,10 +127,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_send_empty_tag ) +TEST( API, func_bsplib_send_empty_tag ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_send_non_empty_tag.c b/tests/functional/func_bsplib_send_non_empty_tag.cpp similarity index 61% rename from tests/functional/func_bsplib_send_non_empty_tag.c rename to tests/functional/func_bsplib_send_non_empty_tag.cpp index a003d2c8..c8910d15 100644 --- a/tests/functional/func_bsplib_send_non_empty_tag.c +++ b/tests/functional/func_bsplib_send_non_empty_tag.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,7 +28,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); size_t tagSize = sizeof( int ); size_t oldTagSize = -1; @@ -37,92 +37,91 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // set tag size which go in effect next super-step oldTagSize = bsplib_set_tagsize(bsplib, tagSize ); - EXPECT_EQ( "%zu", ( size_t ) 0, oldTagSize ); + EXPECT_EQ( ( size_t ) 0, oldTagSize ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // assert that messages queue is empty rc = bsplib_get_tag(bsplib, &status, NULL ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) - 1, status ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) - 1, status ); rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) 0, nmsg ); - EXPECT_EQ( "%zu", ( size_t ) 0, bytes ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) 0, nmsg ); + EXPECT_EQ( ( size_t ) 0, bytes ); // send two messages const int x = 0x12345678; const int y = 0x87654321; rc = bsplib_send(bsplib, 0, &x, &y, sizeof( y ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_send(bsplib, 0, &x, &y, 0 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); // message queue is still empty, of course rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) 0, nmsg ); - EXPECT_EQ( "%zu", ( size_t ) 0, bytes ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) 0, nmsg ); + EXPECT_EQ( ( size_t ) 0, bytes ); // Barrier synchronization rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == 0 ? 2 * bsplib_nprocs(bsplib) : 0 ), + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? 2 * bsplib_nprocs(bsplib) : 0 ), nmsg ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) * sizeof( y ) : 0 ), bytes ); int z = 0; size_t nMessages = 0; while ( rc = bsplib_get_tag(bsplib, &status, &z ), status != (size_t) -1 ) { - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", x, z ); - EXPECT_NE( "%zu", ( size_t ) -1, status ); + EXPECT_EQ( x, z ); + EXPECT_NE( ( size_t ) -1, status ); // before the move qsize should return size_t msgs2 = -1; size_t bytes2 = -1; rc = bsplib_qsize(bsplib, &msgs2, &bytes2 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", bytes, bytes2 ); - EXPECT_EQ( "%zu", msgs2, 2 * bsplib_nprocs(bsplib) - nMessages ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( bytes, bytes2 ); + EXPECT_EQ( msgs2, 2 * bsplib_nprocs(bsplib) - nMessages ); // dequeue the message int a = -1; rc = bsplib_move(bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); ++nMessages; // after the move the values returned by qsize decrease bytes -= status; rc = bsplib_qsize(bsplib, &msgs2, &bytes2 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", bytes, bytes2 ); - EXPECT_EQ( "%zu", msgs2, 2 * bsplib_nprocs(bsplib) - nMessages ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( bytes, bytes2 ); + EXPECT_EQ( msgs2, 2 * bsplib_nprocs(bsplib) - nMessages ); if ( status == sizeof( y ) ) { - EXPECT_EQ( "%d", y, a ); + EXPECT_EQ( y, a ); } else { - EXPECT_EQ( "%zu", ( size_t ) 0, status ); - EXPECT_EQ( "%d", -1, a ); + EXPECT_EQ( ( size_t ) 0, status ); + EXPECT_EQ( -1, a ); } } - EXPECT_EQ( "%u", - bsplib_pid(bsplib) == 0 ? 2 * bsplib_nprocs(bsplib) : 0, + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? 2 * bsplib_nprocs(bsplib) : 0, (unsigned) nMessages ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -130,10 +129,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_send_non_empty_tag ) +TEST( API, func_bsplib_send_non_empty_tag ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_send_none.c b/tests/functional/func_bsplib_send_none.cpp similarity index 77% rename from tests/functional/func_bsplib_send_none.c rename to tests/functional/func_bsplib_send_none.cpp index 14314afe..3bbd2e7f 100644 --- a/tests/functional/func_bsplib_send_none.c +++ b/tests/functional/func_bsplib_send_none.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,7 +28,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); size_t tagSize = sizeof( int ); size_t nmsg = -1, bytes = -1; @@ -36,18 +36,18 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // set tag size which go in effect next super-step oldTagSize = bsplib_set_tagsize(bsplib, tagSize ); - EXPECT_EQ( "%zu", ( size_t ) 0, oldTagSize ); + EXPECT_EQ( ( size_t ) 0, oldTagSize ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", (size_t) 0, nmsg ); - EXPECT_EQ( "%zu", ( size_t ) 0 , bytes ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( (size_t) 0, nmsg ); + EXPECT_EQ( ( size_t ) 0 , bytes ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -55,10 +55,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_send_none) +TEST( API, func_bsplib_send_none) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_send_null.c b/tests/functional/func_bsplib_send_null.cpp similarity index 62% rename from tests/functional/func_bsplib_send_null.c rename to tests/functional/func_bsplib_send_null.cpp index 30bfbda7..19146577 100644 --- a/tests/functional/func_bsplib_send_null.c +++ b/tests/functional/func_bsplib_send_null.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,7 +28,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); size_t tagSize = sizeof( int ); size_t nmsg = -1, bytes = -1; @@ -37,96 +37,96 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // set tag size which go in effect next super-step oldTagSize = bsplib_set_tagsize(bsplib, tagSize ); - EXPECT_EQ( "%zu", ( size_t ) 0, oldTagSize ); + EXPECT_EQ( ( size_t ) 0, oldTagSize ); const int x = 0x12345678; //const int y = 0x87654321; const int z = 0x12344321; rc = bsplib_send(bsplib, 0, NULL, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_send(bsplib, 1, &z, NULL, 0 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) : 0 ), + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) : 0 ), nmsg ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) * sizeof( x ) : 0 ), bytes ); int tag = -1; size_t nMessages = 0; while ( rc = bsplib_get_tag(bsplib, &status, &tag ), status != (size_t) -1 ) { - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", -1, tag ); - EXPECT_NE( "%zu", ( size_t ) -1, status ); + EXPECT_EQ( -1, tag ); + EXPECT_NE( ( size_t ) -1, status ); int a = -1; rc = bsplib_move(bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); ++nMessages; // after the move the values returned by qsize decrease bytes -= status; size_t msgs2 = -1, bytes2 = -1; rc = bsplib_qsize(bsplib, &msgs2, &bytes2 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", bytes, bytes2 ); - EXPECT_EQ( "%zu", msgs2, bsplib_nprocs(bsplib) - nMessages ); - EXPECT_EQ( "%zu", ( size_t ) sizeof( x ), status ); - EXPECT_EQ( "%d", x, a ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( bytes, bytes2 ); + EXPECT_EQ( msgs2, bsplib_nprocs(bsplib) - nMessages ); + EXPECT_EQ( ( size_t ) sizeof( x ), status ); + EXPECT_EQ( x, a ); } - EXPECT_EQ( "%u", + EXPECT_EQ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) : 0, (unsigned) nMessages ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == 1 ? bsplib_nprocs(bsplib) : 0 ), + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 1 ? bsplib_nprocs(bsplib) : 0 ), nmsg ); - EXPECT_EQ( "%zu", ( size_t ) 0, bytes ); + EXPECT_EQ( ( size_t ) 0, bytes ); tag = -1; nMessages = 0; while ( rc = bsplib_get_tag(bsplib, &status, &tag ), status != (size_t) -1 ) { - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%d", z, tag ); - EXPECT_NE( "%zu", ( size_t ) -1, status ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( z, tag ); + EXPECT_NE( ( size_t ) -1, status ); int a = -1; rc = bsplib_move(bsplib, &a, sizeof( a ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); ++nMessages; // after the move the values returned by qsize decrease bytes -= status; size_t msgs2 = -1, bytes2 = -1; rc = bsplib_qsize(bsplib, &msgs2, &bytes2 ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", bytes, bytes2 ); - EXPECT_EQ( "%zu", msgs2, bsplib_nprocs(bsplib) - nMessages ); - EXPECT_EQ( "%zu", ( size_t ) 0, status ); - EXPECT_EQ( "%d", -1, a ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( bytes, bytes2 ); + EXPECT_EQ( msgs2, bsplib_nprocs(bsplib) - nMessages ); + EXPECT_EQ( ( size_t ) 0, status ); + EXPECT_EQ( -1, a ); } - EXPECT_EQ( "%u", + EXPECT_EQ( bsplib_pid(bsplib) == 1 ? bsplib_nprocs(bsplib) : 0, (unsigned) nMessages ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -134,10 +134,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_send_null ) +TEST( API, func_bsplib_send_null ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_send_one.c b/tests/functional/func_bsplib_send_one.cpp similarity index 76% rename from tests/functional/func_bsplib_send_one.c rename to tests/functional/func_bsplib_send_one.cpp index 43dee2fe..4de9ca40 100644 --- a/tests/functional/func_bsplib_send_one.c +++ b/tests/functional/func_bsplib_send_one.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,7 +28,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); size_t tagSize = sizeof( int ); size_t nmsg = -1, bytes = -1; @@ -36,26 +36,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // set tag size which go in effect next super-step oldTagSize = bsplib_set_tagsize(bsplib, tagSize ); - EXPECT_EQ( "%zu", ( size_t ) 0, oldTagSize ); + EXPECT_EQ( ( size_t ) 0, oldTagSize ); const int x = 0x12345678; //const int y = 0x87654321; rc = bsplib_send(bsplib, 0, NULL, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) : 0 ), + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) : 0 ), nmsg ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) * sizeof( x ) : 0 ), bytes ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -63,10 +63,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_send_one) +TEST( API, func_bsplib_send_one) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_send_one_unsafemode.c b/tests/functional/func_bsplib_send_one_unsafemode.cpp similarity index 75% rename from tests/functional/func_bsplib_send_one_unsafemode.c rename to tests/functional/func_bsplib_send_one_unsafemode.cpp index 61b35ac0..985064bf 100644 --- a/tests/functional/func_bsplib_send_one_unsafemode.c +++ b/tests/functional/func_bsplib_send_one_unsafemode.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,7 +28,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 0, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); size_t tagSize = sizeof( int ); size_t nmsg = -1, bytes = -1; @@ -36,26 +36,26 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // set tag size which go in effect next super-step oldTagSize = bsplib_set_tagsize(bsplib, tagSize ); - EXPECT_EQ( "%zu", ( size_t ) 0, oldTagSize ); + EXPECT_EQ( ( size_t ) 0, oldTagSize ); const int x = 0x12345678; //const int y = 0x87654321; rc = bsplib_send(bsplib, 0, NULL, &x, sizeof( x ) ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); rc = bsplib_qsize(bsplib, &nmsg, &bytes ); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) : 0 ), + EXPECT_EQ( BSPLIB_SUCCESS, rc ); + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) : 0 ), nmsg ); - EXPECT_EQ( "%zu", ( size_t ) ( bsplib_pid(bsplib) == + EXPECT_EQ( ( size_t ) ( bsplib_pid(bsplib) == 0 ? bsplib_nprocs(bsplib) * sizeof( x ) : 0 ), bytes ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -63,10 +63,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_send_one_unsafemode) +TEST( API, func_bsplib_send_one_unsafemode) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_set_different_tag_size.c b/tests/functional/func_bsplib_set_different_tag_size.cpp similarity index 83% rename from tests/functional/func_bsplib_set_different_tag_size.c rename to tests/functional/func_bsplib_set_different_tag_size.cpp index 82cc9773..4741fbbf 100644 --- a/tests/functional/func_bsplib_set_different_tag_size.c +++ b/tests/functional/func_bsplib_set_different_tag_size.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,15 +28,15 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 0, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); size_t tagSize = bsplib_pid( bsplib ); bsplib_set_tagsize( bsplib, tagSize ); rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_ERR_TAGSIZE_MISMATCH, rc ); + EXPECT_EQ( BSPLIB_ERR_TAGSIZE_MISMATCH, rc ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -44,10 +44,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_set_different_tag_size ) +TEST( API, func_bsplib_set_different_tag_size ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_set_tag_size.c b/tests/functional/func_bsplib_set_tag_size.cpp similarity index 78% rename from tests/functional/func_bsplib_set_tag_size.c rename to tests/functional/func_bsplib_set_tag_size.cpp index e64957b8..0d154404 100644 --- a/tests/functional/func_bsplib_set_tag_size.c +++ b/tests/functional/func_bsplib_set_tag_size.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -28,30 +28,30 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, (size_t) -1, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); size_t tagSize = 10, oldTagSize = -1; oldTagSize = bsplib_set_tagsize(bsplib, tagSize ); // test for the default tag size; - EXPECT_EQ( "%lu", (size_t) 0, oldTagSize ); + EXPECT_EQ( (size_t) 0, oldTagSize ); // go back to the normal tag size oldTagSize = bsplib_set_tagsize(bsplib, 0 ); - EXPECT_EQ( "%lu", (size_t) 0, oldTagSize ); + EXPECT_EQ( (size_t) 0, oldTagSize ); tagSize = sizeof( int ); oldTagSize = bsplib_set_tagsize(bsplib, tagSize ); - EXPECT_EQ( "%lu", (size_t) 0, oldTagSize ); + EXPECT_EQ( (size_t) 0, oldTagSize ); rc = bsplib_sync(bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); oldTagSize = bsplib_set_tagsize(bsplib, 0 ); - EXPECT_EQ( "%lu", sizeof( int ), oldTagSize ); + EXPECT_EQ( sizeof( int ), oldTagSize ); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -59,10 +59,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_set_tag_size ) +TEST(API, func_bsplib_set_tag_size ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_sync_except_p0.c b/tests/functional/func_bsplib_sync_except_p0.cpp similarity index 83% rename from tests/functional/func_bsplib_sync_except_p0.c rename to tests/functional/func_bsplib_sync_except_p0.cpp index 2109d141..ac3da1c2 100644 --- a/tests/functional/func_bsplib_sync_except_p0.c +++ b/tests/functional/func_bsplib_sync_except_p0.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,15 +27,15 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 3, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if (pid!=0) { rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_ERR_FATAL, rc ); + EXPECT_EQ( BSPLIB_ERR_FATAL, rc ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_ERR_FATAL, rc ); + EXPECT_EQ( BSPLIB_ERR_FATAL, rc ); } /** @@ -43,10 +43,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_sync_except_p0 ) +TEST(API, func_bsplib_sync_except_p0 ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_bsplib_sync_only_p0.c b/tests/functional/func_bsplib_sync_only_p0.cpp similarity index 83% rename from tests/functional/func_bsplib_sync_only_p0.c rename to tests/functional/func_bsplib_sync_only_p0.cpp index a66e3aa4..5b3416b5 100644 --- a/tests/functional/func_bsplib_sync_only_p0.c +++ b/tests/functional/func_bsplib_sync_only_p0.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,15 +27,15 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, (size_t) -1, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); if (pid==0) { rc = bsplib_sync( bsplib ); - EXPECT_EQ( "%d", BSPLIB_ERR_FATAL, rc ); + EXPECT_EQ( BSPLIB_ERR_FATAL, rc ); } rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_ERR_FATAL, rc ); + EXPECT_EQ( BSPLIB_ERR_FATAL, rc ); } /** @@ -43,10 +43,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_bsplib_sync_only_p0 ) +TEST( API, func_bsplib_sync_only_p0 ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS , rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS , rc ); } diff --git a/tests/functional/func_bsplib_time.c b/tests/functional/func_bsplib_time.cpp similarity index 83% rename from tests/functional/func_bsplib_time.c rename to tests/functional/func_bsplib_time.cpp index fa650d87..fa570db6 100644 --- a/tests/functional/func_bsplib_time.c +++ b/tests/functional/func_bsplib_time.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,15 +27,15 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) bsplib_t bsplib; rc = bsplib_create( lpf, pid, nprocs, 1, 3, &bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); double t0 = bsplib_time( bsplib ); - EXPECT_LT( "%f", 0.0, t0); + EXPECT_LT( 0.0, t0); double t1 = bsplib_time( bsplib ); - EXPECT_LT( "%f", t0, t1); + EXPECT_LT( t0, t1); rc = bsplib_destroy( bsplib); - EXPECT_EQ( "%d", BSPLIB_SUCCESS, rc ); + EXPECT_EQ( BSPLIB_SUCCESS, rc ); } /** @@ -43,10 +43,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_bsplib_time ) +TEST( API, func_bsplib_time ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_deregister_parallel_multiple.c b/tests/functional/func_lpf_deregister_parallel_multiple.cpp similarity index 78% rename from tests/functional/func_lpf_deregister_parallel_multiple.c rename to tests/functional/func_lpf_deregister_parallel_multiple.cpp index c38b75c1..922f5ade 100644 --- a/tests/functional/func_lpf_deregister_parallel_multiple.c +++ b/tests/functional/func_lpf_deregister_parallel_multiple.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,11 +26,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) size_t maxMsgs = 8 , maxRegs = 4; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); char buffer[8] = "abcd"; lpf_memslot_t slots[4]; @@ -44,28 +44,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) for ( i = 0; i < maxRegs; ++i) { rc = lpf_register_global( lpf, &buffer[i*2], sizeof(buffer[0])*2, &slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - EXPECT_STREQ( 4, "abcd", buffer ); + EXPECT_EQ( LPF_SUCCESS, rc ); + EXPECT_STREQ( "abcd", buffer ); for (i = 0; i < maxRegs; ++i) { rc = lpf_put( lpf, slots[i], 0u, (pid+i)%nprocs, slots[i], 1u, sizeof(buffer[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - EXPECT_STREQ( 4, "aacc", buffer ); + EXPECT_EQ( LPF_SUCCESS, rc ); + EXPECT_STREQ( "aacc", buffer ); for ( i = 0 ; i < maxRegs; ++i) { rc = lpf_deregister( lpf, slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } // reset to previous state @@ -80,10 +80,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_deregister_parallel_multiple ) +TEST( API, func_lpf_deregister_parallel_multiple ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_deregister_parallel_single.c b/tests/functional/func_lpf_deregister_parallel_single.cpp similarity index 76% rename from tests/functional/func_lpf_deregister_parallel_single.c rename to tests/functional/func_lpf_deregister_parallel_single.cpp index 80a0addc..6475a17f 100644 --- a/tests/functional/func_lpf_deregister_parallel_single.c +++ b/tests/functional/func_lpf_deregister_parallel_single.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,11 +26,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) size_t maxMsgs = 4 , maxRegs = 4; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); int x = 1, y = 2, z = 3; lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; @@ -38,27 +38,27 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) lpf_memslot_t zslot = LPF_INVALID_MEMSLOT; rc = lpf_register_local( lpf, &x, sizeof(x), &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, &y, sizeof(y), &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &z, sizeof(z), &zslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if ( (pid | 0x1) < nprocs ) { rc = lpf_put( lpf, yslot, 0, pid ^ 0x1, zslot, 0, sizeof(y), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%d", (pid|0x1) < nprocs ? 2 : 3, z ); + EXPECT_EQ( (pid|0x1) < nprocs ? 2 : 3, z ); lpf_deregister( lpf, yslot ); lpf_deregister( lpf, zslot ); @@ -69,9 +69,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_deregister_parallel_single ) +TEST( API, func_lpf_deregister_parallel_single ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_exec_multiple_call_single_arg_dual_proc.c b/tests/functional/func_lpf_exec_multiple_call_single_arg_dual_proc.cpp similarity index 60% rename from tests/functional/func_lpf_exec_multiple_call_single_arg_dual_proc.c rename to tests/functional/func_lpf_exec_multiple_call_single_arg_dual_proc.cpp index 569eed93..f584fd9a 100644 --- a/tests/functional/func_lpf_exec_multiple_call_single_arg_dual_proc.c +++ b/tests/functional/func_lpf_exec_multiple_call_single_arg_dual_proc.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void function_1(void) {} void function_2(int a, long b, double c, float d) @@ -28,50 +28,50 @@ void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) lpf; // ignore lpf context variable - EXPECT_EQ( "%d", nprocs, 2 ); + EXPECT_EQ( nprocs, 2 ); if (0 == pid) { - EXPECT_EQ( "%zd", sizeof(int), args.input_size ); - EXPECT_EQ( "%zd", sizeof(int), args.output_size ); + EXPECT_EQ( sizeof(int), args.input_size ); + EXPECT_EQ( sizeof(int), args.output_size ); int n = (* (int *) args.input); - EXPECT_EQ( "%d", 4, n ); + EXPECT_EQ( 4, n ); * (int * ) args.output = 1 ; } else { - EXPECT_EQ( "%zd", (size_t) 0, args.input_size ); - EXPECT_EQ( "%zd", (size_t) 0, args.output_size ); - EXPECT_EQ( "%p", (void *) NULL, args.input ); - EXPECT_EQ( "%p", (void *) NULL, args.output ); + EXPECT_EQ( (size_t) 0, args.input_size ); + EXPECT_EQ( (size_t) 0, args.output_size ); + EXPECT_EQ( (void *) NULL, args.input ); + EXPECT_EQ( (void *) NULL, args.output ); } - EXPECT_EQ( "%zd", (size_t) 1 , args.f_size ); - EXPECT_EQ( "%p", (lpf_func_t) function_1, args.f_symbols[0] ); //note: function pointers cannot be formatted in ANSI C + EXPECT_EQ( (size_t) 1 , args.f_size ); + EXPECT_EQ( (lpf_func_t) function_1, args.f_symbols[0] ); //note: function pointers cannot be formatted in ANSI C } void spmd2( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) lpf; // ignore lpf context variable - EXPECT_EQ( "%d", nprocs, 2 ); + EXPECT_EQ( nprocs, 2 ); if (0 == pid) { - EXPECT_EQ( "%zd", sizeof(int), args.input_size ); - EXPECT_EQ( "%zd", sizeof(int), args.output_size ); + EXPECT_EQ( sizeof(int), args.input_size ); + EXPECT_EQ( sizeof(int), args.output_size ); int n = (* (int *) args.input) ; - EXPECT_EQ( "%d", 3, n ); + EXPECT_EQ( 3, n ); * (int * ) args.output = 2; } else { - EXPECT_EQ( "%zd", (size_t) 0, args.input_size ); - EXPECT_EQ( "%zd", (size_t) 0, args.output_size ); - EXPECT_EQ( "%p", (void *) NULL, args.input ); - EXPECT_EQ( "%p", (void *) NULL, args.output ); + EXPECT_EQ( (size_t) 0, args.input_size ); + EXPECT_EQ( (size_t) 0, args.output_size ); + EXPECT_EQ( (void *) NULL, args.input ); + EXPECT_EQ( (void *) NULL, args.output ); } - EXPECT_EQ( "%zd", (size_t) 1 , args.f_size ); - EXPECT_EQ( "%p", (lpf_func_t) function_2, args.f_symbols[0] ); //note: function pointers cannot be formatted in ANSI C + EXPECT_EQ( (size_t) 1 , args.f_size ); + EXPECT_EQ( (lpf_func_t) function_2, args.f_symbols[0] ); //note: function pointers cannot be formatted in ANSI C } @@ -82,7 +82,7 @@ void spmd2( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_lpf_exec_multiple_call_single_arg_dual_proc ) +TEST( API, func_lpf_exec_multiple_call_single_arg_dual_proc ) { int input[2] = { 4, 3}; int output[2] = { -1, -1 }; @@ -97,7 +97,7 @@ TEST( func_lpf_exec_multiple_call_single_arg_dual_proc ) args.f_size = 1; rc = lpf_exec( LPF_ROOT, 2, &spmd1, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); args.input = &input[1]; args.input_size = sizeof(int); @@ -107,15 +107,14 @@ TEST( func_lpf_exec_multiple_call_single_arg_dual_proc ) args.f_size = 1; rc = lpf_exec( LPF_ROOT, 2, &spmd2, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); int i; for (i = 0; i < 2; ++i) { int m = input[i]; - EXPECT_EQ( "%d", 4-i, m ); + EXPECT_EQ( 4-i, m ); int n = output[i]; - EXPECT_EQ( "%d", i+1, n ); + EXPECT_EQ( i+1, n ); } - return 0; } diff --git a/tests/functional/func_lpf_exec_nested_call_single_arg_dual_proc.c b/tests/functional/func_lpf_exec_nested_call_single_arg_dual_proc.cpp similarity index 58% rename from tests/functional/func_lpf_exec_nested_call_single_arg_dual_proc.c rename to tests/functional/func_lpf_exec_nested_call_single_arg_dual_proc.cpp index ac74b5fb..a0fc8db5 100644 --- a/tests/functional/func_lpf_exec_nested_call_single_arg_dual_proc.c +++ b/tests/functional/func_lpf_exec_nested_call_single_arg_dual_proc.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void function_1() {} void function_2() {} @@ -27,61 +27,61 @@ void spmd2( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) lpf; // ignore lpf context variable - EXPECT_LE( "%d", nprocs, 2); + EXPECT_LE( nprocs, 2); if ( 0 == pid ) { - EXPECT_EQ( "%zd", sizeof(int), args.input_size ); - EXPECT_EQ( "%zd", sizeof(int), args.output_size ); + EXPECT_EQ( sizeof(int), args.input_size ); + EXPECT_EQ( sizeof(int), args.output_size ); int n = * (int * ) args.input; - EXPECT_LE( "%d", 10, n ); - EXPECT_LT( "%d", n, 10 + 2); + EXPECT_LE( 10, n ); + EXPECT_LT( n, 10 + 2); * (int * ) args.output = 9; } else { - EXPECT_EQ( "%zd", (size_t) 0, args.input_size ); - EXPECT_EQ( "%zd", (size_t) 0, args.output_size ); - EXPECT_EQ( "%p", (void *) NULL, args.input ); - EXPECT_EQ( "%p", (void *) NULL, args.output ); + EXPECT_EQ( (size_t) 0, args.input_size ); + EXPECT_EQ( (size_t) 0, args.output_size ); + EXPECT_EQ((void *) NULL, args.input ); + EXPECT_EQ((void *) NULL, args.output ); } - EXPECT_EQ( "%zd", (size_t) 2, args.f_size ); - EXPECT_EQ( "%p", &function_2, args.f_symbols[0] ); - EXPECT_EQ( "%p", &function_3, args.f_symbols[1] ); + EXPECT_EQ( (size_t) 2, args.f_size ); + EXPECT_EQ( &function_2, args.f_symbols[0] ); + EXPECT_EQ( &function_3, args.f_symbols[1] ); } void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { - EXPECT_LE( "%d", nprocs, 2); + EXPECT_LE( nprocs, 2); if ( 0 == pid ) { - EXPECT_EQ( "%zd", sizeof(int), args.input_size ); - EXPECT_EQ( "%zd", sizeof(int), args.output_size ); + EXPECT_EQ( sizeof(int), args.input_size ); + EXPECT_EQ( sizeof(int), args.output_size ); int n = * (int * ) args.input; - EXPECT_EQ( "%d", 3, n ); - EXPECT_EQ( "%d", -1, * (int *) args.output); + EXPECT_EQ( 3, n ); + EXPECT_EQ( -1, * (int *) args.output); * (int * ) args.output = 7; } else { - EXPECT_EQ( "%zd", (size_t) 0, args.input_size ); - EXPECT_EQ( "%zd", (size_t) 0, args.output_size ); - EXPECT_EQ( "%p", (void *) NULL, args.input ); - EXPECT_EQ( "%p", (void *) NULL, args.output ); + EXPECT_EQ( (size_t) 0, args.input_size ); + EXPECT_EQ( (size_t) 0, args.output_size ); + EXPECT_EQ( (void *) NULL, args.input ); + EXPECT_EQ( (void *) NULL, args.output ); } - EXPECT_EQ( "%zd", (size_t) 3, args.f_size ); - EXPECT_EQ( "%p", &function_1, args.f_symbols[0] ); - EXPECT_EQ( "%p", &function_2, args.f_symbols[1] ); - EXPECT_EQ( "%p", &function_3, args.f_symbols[2] ); + EXPECT_EQ( (size_t) 3, args.f_size ); + EXPECT_EQ( &function_1, args.f_symbols[0] ); + EXPECT_EQ( &function_2, args.f_symbols[1] ); + EXPECT_EQ( &function_3, args.f_symbols[2] ); int x = 10 + pid; lpf_args_t newArgs; @@ -94,9 +94,9 @@ void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) newArgs.f_size = args.f_size - 1; lpf_err_t rc = lpf_exec( lpf, 2, &spmd2, newArgs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%d", 9, number ); + EXPECT_EQ( 9, number ); } @@ -106,7 +106,7 @@ void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_exec_nested_call_single_arg_dual_proc ) +TEST( API, func_lpf_exec_nested_call_single_arg_dual_proc ) { lpf_err_t rc = LPF_SUCCESS; int three = 3; @@ -121,7 +121,6 @@ TEST( func_lpf_exec_nested_call_single_arg_dual_proc ) args.f_size = sizeof(function_pointers)/sizeof(function_pointers[0]); rc = lpf_exec( LPF_ROOT, 2, &spmd1, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - EXPECT_EQ( "%d", number, 7 ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); + EXPECT_EQ( number, 7 ); } diff --git a/tests/functional/func_lpf_exec_single_call_no_arg_max_proc.c b/tests/functional/func_lpf_exec_single_call_no_arg_max_proc.cpp similarity index 70% rename from tests/functional/func_lpf_exec_single_call_no_arg_max_proc.c rename to tests/functional/func_lpf_exec_single_call_no_arg_max_proc.cpp index 7b1ecf6d..a4b470af 100644 --- a/tests/functional/func_lpf_exec_single_call_no_arg_max_proc.c +++ b/tests/functional/func_lpf_exec_single_call_no_arg_max_proc.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" @@ -25,12 +25,12 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) lpf; // ignore lpf context variable - EXPECT_LE( "%u", (lpf_pid_t) 1, nprocs ); - EXPECT_LE( "%u", (lpf_pid_t) 0, pid ); - EXPECT_EQ( "%zd", (size_t) 0, args.input_size ); - EXPECT_EQ( "%zd", (size_t) 0, args.output_size ); - EXPECT_EQ( "%p", (void *) NULL, args.input ); - EXPECT_EQ( "%p", (void *) NULL, args.output ); + EXPECT_LE( (lpf_pid_t) 1, nprocs ); + EXPECT_LE( (lpf_pid_t) 0, pid ); + EXPECT_EQ( (size_t) 0, args.input_size ); + EXPECT_EQ( (size_t) 0, args.output_size ); + EXPECT_EQ( (void *) NULL, args.input ); + EXPECT_EQ( (void *) NULL, args.output ); } @@ -39,10 +39,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_exec_single_call_no_arg_max_proc ) +TEST( API, func_lpf_exec_single_call_no_arg_max_proc ) { lpf_err_t rc = LPF_SUCCESS ; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_exec_single_call_no_arg_single_proc.c b/tests/functional/func_lpf_exec_single_call_no_arg_single_proc.cpp similarity index 70% rename from tests/functional/func_lpf_exec_single_call_no_arg_single_proc.c rename to tests/functional/func_lpf_exec_single_call_no_arg_single_proc.cpp index d5b433a1..aaa6ab15 100644 --- a/tests/functional/func_lpf_exec_single_call_no_arg_single_proc.c +++ b/tests/functional/func_lpf_exec_single_call_no_arg_single_proc.cpp @@ -17,19 +17,19 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) lpf; // ignore lpf context variable - EXPECT_LE( "%ud", (lpf_pid_t) 1, nprocs ); - EXPECT_LE( "%ud", (lpf_pid_t) 0, pid ); - EXPECT_EQ( "%zd", (size_t) 0, args.input_size ); - EXPECT_EQ( "%zd", (size_t) 0, args.output_size ); - EXPECT_EQ( "%p", (void *) NULL, args.input ); - EXPECT_EQ( "%p", (void *) NULL, args.output ); + EXPECT_LE( (lpf_pid_t) 1, nprocs ); + EXPECT_LE( (lpf_pid_t) 0, pid ); + EXPECT_EQ( (size_t) 0, args.input_size ); + EXPECT_EQ( (size_t) 0, args.output_size ); + EXPECT_EQ( (void *) NULL, args.input ); + EXPECT_EQ( (void *) NULL, args.output ); } @@ -38,10 +38,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_exec_single_call_no_arg_single_proc ) +TEST( API, func_lpf_exec_single_call_no_arg_single_proc ) { lpf_err_t rc = LPF_SUCCESS ; rc = lpf_exec( LPF_ROOT, 1, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_exec_single_call_single_arg_dual_proc.c b/tests/functional/func_lpf_exec_single_call_single_arg_dual_proc.cpp similarity index 73% rename from tests/functional/func_lpf_exec_single_call_single_arg_dual_proc.c rename to tests/functional/func_lpf_exec_single_call_single_arg_dual_proc.cpp index ce0dc926..c46bf918 100644 --- a/tests/functional/func_lpf_exec_single_call_single_arg_dual_proc.c +++ b/tests/functional/func_lpf_exec_single_call_single_arg_dual_proc.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" @@ -25,18 +25,18 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) lpf; // ignore lpf context variable - EXPECT_EQ( "%d", 2, nprocs ); + EXPECT_EQ( 2, nprocs ); if ( 0 == pid ) { - EXPECT_EQ( "%d", 1, * (int *) args.input ); + EXPECT_EQ( 1, * (int *) args.input ); *(int *) args.output = 1; } else { - EXPECT_EQ( "%zd", (size_t) 0, args.input_size ); - EXPECT_EQ( "%zd", (size_t) 0, args.output_size ); - EXPECT_EQ( "%p", (void *) NULL, args.input ); - EXPECT_EQ( "%p", (void *) NULL, args.output ); + EXPECT_EQ( (size_t) 0, args.input_size ); + EXPECT_EQ( (size_t) 0, args.output_size ); + EXPECT_EQ( (void *) NULL, args.input ); + EXPECT_EQ( (void *) NULL, args.output ); } } @@ -46,7 +46,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_lpf_exec_single_call_single_arg_dual_proc ) +TEST( API, func_lpf_exec_single_call_single_arg_dual_proc ) { lpf_err_t rc = LPF_SUCCESS; int input = 1; @@ -59,8 +59,7 @@ TEST( func_lpf_exec_single_call_single_arg_dual_proc ) args.f_size = 0; args.f_symbols = NULL; rc = lpf_exec( LPF_ROOT, 2, &spmd, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%d", 1, output ); - return 0; + EXPECT_EQ( 1, output ); } diff --git a/tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_one.c b/tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_one.cpp similarity index 66% rename from tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_one.c rename to tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_one.cpp index 131297e9..5b11470e 100644 --- a/tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_one.c +++ b/tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_one.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" @@ -25,53 +25,54 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) lpf; // ignore lpf context variable lpf_err_t rc = LPF_SUCCESS; - int a[2] = { pid, -1 }; + lpf_pid_t a[2] = { pid, LPF_MAX_P }; lpf_memslot_t aSlot = LPF_INVALID_MEMSLOT; - EXPECT_LE( "%d", 2, nprocs ); + EXPECT_LE( 2, nprocs ); + EXPECT_LT( pid, LPF_MAX_P ); if ( 0 == pid ) { - EXPECT_EQ( "%zd", (size_t) sizeof(int), args.input_size ); - EXPECT_EQ( "%zd", (size_t) sizeof(int), args.output_size ); - EXPECT_EQ( "%d", 1, * (int *) args.input ); + EXPECT_EQ( (size_t) sizeof(int), args.input_size ); + EXPECT_EQ( (size_t) sizeof(int), args.output_size ); + EXPECT_EQ( 1, * (int *) args.input ); } else { - EXPECT_EQ( "%zd", (size_t) 0, args.input_size ); - EXPECT_EQ( "%zd", (size_t) 0, args.output_size ); - EXPECT_EQ( "%p", (void *) NULL, args.input ); - EXPECT_EQ( "%p", (void *) NULL, args.output ); + EXPECT_EQ( (size_t) 0, args.input_size ); + EXPECT_EQ( (size_t) 0, args.output_size ); + EXPECT_EQ(( void *) NULL, args.input ); + EXPECT_EQ( (void *) NULL, args.output ); } // perform a simple communication rc = lpf_resize_message_queue( lpf, 2); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 1 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf , LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &a, sizeof(a), &aSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf , LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, aSlot, 0, (pid+1) % nprocs, aSlot, sizeof(a[0]), sizeof(a[0]), LPF_MSG_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf , LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%d", a[0], (int) pid ); - EXPECT_EQ( "%d", a[1], (int) ((pid+nprocs-1) % nprocs) ); + EXPECT_EQ( a[0], (int) pid ); + EXPECT_EQ( a[1], (int) ((pid+nprocs-1) % nprocs) ); rc = lpf_deregister( lpf, aSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // now, all other processes except 'one' perform an extra sync. if ( 1 != pid ) { rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_ERR_FATAL, rc ); + EXPECT_EQ( LPF_ERR_FATAL, rc ); } // It is still possible to send output through the args @@ -87,7 +88,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_lpf_exec_single_call_single_arg_max_proc_early_exit_one ) +TEST( API, func_lpf_exec_single_call_single_arg_max_proc_early_exit_one ) { lpf_err_t rc = LPF_SUCCESS; int input = 1; @@ -100,8 +101,7 @@ TEST( func_lpf_exec_single_call_single_arg_max_proc_early_exit_one ) args.f_size = 0; args.f_symbols = NULL; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, args ); - EXPECT_EQ( "%d", LPF_ERR_FATAL , rc ); + EXPECT_EQ( LPF_ERR_FATAL , rc ); - EXPECT_EQ( "%d", 2, output ); - return 0; + EXPECT_EQ( 2, output ); } diff --git a/tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero.c b/tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero.cpp similarity index 68% rename from tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero.c rename to tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero.cpp index d84b77ad..40e1afee 100644 --- a/tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero.c +++ b/tests/functional/func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" @@ -25,23 +25,23 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) lpf; // ignore lpf context variable - EXPECT_LE( "%d", 2, nprocs ); + EXPECT_LE( 2, nprocs ); if ( 0 == pid ) { - EXPECT_EQ( "%zd", (size_t) sizeof(int), args.input_size ); - EXPECT_EQ( "%zd", (size_t) sizeof(int), args.output_size ); - EXPECT_EQ( "%d", 1, * (int *) args.input ); + EXPECT_EQ( (size_t) sizeof(int), args.input_size ); + EXPECT_EQ( (size_t) sizeof(int), args.output_size ); + EXPECT_EQ( 1, * (int *) args.input ); *(int *) args.output = 2; } else { - EXPECT_EQ( "%zd", (size_t) 0, args.input_size ); - EXPECT_EQ( "%zd", (size_t) 0, args.output_size ); - EXPECT_EQ( "%p", (void *) NULL, args.input ); - EXPECT_EQ( "%p", (void *) NULL, args.output ); + EXPECT_EQ( (size_t) 0, args.input_size ); + EXPECT_EQ( (size_t) 0, args.output_size ); + EXPECT_EQ( (void *) NULL, args.input ); + EXPECT_EQ( (void *) NULL, args.output ); lpf_err_t rc = lpf_sync(lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_ERR_FATAL, rc ); + EXPECT_EQ( LPF_ERR_FATAL, rc ); } } @@ -51,7 +51,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero ) +TEST( API, func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero ) { lpf_err_t rc = LPF_SUCCESS; int input = 1; @@ -64,8 +64,7 @@ TEST( func_lpf_exec_single_call_single_arg_max_proc_early_exit_zero ) args.f_size = 0; args.f_symbols = NULL; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, args ); - EXPECT_EQ( "%d", LPF_ERR_FATAL, rc ); + EXPECT_EQ( LPF_ERR_FATAL, rc ); - EXPECT_EQ( "%d", 2, output ); - return 0; + EXPECT_EQ( 2, output ); } diff --git a/tests/functional/func_lpf_exec_single_call_single_arg_single_proc.c b/tests/functional/func_lpf_exec_single_call_single_arg_single_proc.cpp similarity index 79% rename from tests/functional/func_lpf_exec_single_call_single_arg_single_proc.c rename to tests/functional/func_lpf_exec_single_call_single_arg_single_proc.cpp index 93493e9b..b1d9491b 100644 --- a/tests/functional/func_lpf_exec_single_call_single_arg_single_proc.c +++ b/tests/functional/func_lpf_exec_single_call_single_arg_single_proc.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #define SAMPLE_INPUT_ARG "This is an input argument" #define SAMPLE_INPUT_ARG_LENGTH 10 @@ -29,10 +29,10 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) lpf; // ignore lpf context variable - EXPECT_EQ( "%d", 1, (int) nprocs ); - EXPECT_EQ( "%d", 0, (int) pid); + EXPECT_EQ( 1, (int) nprocs ); + EXPECT_EQ( 0, (int) pid); - EXPECT_EQ( "%d", 0, memcmp( args.input, SAMPLE_INPUT_ARG, SAMPLE_INPUT_ARG_LENGTH ) ); + EXPECT_EQ( 0, memcmp( args.input, SAMPLE_INPUT_ARG, SAMPLE_INPUT_ARG_LENGTH ) ); memcpy( args.output, SAMPLE_OUTPUT_ARG, SAMPLE_OUTPUT_ARG_LENGTH ); } @@ -42,7 +42,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_exec_single_call_single_arg_single_proc ) +TEST( API, func_lpf_exec_single_call_single_arg_single_proc ) { lpf_err_t rc = LPF_SUCCESS; char input_arg[] = SAMPLE_INPUT_ARG; @@ -56,8 +56,7 @@ TEST( func_lpf_exec_single_call_single_arg_single_proc ) args.f_size = 0; rc = lpf_exec( LPF_ROOT, 1, &spmd, args ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); - EXPECT_EQ( "%d", 0, memcmp( args.output, SAMPLE_OUTPUT_ARG, SAMPLE_OUTPUT_ARG_LENGTH ) ); - return 0; + EXPECT_EQ( 0, memcmp( args.output, SAMPLE_OUTPUT_ARG, SAMPLE_OUTPUT_ARG_LENGTH ) ); } diff --git a/tests/functional/func_lpf_get_parallel_alltoall.c b/tests/functional/func_lpf_get_parallel_alltoall.cpp similarity index 73% rename from tests/functional/func_lpf_get_parallel_alltoall.c rename to tests/functional/func_lpf_get_parallel_alltoall.cpp index 4166a705..2bb96d12 100644 --- a/tests/functional/func_lpf_get_parallel_alltoall.c +++ b/tests/functional/func_lpf_get_parallel_alltoall.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,8 +26,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const int n = nprocs; int i; int * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); + ys = (int *) malloc( sizeof(ys[0]) * n); + xs = (int *) malloc( sizeof(xs[0]) * n); for (i = 0; i < n; ++i) { xs[i] = i; @@ -35,28 +35,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = lpf_resize_message_queue( lpf, 2*nprocs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_global( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Check that data is OK. for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", i, xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( i, xs[i] ); + EXPECT_EQ( 0, ys[i] ); } // Do an all-to-all which is like transposing a matrix @@ -66,24 +66,24 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_get( lpf, i, xslot, sizeof(xs[0])*pid, yslot, sizeof(ys[0])*i, sizeof(xs[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", i, xs[i] ); - EXPECT_EQ( "%d", (int) pid, ys[i] ); + EXPECT_EQ( i, xs[i] ); + EXPECT_EQ( (int) pid, ys[i] ); } rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -91,9 +91,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_get_parallel_alltoall ) +TEST( API, func_lpf_get_parallel_alltoall ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_get_parallel_huge.c b/tests/functional/func_lpf_get_parallel_huge.cpp similarity index 73% rename from tests/functional/func_lpf_get_parallel_huge.c rename to tests/functional/func_lpf_get_parallel_huge.cpp index 3d42b3b4..ce9283d9 100644 --- a/tests/functional/func_lpf_get_parallel_huge.c +++ b/tests/functional/func_lpf_get_parallel_huge.cpp @@ -18,31 +18,31 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { (void) args; // ignore args parameter lpf_err_t rc = LPF_SUCCESS; - EXPECT_EQ("%d", 2, nprocs); + EXPECT_EQ( 2, nprocs); size_t maxMsgs = 1 , maxRegs = 2; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); size_t huge = (size_t) 10 + INT_MAX; // if this overflows, it means that // size_t fits in 'int' and so this // test is pointless - int *x = calloc( huge , sizeof(int)); - int *y = calloc( huge, sizeof(int)); + int *x = (int *) calloc( huge , sizeof(int)); + int *y = (int *) calloc( huge, sizeof(int)); - EXPECT_NE( "%p", (int *) NULL, x ); - EXPECT_NE( "%p", (int *) NULL, y ); + EXPECT_NE( (int *) NULL, x ); + EXPECT_NE( (int *) NULL, y ); size_t i; for (i = 0; i -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -27,8 +27,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const int n = nprocs*MTU; int i; int * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); + ys = (int *) malloc( sizeof(ys[0]) * n); + xs = (int *) malloc( sizeof(xs[0]) * n); for (i = 0; i < n; ++i) { xs[i] = i*n + pid; @@ -36,28 +36,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = lpf_resize_message_queue( lpf, nprocs + 1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_global( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Check that data is OK. for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) (i*n+pid), xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( (int) (i*n+pid), xs[i] ); + EXPECT_EQ( 0, ys[i] ); } // processor zero gets data from each processor. @@ -68,12 +68,12 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_get( lpf, i, xslot, 0u, yslot, 0u, sizeof(xs[0]) * n, LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if ( 0 == pid ) { @@ -81,8 +81,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) int delta = ys[0] - xs[0]; for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) ( i*n + pid), xs[i] ); - EXPECT_EQ( "%d", delta, ys[i] - xs[i] ); + EXPECT_EQ( (int) ( i*n + pid), xs[i] ); + EXPECT_EQ( delta, ys[i] - xs[i] ); } } else @@ -90,16 +90,16 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // on the other processors nothing has been written for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) ( i*n + pid), xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( (int) ( i*n + pid), xs[i] ); + EXPECT_EQ( 0, ys[i] ); } } rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -107,9 +107,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_get_parallel_overlapping_complete ) +TEST( API, func_lpf_get_parallel_overlapping_complete ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_get_parallel_overlapping_pyramid.c b/tests/functional/func_lpf_get_parallel_overlapping_pyramid.cpp similarity index 74% rename from tests/functional/func_lpf_get_parallel_overlapping_pyramid.c rename to tests/functional/func_lpf_get_parallel_overlapping_pyramid.cpp index 8b10b06b..7c29336f 100644 --- a/tests/functional/func_lpf_get_parallel_overlapping_pyramid.c +++ b/tests/functional/func_lpf_get_parallel_overlapping_pyramid.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,8 +26,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const size_t n = 2*nprocs*MTU; size_t i; int * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); + ys = (int *) malloc( sizeof(ys[0]) * n); + xs = (int *) malloc( sizeof(xs[0]) * n); for (i = 0; i < n; ++i) { xs[i] = i*n + pid; @@ -35,28 +35,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = lpf_resize_message_queue( lpf, nprocs+1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_global( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Check that data is OK. for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) (i*n+pid), xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( (int) (i*n+pid), xs[i] ); + EXPECT_EQ( 0, ys[i] ); } // processor zero gets the data from all other processors @@ -69,13 +69,13 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_get( lpf, i, xslot, start*MTU*sizeof(xs[0]), yslot, start*MTU*sizeof(xs[0]), (end-start)*MTU*sizeof(xs[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if ( 0 == pid ) { @@ -101,19 +101,19 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // check the contents of a block size_t pid1 = ys[i] - xs[i]; size_t pid2 = ys[n-i-1] - xs[n-i-1]; - EXPECT_EQ( "%zu", pid1, pid2 ); - EXPECT_LE( "%zu", pid1, i ); - EXPECT_LE( "%zu", pid1, n-i-1 ); + EXPECT_EQ( pid1, pid2 ); + EXPECT_LE( pid1, i ); + EXPECT_LE( pid1, n-i-1 ); - EXPECT_LE( "%d", (int) pid1, (int) nprocs); + EXPECT_LE( (int) pid1, (int) nprocs); // check that all values in the block are from the same processor size_t j; for (j = 0; j < MTU; ++j) { - EXPECT_EQ( "%d", (int) pid1, ys[i+j] - xs[i+j]); - EXPECT_EQ( "%d", (int) pid1, ys[n-i-1-j] - xs[n-i-1-j] ); + EXPECT_EQ( (int) pid1, ys[i+j] - xs[i+j]); + EXPECT_EQ( (int) pid1, ys[n-i-1-j] - xs[n-i-1-j] ); } } } @@ -122,16 +122,16 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // on the other processors nothing has changed for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) ( i*n + pid), xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( (int) ( i*n + pid), xs[i] ); + EXPECT_EQ( 0, ys[i] ); } } rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -139,9 +139,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_get_parallel_overlapping_pyramid ) +TEST( API, func_lpf_get_parallel_overlapping_pyramid ) { lpf_err_t rc =lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_get_parallel_overlapping_rooftiling.c b/tests/functional/func_lpf_get_parallel_overlapping_rooftiling.cpp similarity index 74% rename from tests/functional/func_lpf_get_parallel_overlapping_rooftiling.c rename to tests/functional/func_lpf_get_parallel_overlapping_rooftiling.cpp index 865854a7..0e083ee2 100644 --- a/tests/functional/func_lpf_get_parallel_overlapping_rooftiling.c +++ b/tests/functional/func_lpf_get_parallel_overlapping_rooftiling.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -29,8 +29,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const size_t n = 5*nprocs*MTU; size_t i; uint64_t * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); + ys = (uint64_t *) malloc( sizeof(ys[0]) * n); + xs = (uint64_t *) malloc( sizeof(xs[0]) * n); for (i = 0; i < n; ++i) { xs[i] = i*nprocs + pid; @@ -38,28 +38,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = lpf_resize_message_queue( lpf, nprocs+1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_global( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Check that data is OK. for (i = 0; i < n; ++i) { - EXPECT_EQ( "%" PRIu64, (uint64_t) (i*nprocs+pid), xs[i] ); - EXPECT_EQ( "%" PRIu64, (uint64_t) 0, ys[i] ); + EXPECT_EQ( (uint64_t) (i*nprocs+pid), xs[i] ); + EXPECT_EQ( (uint64_t) 0, ys[i] ); } // Each processor copies his row to processor zero. @@ -73,13 +73,13 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_get( lpf, i, xslot, start*sizeof(xs[0])*MTU, yslot, offset*sizeof(xs[0])*MTU, length*sizeof(xs[0])*MTU, LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if ( 0 == pid ) { @@ -115,32 +115,33 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) uint64_t fromPid2 = ys[ (4*i+j) * MTU + k] - xs[(4*i+j + offset) * MTU + k]; fromPid2 = (fromPid2 + nprocs*MTU)%nprocs; - EXPECT_EQ( "%" PRIu64, fromPid, fromPid2 ); + EXPECT_EQ( fromPid, fromPid2 ); - if (fromPid == i) - EXPECT_EQ( "%" PRIu64, (5*i+j)*nprocs*MTU + fromPid, ys[(4*i+j)*MTU] ); + if (fromPid == i) { + EXPECT_EQ( (5*i+j)*nprocs*MTU + fromPid, ys[(4*i+j)*MTU] ); + } } if (0 == j && i > 0) { - EXPECT_EQ( "%d", 1, fromPid == i || fromPid == i-1 ); + EXPECT_EQ( 1, fromPid == i || fromPid == i-1 ); } else if (4 == j && i < nprocs-1) { - EXPECT_EQ( "%d", 1, fromPid == i || fromPid == i+1 ); + EXPECT_EQ( 1, fromPid == i || fromPid == i+1 ); } else { - EXPECT_EQ( "%" PRIu64, fromPid, (uint64_t) i ); + EXPECT_EQ( fromPid, (uint64_t) i ); } } offset += 1; } - EXPECT_EQ("%d", (int) nprocs, offset ); + EXPECT_EQ( (int) nprocs, offset ); // the rest of the ys array should be zero for (i = 0; i < (nprocs - 1) * MTU; ++i) { - EXPECT_EQ("%" PRIu64, (uint64_t) 0, ys[n-i-1]); + EXPECT_EQ( (uint64_t) 0, ys[n-i-1]); } } else @@ -148,16 +149,16 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // on the other processors nothing has changed for (i = 0; i < n; ++i) { - EXPECT_EQ( "%" PRIu64, (uint64_t) ( i*nprocs + pid), xs[i] ); - EXPECT_EQ( "%" PRIu64, (uint64_t) 0, ys[i] ); + EXPECT_EQ( (uint64_t) ( i*nprocs + pid), xs[i] ); + EXPECT_EQ( (uint64_t) 0, ys[i] ); } } rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -165,9 +166,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_get_parallel_overlapping_rooftiling ) +TEST( API, func_lpf_get_parallel_overlapping_rooftiling ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_get_parallel_single.c b/tests/functional/func_lpf_get_parallel_single.cpp similarity index 74% rename from tests/functional/func_lpf_get_parallel_single.c rename to tests/functional/func_lpf_get_parallel_single.cpp index 5ab4657c..436ebdd7 100644 --- a/tests/functional/func_lpf_get_parallel_single.c +++ b/tests/functional/func_lpf_get_parallel_single.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,39 +26,39 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) size_t maxMsgs = 2 , maxRegs = 2; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); int x = 5, y = 10; lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_global( lpf, &x, sizeof(x), &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( lpf, &y, sizeof(y), &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%d", 10, y); + EXPECT_EQ( 10, y); rc = lpf_get( lpf, (pid+1)%nprocs, xslot, 0, yslot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%d", 5, y); + EXPECT_EQ( 5, y); rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -66,9 +66,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_get_parallel_single ) +TEST( API, func_lpf_get_parallel_single ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_hook_simple.mpirma.c b/tests/functional/func_lpf_hook_simple.mpirma.cpp similarity index 76% rename from tests/functional/func_lpf_hook_simple.mpirma.c rename to tests/functional/func_lpf_hook_simple.mpirma.cpp index 5dfa7104..81016a39 100644 --- a/tests/functional/func_lpf_hook_simple.mpirma.c +++ b/tests/functional/func_lpf_hook_simple.mpirma.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -28,11 +28,11 @@ void spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_err_t rc = LPF_SUCCESS; rc = lpf_resize_message_queue( ctx, 2); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_sync(ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); int x = 5 - pid; int y = pid; @@ -41,21 +41,21 @@ void spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; rc = lpf_register_global( ctx, &x, sizeof(x), &xSlot ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_register_global( ctx, &y, sizeof(y), &ySlot ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_put( ctx, xSlot, 0, (pid + 1) % nprocs, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); - EXPECT_EQ( "%d", x, (int) (5 - pid) ); - EXPECT_EQ( "%d", y, (int) (5 - (pid + nprocs -1) % nprocs) ); + EXPECT_EQ( x, (int) (5 - pid) ); + EXPECT_EQ( y, (int) (5 - (pid + nprocs -1) % nprocs) ); } // disable automatic initialization. @@ -66,7 +66,7 @@ const int LPF_MPI_AUTO_INITIALIZE=0; * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_hook_simple_mpi ) +TEST(API, func_lpf_hook_simple_mpi) { lpf_err_t rc = LPF_SUCCESS; MPI_Init(NULL, NULL); @@ -79,16 +79,15 @@ TEST( func_lpf_hook_simple_mpi ) lpf_init_t init; rc = lpf_mpi_initialize_with_mpicomm( MPI_COMM_WORLD, &init); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_hook( init, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_mpi_finalize( init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); MPI_Finalize(); - return 0; } diff --git a/tests/functional/func_lpf_hook_simple.pthread.c b/tests/functional/func_lpf_hook_simple.pthread.cpp similarity index 72% rename from tests/functional/func_lpf_hook_simple.pthread.c rename to tests/functional/func_lpf_hook_simple.pthread.cpp index 3b33bdc6..6438b676 100644 --- a/tests/functional/func_lpf_hook_simple.pthread.c +++ b/tests/functional/func_lpf_hook_simple.pthread.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -36,18 +36,18 @@ struct thread_local_data { void lpf_spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) ctx; - const struct thread_local_data * const data = pthread_getspecific( pid_key ); - - EXPECT_EQ( "%zd", (size_t)nprocs, (size_t)(data->P) ); - EXPECT_EQ( "%zd", (size_t)pid, (size_t)(data->s) ); - EXPECT_EQ( "%zd", (size_t)(args.input_size), (size_t)(sizeof( struct thread_local_data)) ); - EXPECT_EQ( "%zd", (size_t)(args.output_size), (size_t)0 ); - EXPECT_EQ( "%p", args.input, data ); - EXPECT_EQ( "%p", args.output, NULL ); + const struct thread_local_data * const data = static_cast(pthread_getspecific( pid_key )); + + EXPECT_EQ( (size_t)nprocs, (size_t)(data->P) ); + EXPECT_EQ( (size_t)pid, (size_t)(data->s) ); + EXPECT_EQ( (size_t)(args.input_size), (size_t)(sizeof( struct thread_local_data)) ); + EXPECT_EQ( (size_t)(args.output_size), (size_t)0 ); + EXPECT_EQ( args.input, data ); + EXPECT_EQ( args.output, nullptr ); } void * pthread_spmd( void * _data ) { - EXPECT_NE( "%p", _data, NULL ); + EXPECT_NE( _data, nullptr); const struct thread_local_data data = * ((struct thread_local_data*) _data); const int pts_rc = pthread_setspecific( pid_key, _data ); @@ -61,20 +61,20 @@ void * pthread_spmd( void * _data ) { lpf_init_t init; lpf_err_t rc = LPF_SUCCESS; - EXPECT_EQ( "%d", pts_rc, 0 ); + EXPECT_EQ( pts_rc, 0 ); rc = lpf_pthread_initialize( (lpf_pid_t)data.s, (lpf_pid_t)data.P, &init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_hook( init, &lpf_spmd, args ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_pthread_finalize( init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); return NULL; } @@ -85,36 +85,35 @@ void * pthread_spmd( void * _data ) { * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_hook_simple_pthread ) +TEST(API, func_lpf_hook_simple_pthread ) { long k = 0; const long P = sysconf( _SC_NPROCESSORS_ONLN ); const int ptc_rc = pthread_key_create( &pid_key, NULL ); - EXPECT_EQ( "%d", ptc_rc, 0 ); + EXPECT_EQ( ptc_rc, 0 ); pthread_t * const threads = (pthread_t*) malloc( P * sizeof(pthread_t) ); - EXPECT_NE( "%p", threads, NULL ); + EXPECT_NE( threads, nullptr ); struct thread_local_data * const data = (struct thread_local_data*) malloc( P * sizeof(struct thread_local_data) ); - EXPECT_NE( "%p", data, NULL ); + EXPECT_NE( data, nullptr ); for( k = 0; k < P; ++k ) { data[ k ].P = P; data[ k ].s = k; const int rval = pthread_create( threads + k, NULL, &pthread_spmd, data + k ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } for( k = 0; k < P; ++k ) { const int rval = pthread_join( threads[ k ], NULL ); - EXPECT_EQ( "%d", rval, 0 ); + EXPECT_EQ( rval, 0 ); } const int ptd_rc = pthread_key_delete( pid_key ); - EXPECT_EQ( "%d", ptd_rc, 0 ); + EXPECT_EQ( ptd_rc, 0 ); - return 0; } diff --git a/tests/functional/func_lpf_hook_subset.mpimsg.c b/tests/functional/func_lpf_hook_subset.mpimsg.cpp similarity index 92% rename from tests/functional/func_lpf_hook_subset.mpimsg.c rename to tests/functional/func_lpf_hook_subset.mpimsg.cpp index f073e443..6693bab3 100644 --- a/tests/functional/func_lpf_hook_subset.mpimsg.c +++ b/tests/functional/func_lpf_hook_subset.mpimsg.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include @@ -39,10 +39,10 @@ void subset_func(MPI_Comm comm) lpf_init_t init; lpf_err_t rc = lpf_mpi_initialize_with_mpicomm(comm, &init); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_hook(init, test_spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -50,7 +50,7 @@ void subset_func(MPI_Comm comm) * \pre P >= 3 * \return Exit code: 0 */ -TEST( func_lpf_hook_subset ) +TEST(API, func_lpf_hook_subset ) { MPI_Init(NULL, NULL); @@ -71,5 +71,5 @@ TEST( func_lpf_hook_subset ) MPI_Barrier(MPI_COMM_WORLD); // Paranoid barrier MPI_Finalize(); - return 0; + } diff --git a/tests/functional/func_lpf_hook_tcp.mpirma.c b/tests/functional/func_lpf_hook_tcp.mpirma.cpp similarity index 71% rename from tests/functional/func_lpf_hook_tcp.mpirma.c rename to tests/functional/func_lpf_hook_tcp.mpirma.cpp index 2921e6fc..0d7f0290 100644 --- a/tests/functional/func_lpf_hook_tcp.mpirma.c +++ b/tests/functional/func_lpf_hook_tcp.mpirma.cpp @@ -17,28 +17,35 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include #include +static int myargc; +static char **myargv; + +// disable automatic initialization. +const int LPF_MPI_AUTO_INITIALIZE=0; + + void spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { lpf_err_t rc = LPF_SUCCESS; struct { int pid, nprocs; } params; - EXPECT_EQ( "%lu", sizeof(params), args.input_size ); + EXPECT_EQ( sizeof(params), args.input_size ); memcpy( ¶ms, args.input, sizeof(params)); - EXPECT_EQ( "%u", (lpf_pid_t) params.pid, pid ); - EXPECT_EQ( "%u", (lpf_pid_t) params.nprocs, nprocs ); + EXPECT_EQ( (lpf_pid_t) params.pid, pid ); + EXPECT_EQ( (lpf_pid_t) params.nprocs, nprocs ); rc = lpf_resize_message_queue( ctx, 2); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, 2); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_sync(ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); int x = 5 - pid; int y = pid; @@ -47,25 +54,23 @@ void spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; rc = lpf_register_global( ctx, &x, sizeof(x), &xSlot ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_register_global( ctx, &y, sizeof(y), &ySlot ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_put( ctx, xSlot, 0, (pid + 1) % nprocs, ySlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); - EXPECT_EQ( "%d", x, (int) (5 - pid) ); - EXPECT_EQ( "%d", y, (int) (5 - (pid + nprocs -1) % nprocs) ); + EXPECT_EQ( x, (int) (5 - pid) ); + EXPECT_EQ( y, (int) (5 - (pid + nprocs -1) % nprocs) ); } -// disable automatic initialization. -const int LPF_MPI_AUTO_INITIALIZE=0; /** * \test Tests lpf_hook on mpi implementation using TCP/IP to initialize. The pids and nprocs are checked for their correctness. @@ -73,15 +78,14 @@ const int LPF_MPI_AUTO_INITIALIZE=0; * \return Exit code: 0 * \note Independent processes: yes */ -TEST( func_lpf_hook_tcp ) +TEST( API, func_lpf_hook_tcp_mpirma ) { lpf_err_t rc = LPF_SUCCESS; - MPI_Init(&argc, &argv); struct { int pid, nprocs; } params = { 0, 0}; - EXPECT_GT("%d", argc, 2 ); - params.pid = atoi( argv[1] ); - params.nprocs = atoi( argv[2] ); + EXPECT_GT( myargc, 2 ); + params.pid = atoi( myargv[1] ); + params.nprocs = atoi( myargv[2] ); lpf_init_t init; rc = lpf_mpi_initialize_over_tcp( @@ -89,7 +93,7 @@ TEST( func_lpf_hook_tcp ) params.pid, params.nprocs, &init); // let e.g. Intel MPI try a few // alternative fabrics - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); lpf_args_t args; args.input = ¶ms; @@ -100,13 +104,20 @@ TEST( func_lpf_hook_tcp ) args.f_size = 0; rc = lpf_hook( init, &spmd, args ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); rc = lpf_mpi_finalize( init ); - EXPECT_EQ( "%d", rc, LPF_SUCCESS ); + EXPECT_EQ( rc, LPF_SUCCESS ); MPI_Finalize(); - return 0; +} + +int main(int argc, char **argv) { + myargc = argc; + myargv = argv; + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); + } diff --git a/tests/functional/func_lpf_hook_tcp_timeout.mpirma.c b/tests/functional/func_lpf_hook_tcp_timeout.mpirma.cpp similarity index 91% rename from tests/functional/func_lpf_hook_tcp_timeout.mpirma.c rename to tests/functional/func_lpf_hook_tcp_timeout.mpirma.cpp index e8aba501..94d3edd6 100644 --- a/tests/functional/func_lpf_hook_tcp_timeout.mpirma.c +++ b/tests/functional/func_lpf_hook_tcp_timeout.mpirma.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -31,7 +31,7 @@ const int LPF_MPI_AUTO_INITIALIZE=0; * \pre P <= 100 * \return Exit code: 1 */ -TEST( func_lpf_hook_tcp_timeout_mpi ) +TEST(API, func_lpf_hook_tcp_timeout_mpi ) { MPI_Init(NULL, NULL); @@ -45,9 +45,8 @@ TEST( func_lpf_hook_tcp_timeout_mpi ) "localhost", "9325", 999, pid, nprocs, &init); - EXPECT_EQ( "%d", rc, LPF_ERR_FATAL ); + EXPECT_EQ( rc, LPF_ERR_FATAL ); - return 0; } diff --git a/tests/functional/func_lpf_probe_parallel_full.c b/tests/functional/func_lpf_probe_parallel_full.cpp similarity index 52% rename from tests/functional/func_lpf_probe_parallel_full.c rename to tests/functional/func_lpf_probe_parallel_full.cpp index 113aa0ca..7bf55696 100644 --- a/tests/functional/func_lpf_probe_parallel_full.c +++ b/tests/functional/func_lpf_probe_parallel_full.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -24,24 +24,24 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) lpf_machine_t subMachine = LPF_INVALID_MACHINE; lpf_err_t rc = lpf_probe( lpf, &subMachine ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%u", nprocs, subMachine.p ); - EXPECT_EQ( "%u", 1u, subMachine.free_p ); - EXPECT_LT( "%g", 0.0, (*(subMachine.g))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.l))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.g))(subMachine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.l))(subMachine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.g))(subMachine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.l))(subMachine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_EQ( nprocs, subMachine.p ); + EXPECT_EQ( 1u, subMachine.free_p ); + EXPECT_LT( 0.0, (*(subMachine.g))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.l))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.g))(subMachine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.l))(subMachine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.g))(subMachine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.l))(subMachine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); if ( 0 == pid ) { lpf_machine_t * machine = (lpf_machine_t * ) args.input; - EXPECT_EQ( "%zd", args.input_size, sizeof(lpf_machine_t) ); + EXPECT_EQ( args.input_size, sizeof(lpf_machine_t) ); - EXPECT_EQ( "%u", nprocs, machine->p ); - EXPECT_EQ( "%u", nprocs, machine->free_p ); + EXPECT_EQ( nprocs, machine->p ); + EXPECT_EQ( nprocs, machine->free_p ); } } @@ -52,24 +52,24 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_probe_parallel_full ) +TEST( API, func_lpf_probe_parallel_full ) { lpf_err_t rc = LPF_SUCCESS; lpf_machine_t machine = LPF_INVALID_MACHINE; rc = lpf_probe( LPF_ROOT, &machine ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_LE( "%u", 1u, machine.p ); - EXPECT_LE( "%u", 1u, machine.free_p ); - EXPECT_LE( "%u", machine.p, machine.free_p ); - EXPECT_LT( "%g", 0.0, (*(machine.g))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.l))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.g))(machine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.l))(machine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.g))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.l))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_LE( 1u, machine.p ); + EXPECT_LE( 1u, machine.free_p ); + EXPECT_LE( machine.p, machine.free_p ); + EXPECT_LT( 0.0, (*(machine.g))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.l))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.g))(machine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.l))(machine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.g))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.l))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); lpf_args_t args; args.input = &machine; @@ -80,7 +80,6 @@ TEST( func_lpf_probe_parallel_full ) args.f_size = 0; rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - return 0; } diff --git a/tests/functional/func_lpf_probe_parallel_nested.c b/tests/functional/func_lpf_probe_parallel_nested.cpp similarity index 59% rename from tests/functional/func_lpf_probe_parallel_nested.c rename to tests/functional/func_lpf_probe_parallel_nested.cpp index bacafad8..f594b7b8 100644 --- a/tests/functional/func_lpf_probe_parallel_nested.c +++ b/tests/functional/func_lpf_probe_parallel_nested.cpp @@ -16,56 +16,56 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd2( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { (void) args; // ignore any arguments passed through call to lpf_exec lpf_err_t rc = lpf_resize_message_queue( lpf, nprocs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 1 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync(lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_machine_t machine[3] = { LPF_INVALID_MACHINE, LPF_INVALID_MACHINE, LPF_INVALID_MACHINE }; lpf_memslot_t machineSlot = LPF_INVALID_MEMSLOT ; rc = lpf_register_global( lpf, &machine[0], sizeof(machine), &machineSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync(lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if ( 0 == pid ) { machine[0] = ((lpf_machine_t * ) args.input)[0]; machine[1] = ((lpf_machine_t * ) args.input)[1]; - EXPECT_EQ( "%zd", args.input_size, 2*sizeof(lpf_machine_t) ); + EXPECT_EQ( args.input_size, 2*sizeof(lpf_machine_t) ); } else { // broadcast machine info rc = lpf_get( lpf, 0, machineSlot, 0, machineSlot, 0, 2*sizeof(machine[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync(lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_probe( lpf, &machine[2] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - - EXPECT_EQ( "%u", machine[0].p, machine[1].p ); - EXPECT_EQ( "%u", machine[0].p, machine[2].p ); - EXPECT_EQ( "%u", 1u, machine[2].free_p ); - EXPECT_LT( "%g", 0.0, (*(machine[2].g))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine[2].l))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine[2].g))(machine[0].p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine[2].l))(machine[0].p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine[2].g))(machine[0].p, (size_t)(-1), LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine[2].l))(machine[0].p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_EQ( LPF_SUCCESS, rc ); + + EXPECT_EQ( machine[0].p, machine[1].p ); + EXPECT_EQ( machine[0].p, machine[2].p ); + EXPECT_EQ( 1u, machine[2].free_p ); + EXPECT_LT( 0.0, (*(machine[2].g))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine[2].l))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine[2].g))(machine[0].p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine[2].l))(machine[0].p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine[2].g))(machine[0].p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine[2].l))(machine[0].p, (size_t)(-1), LPF_SYNC_DEFAULT) ); rc = lpf_deregister( lpf, machineSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) @@ -75,64 +75,64 @@ void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) lpf_pid_t p = 0; lpf_machine_t subMachine; lpf_err_t rc = lpf_probe( lpf, &subMachine ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, nprocs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 1 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync(lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_machine_t machine ; lpf_memslot_t machineSlot = LPF_INVALID_MEMSLOT ; rc = lpf_register_global( lpf, &machine, sizeof(machine), &machineSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync(lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if ( 0 == pid ) { machine = * ( lpf_machine_t * ) args.input; - EXPECT_EQ( "%zd", args.input_size, sizeof(lpf_machine_t) ); + EXPECT_EQ( args.input_size, sizeof(lpf_machine_t) ); } else { // broadcast machine info rc = lpf_get( lpf, 0, machineSlot, 0, machineSlot, 0, sizeof(machine), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync(lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, machineSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Do some checks - EXPECT_EQ( "%u", nprocs, subMachine.p / 2 ); - EXPECT_EQ( "%u", nprocs, machine.p / 2 ); - EXPECT_LT( "%g", 0.0, (*(subMachine.g))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.l))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.g))(machine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.l))(machine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.g))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(subMachine.l))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_EQ( nprocs, subMachine.p / 2 ); + EXPECT_EQ( nprocs, machine.p / 2 ); + EXPECT_LT( 0.0, (*(subMachine.g))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.l))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.g))(machine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.l))(machine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.g))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(subMachine.l))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); const int pthread = 1, mpirma = 1, mpimsg = 1, hybrid = 0, ibverbs=1; (void) pthread; (void) mpirma; (void) mpimsg; (void) hybrid; (void) ibverbs; if (LPF_CORE_IMPL_ID) // this part is disabled for the hybrid implementation, because { // that one doesn't do generic nesting of lpf_exec's - EXPECT_EQ( "%d", 1, subMachine.free_p == 2 || subMachine.free_p == 3 ); + EXPECT_EQ( 1, subMachine.free_p == 2 || subMachine.free_p == 3 ); // compute the sum of all 'free_p' values - lpf_pid_t * vec = malloc(sizeof(lpf_pid_t)*nprocs); - EXPECT_NE( "%p", NULL, vec ); + lpf_pid_t * vec = (lpf_pid_t *) malloc(sizeof(lpf_pid_t)*nprocs); + EXPECT_NE( nullptr, vec ); vec[ pid ] = subMachine.free_p; lpf_memslot_t vecSlot = LPF_INVALID_MEMSLOT; rc = lpf_register_global( lpf, vec, sizeof(lpf_pid_t)*nprocs, &vecSlot); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for (p = 0 ; p < nprocs; ++p) { if ( pid != p ) @@ -140,19 +140,19 @@ void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_put( lpf, vecSlot, pid*sizeof(vec[0]), p, vecSlot, pid*sizeof(vec[0]), sizeof(vec[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, vecSlot ); lpf_pid_t sum = 0; for (p = 0; p < nprocs; ++p) { sum += vec[p]; } - EXPECT_EQ( "%u", sum, machine.p ); - EXPECT_EQ( "%u", sum, subMachine.p ); + EXPECT_EQ( sum, machine.p ); + EXPECT_EQ( sum, subMachine.p ); free(vec); } @@ -164,7 +164,7 @@ void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) args.input = multiMachine; args.input_size = sizeof(multiMachine); rc = lpf_exec( lpf, pid + 3, &spmd2, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } @@ -174,24 +174,24 @@ void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_lpf_probe_parallel_nested ) +TEST( API, func_lpf_probe_parallel_nested ) { lpf_err_t rc = LPF_SUCCESS; lpf_machine_t machine; rc = lpf_probe( LPF_ROOT, &machine ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - - EXPECT_LE( "%u", 1u, machine.p ); - EXPECT_LE( "%u", 1u, machine.free_p ); - EXPECT_LE( "%u", machine.p, machine.free_p ); - EXPECT_LT( "%g", 0.0, (*(machine.g))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.l))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.g))(machine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.l))(machine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.g))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.l))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_EQ( LPF_SUCCESS, rc ); + + EXPECT_LE( 1u, machine.p ); + EXPECT_LE( 1u, machine.free_p ); + EXPECT_LE( machine.p, machine.free_p ); + EXPECT_LT( 0.0, (*(machine.g))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.l))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.g))(machine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.l))(machine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.g))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.l))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); lpf_args_t args; args.input = &machine; @@ -202,7 +202,6 @@ TEST( func_lpf_probe_parallel_nested ) args.f_size = 0; rc = lpf_exec( LPF_ROOT, machine.p / 2, &spmd1, args ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - return 0; } diff --git a/tests/functional/func_lpf_probe_root.c b/tests/functional/func_lpf_probe_root.cpp similarity index 58% rename from tests/functional/func_lpf_probe_root.c rename to tests/functional/func_lpf_probe_root.cpp index 5a655678..32021efa 100644 --- a/tests/functional/func_lpf_probe_root.c +++ b/tests/functional/func_lpf_probe_root.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" /** * \test Test lpf_probe function on LPF_ROOT @@ -24,23 +24,22 @@ * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_probe_root ) +TEST( API, func_lpf_probe_root ) { lpf_err_t rc = LPF_SUCCESS; lpf_machine_t machine = LPF_INVALID_MACHINE; rc = lpf_probe( LPF_ROOT, &machine ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_LE( "%u", 1u, machine.p ); - EXPECT_LE( "%u", 1u, machine.free_p ); - EXPECT_LT( "%g", 0.0, (*(machine.g))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.l))(1, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.g))(machine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.l))(machine.p, 0, LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.g))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); - EXPECT_LT( "%g", 0.0, (*(machine.l))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_LE( 1u, machine.p ); + EXPECT_LE( 1u, machine.free_p ); + EXPECT_LT( 0.0, (*(machine.g))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.l))(1, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.g))(machine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.l))(machine.p, 0, LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.g))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); + EXPECT_LT( 0.0, (*(machine.l))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); - return 0; } diff --git a/tests/functional/func_lpf_put_and_get_overlapping.c b/tests/functional/func_lpf_put_and_get_overlapping.cpp similarity index 74% rename from tests/functional/func_lpf_put_and_get_overlapping.c rename to tests/functional/func_lpf_put_and_get_overlapping.cpp index ffd1b4bb..9eed7708 100644 --- a/tests/functional/func_lpf_put_and_get_overlapping.c +++ b/tests/functional/func_lpf_put_and_get_overlapping.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,8 +26,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const int n = nprocs*MTU; int i; int * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); + ys = (int *) malloc( sizeof(ys[0]) * n); + xs = (int *) malloc( sizeof(xs[0]) * n); for (i = 0; i < n; ++i) { xs[i] = i*n + pid; @@ -35,28 +35,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = lpf_resize_message_queue( lpf, 4*nprocs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_global( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Check that data is OK. for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) (i*n+pid), xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( (int) (i*n+pid), xs[i] ); + EXPECT_EQ( 0, ys[i] ); } // get the block from all processors and also put data to all processors @@ -67,30 +67,30 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_get( lpf, i, xslot, 0u, yslot, 0u, sizeof(xs[0]) * n, LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, xslot, 0u, i, yslot, 0u, sizeof(xs[0]) * n, LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // on all processors the writes have occurred in some sequential order int delta = ys[0] - xs[0]; for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) ( i*n + pid), xs[i] ); - EXPECT_EQ( "%d", delta, ys[i] - xs[i] ); + EXPECT_EQ( (int) ( i*n + pid), xs[i] ); + EXPECT_EQ( delta, ys[i] - xs[i] ); } rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -98,9 +98,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_put_and_get_overlapping ) +TEST( API, func_lpf_put_and_get_overlapping ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_put_parallel_alltoall.c b/tests/functional/func_lpf_put_parallel_alltoall.cpp similarity index 73% rename from tests/functional/func_lpf_put_parallel_alltoall.c rename to tests/functional/func_lpf_put_parallel_alltoall.cpp index 3dafc19a..41e4ee2e 100644 --- a/tests/functional/func_lpf_put_parallel_alltoall.c +++ b/tests/functional/func_lpf_put_parallel_alltoall.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,8 +26,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const int n = nprocs; int i; int * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); + ys = (int *) malloc( sizeof(ys[0]) * n); + xs = (int *) malloc( sizeof(xs[0]) * n); for (i = 0; i < n; ++i) { xs[i] = i; @@ -35,28 +35,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = lpf_resize_message_queue( lpf, 2*nprocs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_local( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Check that data is OK. for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", i, xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( i, xs[i] ); + EXPECT_EQ( 0, ys[i] ); } // Do an all-to-all which is like transposing a matrix @@ -66,24 +66,24 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_put( lpf, xslot, sizeof(xs[0])*i, i, yslot, sizeof(ys[0])*pid, sizeof(xs[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", i, xs[i] ); - EXPECT_EQ( "%d", (int) pid, ys[i] ); + EXPECT_EQ( i, xs[i] ); + EXPECT_EQ( (int) pid, ys[i] ); } rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -91,9 +91,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_put_parallel_alltoall ) +TEST( API, func_lpf_put_parallel_alltoall ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_put_parallel_bad_pattern.c b/tests/functional/func_lpf_put_parallel_bad_pattern.c deleted file mode 100644 index 08756644..00000000 --- a/tests/functional/func_lpf_put_parallel_bad_pattern.c +++ /dev/null @@ -1,101 +0,0 @@ - -/* - * Copyright 2021 Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "Test.h" - -void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) -{ - (void) args; // ignore args parameter - - lpf_err_t rc = LPF_SUCCESS; - const unsigned n = sqrt(nprocs); - unsigned i; - unsigned * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); - for (i = 0; i < n; ++i) - { - xs[i] = i; - ys[i] = 0; - } - - rc = lpf_resize_message_queue( lpf, n); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - - lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; - lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; - rc = lpf_register_local( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - rc = lpf_register_global( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - - // Check that data is OK. - for (i = 0; i < n; ++i) - { - EXPECT_EQ( "%u", i, xs[i] ); - EXPECT_EQ( "%u", 0u, ys[i] ); - } - - if ( pid < n ) - { - for ( i = 0; i < n; ++ i) - { - EXPECT_LT("%u", i*n, nprocs); - rc = lpf_put( lpf, xslot, sizeof(xs[0])*i, - i*n, yslot, sizeof(ys[0])*pid, sizeof(xs[0]), - LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - } - } - - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - - for (i = 0; i < n; ++i) - { - EXPECT_EQ( "%u", i, xs[i] ); - if ( pid % n == 0 && pid < n*n) - EXPECT_EQ( "%u", pid / n, ys[i] ); - else - EXPECT_EQ( "%d", 0, ys[i] ); - } - -} - -/** - * \test Test lpf_put by doing a pattern which bad for a sparse all-to-all - * \pre P >= 1024 - * \pre P <= 1024 - * \return Exit code: 0 - */ -TEST( func_lpf_put_parallel_bad_pattern ) -{ - lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; -} diff --git a/tests/functional/func_lpf_put_parallel_big.c b/tests/functional/func_lpf_put_parallel_big.cpp similarity index 84% rename from tests/functional/func_lpf_put_parallel_big.c rename to tests/functional/func_lpf_put_parallel_big.cpp index af4b3e77..d6f5a93f 100644 --- a/tests/functional/func_lpf_put_parallel_big.c +++ b/tests/functional/func_lpf_put_parallel_big.cpp @@ -22,7 +22,8 @@ #include #include -#include "Test.h" +#include + void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t arg ) { @@ -35,8 +36,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t arg ) const size_t blocksize = 99999; const size_t bufsize = nprocs * blocksize; - char * srcbuf = calloc( bufsize, 1 ); - char * dstbuf = calloc( bufsize, 1 ); + char * srcbuf = (char *) calloc( bufsize, 1 ); + char * dstbuf = (char *) calloc( bufsize, 1 ); lpf_memslot_t srcslot = LPF_INVALID_MEMSLOT; lpf_memslot_t dstslot = LPF_INVALID_MEMSLOT; @@ -44,10 +45,10 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t arg ) lpf_register_global( lpf, srcbuf, bufsize, &srcslot); lpf_register_global( lpf, dstbuf, bufsize, &dstslot); - int try = 0; - for (try = 0; try < 3; ++try ) { + int i = 0; + for (i= 0; i < 3; ++i ) { lpf_err_t rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ) ; - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); size_t dstoffset = 0; size_t srcoffset = 0; unsigned p; @@ -59,7 +60,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t arg ) } lpf_err_t rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ) ; - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_deregister( lpf, srcslot ); lpf_deregister( lpf, dstslot ); @@ -72,13 +73,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t arg ) * \note Extra lpfrun parameters: -max-mpi-msg-size 500 * \return Exit code: 0 */ -TEST( func_lpf_put_parallel_big ) +TEST(API, func_lpf_put_parallel_big) { - (void) argc; - (void) argv; - lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - return 0; } diff --git a/tests/functional/func_lpf_put_parallel_huge.c b/tests/functional/func_lpf_put_parallel_huge.cpp similarity index 73% rename from tests/functional/func_lpf_put_parallel_huge.c rename to tests/functional/func_lpf_put_parallel_huge.cpp index b26d0802..bcb754f8 100644 --- a/tests/functional/func_lpf_put_parallel_huge.c +++ b/tests/functional/func_lpf_put_parallel_huge.cpp @@ -18,31 +18,31 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { (void) args; // ignore args parameter lpf_err_t rc = LPF_SUCCESS; - EXPECT_EQ("%d", 2, nprocs); + EXPECT_EQ( 2, nprocs); size_t maxMsgs = 1 , maxRegs = 2; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); size_t huge = (size_t) 10 + INT_MAX; // if this overflows, it means that // size_t fits in 'int' and so this // test is pointless - int *x = calloc( huge , sizeof(int)); - int *y = calloc( huge, sizeof(int)); + int *x = (int *) calloc( huge , sizeof(int)); + int *y = (int *) calloc( huge, sizeof(int)); - EXPECT_NE( "%p", (int *) NULL, x ); - EXPECT_NE( "%p", (int *) NULL, y ); + EXPECT_NE( (int *) NULL, x ); + EXPECT_NE( (int *) NULL, y ); size_t i; for (i = 0; i -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,8 +26,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const int n = MTU*nprocs; int i; int * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); + ys = (int *) malloc( sizeof(ys[0]) * n); + xs = (int *) malloc( sizeof(xs[0]) * n); for (i = 0; i < n; ++i) { xs[i] = i*n + pid; @@ -35,39 +35,39 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = lpf_resize_message_queue( lpf, nprocs+1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_local( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Check that data is OK. for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", i*n + (int) pid, xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( i*n + (int) pid, xs[i] ); + EXPECT_EQ( 0, ys[i] ); } // Each processor copies his row to processor zero. rc = lpf_put( lpf, xslot, 0u, 0, yslot, 0u, sizeof(xs[0]) * n, LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if ( 0 == pid ) { @@ -75,8 +75,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) int delta = ys[0] - xs[0]; for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) ( i*n + pid), xs[i] ); - EXPECT_EQ( "%d", delta, ys[i] - xs[i] ); + EXPECT_EQ( (int) ( i*n + pid), xs[i] ); + EXPECT_EQ( delta, ys[i] - xs[i] ); } } else @@ -84,15 +84,15 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // on the other processors nothing has been written for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) ( i*n + pid), xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( (int) ( i*n + pid), xs[i] ); + EXPECT_EQ( 0, ys[i] ); } } rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -100,9 +100,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_put_parallel_overlapping_complete ) +TEST( API, func_lpf_put_parallel_overlapping_complete ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_put_parallel_overlapping_pyramid.c b/tests/functional/func_lpf_put_parallel_overlapping_pyramid.cpp similarity index 74% rename from tests/functional/func_lpf_put_parallel_overlapping_pyramid.c rename to tests/functional/func_lpf_put_parallel_overlapping_pyramid.cpp index 690ebaf5..91f57753 100644 --- a/tests/functional/func_lpf_put_parallel_overlapping_pyramid.c +++ b/tests/functional/func_lpf_put_parallel_overlapping_pyramid.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,8 +26,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const size_t n = 2*nprocs*MTU; size_t i; int * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); + ys = (int *) malloc( sizeof(ys[0]) * n); + xs = (int *) malloc( sizeof(xs[0]) * n); for (i = 0; i < n; ++i) { xs[i] = i*n + pid; @@ -35,28 +35,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = lpf_resize_message_queue( lpf, nprocs + 1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_local( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Check that data is OK. for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) (i*n+pid), xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( (int) (i*n+pid), xs[i] ); + EXPECT_EQ( 0, ys[i] ); } // Each processor copies his row to processor zero. @@ -65,11 +65,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_put( lpf, xslot, start*MTU*sizeof(xs[0]), 0, yslot, start*MTU*sizeof(xs[0]), (end-start)*MTU*sizeof(xs[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if ( 0 == pid ) { @@ -95,19 +95,19 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // check the contents of a block int pid1 = ys[i] - xs[i]; int pid2 = ys[n-i-1] - xs[n-i-1]; - EXPECT_EQ( "%d", pid1, pid2 ); - EXPECT_LE( "%d", pid1, (int) i ); - EXPECT_LE( "%d", pid1, (int) (n-i-1) ); + EXPECT_EQ( pid1, pid2 ); + EXPECT_LE( pid1, (int) i ); + EXPECT_LE( pid1, (int) (n-i-1) ); - EXPECT_LE( "%d", pid1, (int) nprocs); + EXPECT_LE( pid1, (int) nprocs); // check that all values in the block are from the same processor size_t j; for (j = 0; j < MTU; ++j) { - EXPECT_EQ( "%d", pid1, ys[i+j] - xs[i+j]); - EXPECT_EQ( "%d", pid1, ys[n-i-1-j] - xs[n-i-1-j] ); + EXPECT_EQ( pid1, ys[i+j] - xs[i+j]); + EXPECT_EQ( pid1, ys[n-i-1-j] - xs[n-i-1-j] ); } } } @@ -116,16 +116,16 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // on the other processors nothing has changed for (i = 0; i < n; ++i) { - EXPECT_EQ( "%d", (int) ( i*n + pid), xs[i] ); - EXPECT_EQ( "%d", 0, ys[i] ); + EXPECT_EQ( (int) ( i*n + pid), xs[i] ); + EXPECT_EQ( 0, ys[i] ); } } rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -133,9 +133,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_put_parallel_overlapping_pyramid ) +TEST( API, func_lpf_put_parallel_overlapping_pyramid ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_put_parallel_overlapping_rooftiling.c b/tests/functional/func_lpf_put_parallel_overlapping_rooftiling.cpp similarity index 74% rename from tests/functional/func_lpf_put_parallel_overlapping_rooftiling.c rename to tests/functional/func_lpf_put_parallel_overlapping_rooftiling.cpp index 4e08b8eb..dfbb1595 100644 --- a/tests/functional/func_lpf_put_parallel_overlapping_rooftiling.c +++ b/tests/functional/func_lpf_put_parallel_overlapping_rooftiling.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #include #include @@ -30,8 +30,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) const size_t n = 5*nprocs*MTU; size_t i; uint64_t * xs, *ys; - ys = malloc( sizeof(ys[0]) * n); - xs = malloc( sizeof(xs[0]) * n); + ys = (uint64_t *) malloc( sizeof(ys[0]) * n); + xs = (uint64_t *) malloc( sizeof(xs[0]) * n); for (i = 0; i < n; ++i) { xs[i] = i*nprocs + pid; @@ -39,28 +39,28 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } rc = lpf_resize_message_queue( lpf, nprocs+1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_local( lpf, xs, sizeof(xs[0]) * n, &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, ys, sizeof(ys[0]) * n, &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // Check that data is OK. for (i = 0; i < n; ++i) { - EXPECT_EQ( "%" PRIu64, (uint64_t) (i*nprocs+pid), xs[i] ); - EXPECT_EQ( "%" PRIu64, (uint64_t) 0, ys[i] ); + EXPECT_EQ( (uint64_t) (i*nprocs+pid), xs[i] ); + EXPECT_EQ( (uint64_t) 0, ys[i] ); } // Each processor copies his row to processor zero. @@ -71,12 +71,12 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_put( lpf, xslot, start*sizeof(xs[0])*MTU, 0, yslot, offset*sizeof(xs[0])*MTU, length*sizeof(xs[0])*MTU, LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); if ( 0 == pid ) { @@ -112,32 +112,33 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) uint64_t fromPid2 = ys[ (4*i+j) * MTU + k] - xs[(4*i+j + offset) * MTU + k]; fromPid2 = (fromPid2 + nprocs*MTU)%nprocs; - EXPECT_EQ( "%" PRIu64, fromPid, fromPid2 ); + EXPECT_EQ( fromPid, fromPid2 ); - if (fromPid == i) - EXPECT_EQ( "%" PRIu64, (5*i+j)*nprocs*MTU + fromPid, ys[(4*i+j)*MTU] ); + if (fromPid == i) { + EXPECT_EQ( (5*i+j)*nprocs*MTU + fromPid, ys[(4*i+j)*MTU] ); + } } if (0 == j && i > 0) { - EXPECT_EQ( "%d", 1, fromPid == i || fromPid == i-1 ); + EXPECT_EQ( 1, fromPid == i || fromPid == i-1 ); } else if (4 == j && i < nprocs-1) { - EXPECT_EQ( "%d", 1, fromPid == i || fromPid == i+1 ); + EXPECT_EQ( 1, fromPid == i || fromPid == i+1 ); } else { - EXPECT_EQ( "%" PRIu64, fromPid, (uint64_t) i ); + EXPECT_EQ( fromPid, (uint64_t) i ); } } offset += 1; } - EXPECT_EQ("%u", (unsigned) nprocs, offset ); + EXPECT_EQ( (unsigned) nprocs, offset ); // the rest of the ys array should be zero for (i = 0; i < (nprocs-1) * MTU ; ++i) { - EXPECT_EQ("%" PRIu64, (uint64_t) 0, ys[n-i-1]); + EXPECT_EQ( (uint64_t) 0, ys[n-i-1]); } } else @@ -145,16 +146,16 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // on the other processors nothing has changed for (i = 0; i < n; ++i) { - EXPECT_EQ( "%" PRIu64, (uint64_t) ( i*nprocs + pid), xs[i] ); - EXPECT_EQ( "%" PRIu64, (uint64_t) 0, ys[i] ); + EXPECT_EQ( (uint64_t) ( i*nprocs + pid), xs[i] ); + EXPECT_EQ( (uint64_t) 0, ys[i] ); } } rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -162,9 +163,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_put_parallel_overlapping_rooftiling ) +TEST( API, func_lpf_put_parallel_overlapping_rooftiling ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ("%d", LPF_SUCCESS, rc); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc); } diff --git a/tests/functional/func_lpf_put_parallel_single.c b/tests/functional/func_lpf_put_parallel_single.cpp similarity index 74% rename from tests/functional/func_lpf_put_parallel_single.c rename to tests/functional/func_lpf_put_parallel_single.cpp index 9fa85d84..4dcb9d02 100644 --- a/tests/functional/func_lpf_put_parallel_single.c +++ b/tests/functional/func_lpf_put_parallel_single.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -25,38 +25,38 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) size_t maxMsgs = 2 , maxRegs = 2; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); int x = 5, y = 10; lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_local( lpf, &x, sizeof(x), &xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &y, sizeof(y), &yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%d", 10, y); + EXPECT_EQ( 10, y); rc = lpf_put( lpf, xslot, 0, (pid+1)%nprocs, yslot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%d", 5, y); + EXPECT_EQ( 5, y); rc = lpf_deregister( lpf, xslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_deregister( lpf, yslot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -64,9 +64,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_put_parallel_single ) +TEST( API, func_lpf_put_parallel_single ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ("%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_register_and_deregister_irregularly.c b/tests/functional/func_lpf_register_and_deregister_irregularly.cpp similarity index 76% rename from tests/functional/func_lpf_register_and_deregister_irregularly.c rename to tests/functional/func_lpf_register_and_deregister_irregularly.cpp index 0047bfcd..890b8e1e 100644 --- a/tests/functional/func_lpf_register_and_deregister_irregularly.c +++ b/tests/functional/func_lpf_register_and_deregister_irregularly.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -28,13 +28,13 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) size_t maxMsgs = 0 , maxRegs = 16; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - char buffer[16] = "abcdefghijklmnop"; + std::string buffer = "abcdefghijklmnop"; lpf_memslot_t slots[16]; // register 3 entries @@ -42,36 +42,36 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) for ( i = 0; i < 16; ++i) { rc = lpf_register_global( lpf, &buffer[i], sizeof(buffer[i]), &slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // deregister all but the last for ( i = 0; i < 15; ++i) { rc = lpf_deregister( lpf, slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // and resize to 2 maxRegs = 2; rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // and deregister the last one rc = lpf_deregister( lpf, slots[15] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -79,10 +79,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_register_and_deregister_irregularly ) +TEST( API, func_lpf_register_and_deregister_irregularly ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_register_and_deregister_many_global.c b/tests/functional/func_lpf_register_and_deregister_many_global.cpp similarity index 81% rename from tests/functional/func_lpf_register_and_deregister_many_global.c rename to tests/functional/func_lpf_register_and_deregister_many_global.cpp index 851c25e7..8aa2a29e 100644 --- a/tests/functional/func_lpf_register_and_deregister_many_global.c +++ b/tests/functional/func_lpf_register_and_deregister_many_global.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -28,11 +28,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) size_t maxMsgs = 4 , maxRegs = 4; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); char buffer[8] = "abcd"; lpf_memslot_t slots[4]; @@ -46,18 +46,18 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) for ( i = 0; i < maxRegs; ++i) { rc = lpf_register_global( lpf, &buffer[i*2], sizeof(buffer[0])*2, &slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } for ( i = 0 ; i < maxRegs; ++i) { rc = lpf_deregister( lpf, slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -65,10 +65,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_register_and_deregister_many_global ) +TEST( API, func_lpf_register_and_deregister_many_global ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_register_global_parallel_grow.c b/tests/functional/func_lpf_register_global_parallel_grow.cpp similarity index 77% rename from tests/functional/func_lpf_register_global_parallel_grow.c rename to tests/functional/func_lpf_register_global_parallel_grow.cpp index 1c5821fd..641cfe07 100644 --- a/tests/functional/func_lpf_register_global_parallel_grow.c +++ b/tests/functional/func_lpf_register_global_parallel_grow.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -26,11 +26,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) size_t maxMsgs = 20 , maxRegs = 7; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); char buffer[21] = "Ditiseentestmettandr"; lpf_memslot_t slots[10]; @@ -39,24 +39,24 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) for ( i = 0; i < 5; ++i) { rc = lpf_register_global( lpf, &buffer[i*2], sizeof(buffer[0])*2, &slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_resize_memory_register( lpf, maxRegs + 3 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for ( i = 0; i < 5; ++i) { rc = lpf_register_global( lpf, &buffer[(i+5)*2], sizeof(buffer[0])*2, &slots[i+5] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } - EXPECT_STREQ( 20, "Ditiseentestmettandr", buffer ); + EXPECT_STREQ( "Ditiseentestmettandr", buffer ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); for (i = 0; i < 10; ++i) { @@ -66,7 +66,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_STREQ( 20, "DDttsseettssmmttaadd", buffer ); + EXPECT_STREQ( "DDttsseettssmmttaadd", buffer ); for (i = 0; i < 10; ++i) lpf_deregister( lpf, slots[i] ); @@ -77,9 +77,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_register_global_parallel_grow ) +TEST( API, func_lpf_register_global_parallel_grow ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_register_global_parallel_multiple.c b/tests/functional/func_lpf_register_global_parallel_multiple.cpp similarity index 60% rename from tests/functional/func_lpf_register_global_parallel_multiple.c rename to tests/functional/func_lpf_register_global_parallel_multiple.cpp index 515f1f87..1578b837 100644 --- a/tests/functional/func_lpf_register_global_parallel_multiple.c +++ b/tests/functional/func_lpf_register_global_parallel_multiple.cpp @@ -17,12 +17,12 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { (void) args; // ignore args parameter - EXPECT_LT( "%d", (int) pid, (int) nprocs ); + EXPECT_LT( (int) pid, (int) nprocs ); char a[1] = { 'i' }; char b[2] = { 'p', 'q' }; char c[3] = { 'a', 'b', 'c'}; @@ -35,62 +35,62 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_err_t rc = LPF_SUCCESS; rc = lpf_resize_message_queue( lpf, 1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 4); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &a, sizeof(a), &aSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &c, sizeof(c), &cSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &d, sizeof(d), &dSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - - EXPECT_EQ( "%c", 'i', a[0]); - EXPECT_EQ( "%c", 'p', b[0]); - EXPECT_EQ( "%c", 'q', b[1]); - EXPECT_EQ( "%c", 'a', c[0]); - EXPECT_EQ( "%c", 'b', c[1]); - EXPECT_EQ( "%c", 'c', c[2]); - EXPECT_EQ( "%c", 'h', d[0]); - EXPECT_EQ( "%c", 'a', d[1]); - EXPECT_EQ( "%c", 'l', d[2]); - EXPECT_EQ( "%c", 'l', d[3]); - EXPECT_EQ( "%c", 'o', d[4]); - EXPECT_EQ( "%c", '\0', d[5]); + EXPECT_EQ( LPF_SUCCESS, rc ); + + EXPECT_EQ( 'i', a[0]); + EXPECT_EQ( 'p', b[0]); + EXPECT_EQ( 'q', b[1]); + EXPECT_EQ( 'a', c[0]); + EXPECT_EQ( 'b', c[1]); + EXPECT_EQ( 'c', c[2]); + EXPECT_EQ( 'h', d[0]); + EXPECT_EQ( 'a', d[1]); + EXPECT_EQ( 'l', d[2]); + EXPECT_EQ( 'l', d[3]); + EXPECT_EQ( 'o', d[4]); + EXPECT_EQ( '\0', d[5]); if ( 0 == pid ) { rc = lpf_register_local( lpf, &b, sizeof(b), &bSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, bSlot, 1u * sizeof(b[0]), 1u, dSlot, 2u*sizeof(d[0]), sizeof(b[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - - EXPECT_EQ( "%c", 'i', a[0]); - EXPECT_EQ( "%c", 'p', b[0]); - EXPECT_EQ( "%c", 'q', b[1]); - EXPECT_EQ( "%c", 'a', c[0]); - EXPECT_EQ( "%c", 'b', c[1]); - EXPECT_EQ( "%c", 'c', c[2]); - EXPECT_EQ( "%c", 'h', d[0]); - EXPECT_EQ( "%c", 'a', d[1]); - EXPECT_EQ( "%c", pid == 1 ? 'q' : 'l', d[2]); - EXPECT_EQ( "%c", 'l', d[3]); - EXPECT_EQ( "%c", 'o', d[4]); - EXPECT_EQ( "%c", '\0', d[5]); + EXPECT_EQ( LPF_SUCCESS, rc ); + + EXPECT_EQ( 'i', a[0]); + EXPECT_EQ( 'p', b[0]); + EXPECT_EQ( 'q', b[1]); + EXPECT_EQ( 'a', c[0]); + EXPECT_EQ( 'b', c[1]); + EXPECT_EQ( 'c', c[2]); + EXPECT_EQ( 'h', d[0]); + EXPECT_EQ( 'a', d[1]); + EXPECT_EQ( pid == 1 ? 'q' : 'l', d[2]); + EXPECT_EQ( 'l', d[3]); + EXPECT_EQ( 'o', d[4]); + EXPECT_EQ( '\0', d[5]); lpf_deregister( lpf, dSlot ); @@ -104,9 +104,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 2 * \return Exit code: 0 */ -TEST( func_lpf_register_global_parallel_multiple ) +TEST( API, func_lpf_register_global_parallel_multiple ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc); } diff --git a/tests/functional/func_lpf_register_global_parallel_shrink.c b/tests/functional/func_lpf_register_global_parallel_shrink.cpp similarity index 82% rename from tests/functional/func_lpf_register_global_parallel_shrink.c rename to tests/functional/func_lpf_register_global_parallel_shrink.cpp index ec1ac62a..231482de 100644 --- a/tests/functional/func_lpf_register_global_parallel_shrink.c +++ b/tests/functional/func_lpf_register_global_parallel_shrink.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -25,11 +25,11 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) size_t maxMsgs = 20 , maxRegs = 10; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); char buffer[21] = "Ditiseentestmettandr"; lpf_memslot_t slots[10]; @@ -39,7 +39,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) for ( i = 0; i < 10; ++i) { rc = lpf_register_global( lpf, &buffer[i*2], sizeof(buffer[0])*2, &slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } // deregister 4 in an atypical order @@ -49,16 +49,16 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) for (i = 0; i < nDelRegs; ++i) { rc = lpf_deregister( lpf, slots[ delRegs[i] ]); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } // reduce by 4 which gets accepted rc = lpf_resize_memory_register( lpf, maxRegs - 4); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_STREQ( 20, "Ditiseentestmettandr", buffer ); + EXPECT_STREQ( "Ditiseentestmettandr", buffer ); // test that the remaining registrations still work size_t k; @@ -80,7 +80,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_STREQ( 20, "Dittsseettstmmttandr", buffer ); + EXPECT_STREQ( "Dittsseettstmmttandr", buffer ); for (i = 0; i < 6; ++i) lpf_deregister( lpf, slots[ otherRegs[i] ]); @@ -91,9 +91,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_register_global_parallel_shrink ) +TEST( API, func_lpf_register_global_parallel_shrink ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_register_global_root_multiple.c b/tests/functional/func_lpf_register_global_root_multiple.cpp similarity index 65% rename from tests/functional/func_lpf_register_global_root_multiple.c rename to tests/functional/func_lpf_register_global_root_multiple.cpp index 04c69846..b4287632 100644 --- a/tests/functional/func_lpf_register_global_root_multiple.c +++ b/tests/functional/func_lpf_register_global_root_multiple.cpp @@ -17,14 +17,14 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" /** * \test Test registering two times a global variable. * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_register_global_root_multiple ) +TEST( API, func_lpf_register_global_root_multiple ) { char a[1] = { 'i' }; char b[2] = { 'p', 'q' }; @@ -36,44 +36,43 @@ TEST( func_lpf_register_global_root_multiple ) lpf_err_t rc = LPF_SUCCESS; rc = lpf_resize_message_queue( LPF_ROOT, 2); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( LPF_ROOT, 3); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( LPF_ROOT, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( LPF_ROOT, &a, sizeof(a), &aSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( LPF_ROOT, &b, sizeof(b), &bSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( LPF_ROOT, &c, sizeof(c), &cSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( LPF_ROOT, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%c", 'i', a[0]); - EXPECT_EQ( "%c", 'p', b[0]); - EXPECT_EQ( "%c", 'q', b[1]); - EXPECT_EQ( "%c", 'a', c[0]); - EXPECT_EQ( "%c", 'b', c[1]); - EXPECT_EQ( "%c", 'c', c[2]); + EXPECT_EQ( 'i', a[0]); + EXPECT_EQ( 'p', b[0]); + EXPECT_EQ( 'q', b[1]); + EXPECT_EQ( 'a', c[0]); + EXPECT_EQ( 'b', c[1]); + EXPECT_EQ( 'c', c[2]); rc = lpf_put( LPF_ROOT, bSlot, 1u * sizeof(b[0]), 0u, cSlot, 2u*sizeof(c[0]), sizeof(b[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( LPF_ROOT, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%c", 'i', a[0]); - EXPECT_EQ( "%c", 'p', b[0]); - EXPECT_EQ( "%c", 'q', b[1]); - EXPECT_EQ( "%c", 'a', c[0]); - EXPECT_EQ( "%c", 'b', c[1]); - EXPECT_EQ( "%c", 'q', c[2]); + EXPECT_EQ( 'i', a[0]); + EXPECT_EQ( 'p', b[0]); + EXPECT_EQ( 'q', b[1]); + EXPECT_EQ( 'a', c[0]); + EXPECT_EQ( 'b', c[1]); + EXPECT_EQ( 'q', c[2]); - return 0; } diff --git a/tests/functional/func_lpf_register_global_root_single.c b/tests/functional/func_lpf_register_global_root_single.cpp similarity index 70% rename from tests/functional/func_lpf_register_global_root_single.c rename to tests/functional/func_lpf_register_global_root_single.cpp index 87514734..f8c93aa7 100644 --- a/tests/functional/func_lpf_register_global_root_single.c +++ b/tests/functional/func_lpf_register_global_root_single.cpp @@ -17,14 +17,14 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" /** * \test Test registering one global variable. * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_register_global_root_single ) +TEST( API, func_lpf_register_global_root_single ) { char a[1] = { 'j' }; char b[2] = { 'a', 'b' }; @@ -33,35 +33,34 @@ TEST( func_lpf_register_global_root_single ) lpf_err_t rc = LPF_SUCCESS; rc = lpf_resize_message_queue( LPF_ROOT, 2); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( LPF_ROOT, 2); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( LPF_ROOT, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( LPF_ROOT, &a, sizeof(a), &aSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_local( LPF_ROOT, &b, sizeof(b), &bSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( LPF_ROOT, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%c", 'j', a[0]); - EXPECT_EQ( "%c", 'a', b[0]); - EXPECT_EQ( "%c", 'b', b[1]); + EXPECT_EQ( 'j', a[0]); + EXPECT_EQ( 'a', b[0]); + EXPECT_EQ( 'b', b[1]); rc = lpf_put( LPF_ROOT, bSlot, 1u * sizeof(b[0]), 0u, aSlot, 0u*sizeof(a[0]), sizeof(a[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( LPF_ROOT, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%c", 'b', a[0]); - EXPECT_EQ( "%c", 'a', b[0]); - EXPECT_EQ( "%c", 'b', b[1]); + EXPECT_EQ( 'b', a[0]); + EXPECT_EQ( 'a', b[0]); + EXPECT_EQ( 'b', b[1]); - return 0; } diff --git a/tests/functional/func_lpf_register_local_parallel_multiple.c b/tests/functional/func_lpf_register_local_parallel_multiple.cpp similarity index 69% rename from tests/functional/func_lpf_register_local_parallel_multiple.c rename to tests/functional/func_lpf_register_local_parallel_multiple.cpp index 368fbe17..e97a9013 100644 --- a/tests/functional/func_lpf_register_local_parallel_multiple.c +++ b/tests/functional/func_lpf_register_local_parallel_multiple.cpp @@ -17,7 +17,7 @@ #include #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -32,55 +32,55 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t xSlot[10]; lpf_err_t rc = LPF_SUCCESS; - EXPECT_LT( "%u", pid, nprocs ); + EXPECT_LT( pid, nprocs ); rc = lpf_resize_message_queue( lpf, 1); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, 2 + nprocs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_pid_t i; for (i = 0; i < pid; ++i) { int x = 0; rc = lpf_register_local( lpf, &x, sizeof(x)+pid, &xSlot[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_register_global( lpf, &a, sizeof(a), &aSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%c", 'i', a[0]); - EXPECT_EQ( "%c", 'p', b[0]); - EXPECT_EQ( "%c", 'q', b[1]); - EXPECT_EQ( "%c", 'a', c[0]); - EXPECT_EQ( "%c", 'b', c[1]); - EXPECT_EQ( "%c", 'c', c[2]); + EXPECT_EQ( 'i', a[0]); + EXPECT_EQ( 'p', b[0]); + EXPECT_EQ( 'q', b[1]); + EXPECT_EQ( 'a', c[0]); + EXPECT_EQ( 'b', c[1]); + EXPECT_EQ( 'c', c[2]); if ( 1 == pid ) { rc = lpf_register_local( lpf, &c, sizeof(c), &cSlot ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_put( lpf, cSlot, 1u * sizeof(c[0]), 0u, aSlot, 0u*sizeof(a[0]), sizeof(a[0]), LPF_MSG_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ( "%c", 0 == pid ? 'b' : 'i', a[0]); - EXPECT_EQ( "%c", 'p', b[0]); - EXPECT_EQ( "%c", 'q', b[1]); - EXPECT_EQ( "%c", 'a', c[0]); - EXPECT_EQ( "%c", 'b', c[1]); - EXPECT_EQ( "%c", 'c', c[2]); + EXPECT_EQ( 0 == pid ? 'b' : 'i', a[0]); + EXPECT_EQ( 'p', b[0]); + EXPECT_EQ( 'q', b[1]); + EXPECT_EQ( 'a', c[0]); + EXPECT_EQ( 'b', c[1]); + EXPECT_EQ( 'c', c[2]); if ( 1 == pid) lpf_deregister( lpf, cSlot ); lpf_deregister( lpf, aSlot ); @@ -94,8 +94,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P <= 10 * \return Exit code: 0 */ -TEST( func_lpf_register_local_parallel_multiple ) +TEST( API, func_lpf_register_local_parallel_multiple ) { lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS); - return 0; } diff --git a/tests/functional/func_lpf_resize_delayed_shrinking_memory_registers.c b/tests/functional/func_lpf_resize_delayed_shrinking_memory_registers.cpp similarity index 77% rename from tests/functional/func_lpf_resize_delayed_shrinking_memory_registers.c rename to tests/functional/func_lpf_resize_delayed_shrinking_memory_registers.cpp index 1ff9ff99..7a94803b 100644 --- a/tests/functional/func_lpf_resize_delayed_shrinking_memory_registers.c +++ b/tests/functional/func_lpf_resize_delayed_shrinking_memory_registers.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -28,13 +28,13 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) size_t maxMsgs = 0 , maxRegs = 16; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - char buffer[16] = "abcdefghijklmnop"; + std::string buffer = "abcdefghijklmnop"; lpf_memslot_t slots[16]; // register 16 entries @@ -42,27 +42,27 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) for ( i = 0; i < 16; ++i) { rc = lpf_register_global( lpf, &buffer[i], sizeof(buffer[i]), &slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // resize to 0 again. maxRegs = 0; rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // deregister all for ( i = 0; i < 16; ++i) { rc = lpf_deregister( lpf, slots[i] ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } /** @@ -70,10 +70,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_resize_delayed_shrinking_memory_registers ) +TEST( API, func_lpf_resize_delayed_shrinking_memory_registers ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_resize_delayed_shrinking_message_queues.c b/tests/functional/func_lpf_resize_delayed_shrinking_message_queues.cpp similarity index 75% rename from tests/functional/func_lpf_resize_delayed_shrinking_message_queues.c rename to tests/functional/func_lpf_resize_delayed_shrinking_message_queues.cpp index 94e2f3e1..ce0bc8c6 100644 --- a/tests/functional/func_lpf_resize_delayed_shrinking_message_queues.c +++ b/tests/functional/func_lpf_resize_delayed_shrinking_message_queues.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) { @@ -29,43 +29,43 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) // reserve space for 16 messages size_t maxMsgs = 32 , maxRegs = 2; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( lpf, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - char buf1[16] = "abcdefghijklmnop"; - char buf2[16] = "ABCDEFGHIJKLMNOP"; + std::string buf1 = "abcdefghijklmnop"; + std::string buf2 = "ABCDEFGHIJKLMNOP"; lpf_memslot_t slot1, slot2; rc = lpf_register_global( lpf, &buf1[0], sizeof(buf1), &slot1 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_register_global( lpf, &buf2[0], sizeof(buf2), &slot2 ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); // resize to 0 messages again. maxMsgs = 0; rc = lpf_resize_message_queue( lpf, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); unsigned i; for ( i = 0; i < 16; ++i ) lpf_put( lpf, slot1, i, (pid + 1 ) % nprocs, slot2, i, 1, LPF_MSG_DEFAULT); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_STREQ( 16, buf2, "abcdefghijklmnop"); + EXPECT_STREQ( buf2.c_str(), "abcdefghijklmnop"); rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); lpf_deregister( lpf, slot1 ); lpf_deregister( lpf, slot2 ); @@ -76,10 +76,9 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_resize_delayed_shrinking_message_queues ) +TEST( API, func_lpf_resize_delayed_shrinking_message_queues ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc ); } diff --git a/tests/functional/func_lpf_resize_parallel_five.c b/tests/functional/func_lpf_resize_parallel_five.cpp similarity index 84% rename from tests/functional/func_lpf_resize_parallel_five.c rename to tests/functional/func_lpf_resize_parallel_five.cpp index c0937c51..1af3a131 100644 --- a/tests/functional/func_lpf_resize_parallel_five.c +++ b/tests/functional/func_lpf_resize_parallel_five.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) { @@ -29,12 +29,12 @@ void spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) size_t maxMsgs = 5 , maxRegs = 7; rc = lpf_resize_message_queue( ctx, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( ctx, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( ctx, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); } @@ -44,9 +44,8 @@ void spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_resize_parallel_five ) +TEST( API, func_lpf_resize_parallel_five ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, &spmd, LPF_NO_ARGS); - EXPECT_EQ( "%d", LPF_SUCCESS, rc); - return 0; + EXPECT_EQ( LPF_SUCCESS, rc); } diff --git a/tests/functional/func_lpf_resize_root_five.c b/tests/functional/func_lpf_resize_root_five.cpp similarity index 84% rename from tests/functional/func_lpf_resize_root_five.c rename to tests/functional/func_lpf_resize_root_five.cpp index bbaea650..7f6cdeea 100644 --- a/tests/functional/func_lpf_resize_root_five.c +++ b/tests/functional/func_lpf_resize_root_five.cpp @@ -16,25 +16,24 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" /** * \test Test lpf_resize function on LPF_ROOT and set maxMsgs to five * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_resize_root_five ) +TEST( API, func_lpf_resize_root_five ) { lpf_err_t rc = LPF_SUCCESS; size_t maxMsgs = 5 , maxRegs = 7; rc = lpf_resize_message_queue( LPF_ROOT, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( LPF_ROOT, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( LPF_ROOT, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - return 0; } diff --git a/tests/functional/func_lpf_resize_root_outofmem.c b/tests/functional/func_lpf_resize_root_outofmem.cpp similarity index 81% rename from tests/functional/func_lpf_resize_root_outofmem.c rename to tests/functional/func_lpf_resize_root_outofmem.cpp index 7c15ccc3..8cd13358 100644 --- a/tests/functional/func_lpf_resize_root_outofmem.c +++ b/tests/functional/func_lpf_resize_root_outofmem.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" @@ -25,25 +25,24 @@ * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_resize_root_outofmem ) +TEST( API, func_lpf_resize_root_outofmem ) { lpf_err_t rc = LPF_SUCCESS; size_t maxMsgs = ((size_t) -1)/10 ; size_t maxRegs = ((size_t) -1)/10; rc = lpf_resize_message_queue( LPF_ROOT, maxMsgs); - EXPECT_EQ( "%d", LPF_ERR_OUT_OF_MEMORY, rc ); + EXPECT_EQ( LPF_ERR_OUT_OF_MEMORY, rc ); rc = lpf_resize_memory_register( LPF_ROOT, maxRegs ); - EXPECT_EQ( "%d", LPF_ERR_OUT_OF_MEMORY, rc ); + EXPECT_EQ( LPF_ERR_OUT_OF_MEMORY, rc ); maxMsgs = -1; maxRegs = -1; rc = lpf_resize_message_queue( LPF_ROOT, maxMsgs); - EXPECT_EQ( "%d", LPF_ERR_OUT_OF_MEMORY, rc ); + EXPECT_EQ( LPF_ERR_OUT_OF_MEMORY, rc ); rc = lpf_resize_memory_register( LPF_ROOT, maxRegs ); - EXPECT_EQ( "%d", LPF_ERR_OUT_OF_MEMORY, rc ); + EXPECT_EQ( LPF_ERR_OUT_OF_MEMORY, rc ); - return 0; } diff --git a/tests/functional/func_lpf_resize_root_zero.c b/tests/functional/func_lpf_resize_root_zero.cpp similarity index 84% rename from tests/functional/func_lpf_resize_root_zero.c rename to tests/functional/func_lpf_resize_root_zero.cpp index 55585084..5bd2bedc 100644 --- a/tests/functional/func_lpf_resize_root_zero.c +++ b/tests/functional/func_lpf_resize_root_zero.cpp @@ -16,24 +16,23 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" /** * \test Test lpf_resize function on LPF_ROOT allocating nothing * \pre P >= 1 * \return Exit code: 0 */ -TEST( func_lpf_resize_root_zero ) +TEST( API, func_lpf_resize_root_zero ) { lpf_err_t rc = LPF_SUCCESS; size_t maxMsgs = 0 , maxRegs = 0; rc = lpf_resize_message_queue( LPF_ROOT, maxMsgs); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_memory_register( LPF_ROOT, maxRegs ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync( LPF_ROOT, LPF_SYNC_DEFAULT ); - EXPECT_EQ( "%d", LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); - return 0; } diff --git a/tests/functional/macro_LPF_VERSION.c b/tests/functional/macro_LPF_VERSION.cpp similarity index 90% rename from tests/functional/macro_LPF_VERSION.c rename to tests/functional/macro_LPF_VERSION.cpp index 4527d24d..7588aeea 100644 --- a/tests/functional/macro_LPF_VERSION.c +++ b/tests/functional/macro_LPF_VERSION.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" #ifdef _LPF_VERSION #if _LPF_VERSION == 202000L @@ -33,8 +33,7 @@ * \pre P >= 1 * \return Exit code: 0 */ -TEST( macro_LPF_VERSION ) +TEST( API, macro_LPF_VERSION ) { - EXPECT_EQ( "%ld", 202000L, _LPF_VERSION ); - return 0; + EXPECT_EQ( 202000L, _LPF_VERSION ); } diff --git a/tests/functional/run.sh b/tests/functional/run.sh deleted file mode 100755 index 3af01b5c..00000000 --- a/tests/functional/run.sh +++ /dev/null @@ -1,299 +0,0 @@ -#!/bin/bash - -# -# Copyright 2021 Huawei Technologies Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -shopt -s extglob - -builddir=`pwd` -dir=`dirname $0` -defaultMaxProcs=5 -defaultNodes=2 # This makes the hybrid implementation sensitive to errors -intermOutput=output -lpf_impl_id=$1 -lpf_impl_config=$2 -log=tests-${lpf_impl_id}-${lpf_impl_config}.log -junitfile=$3 -loglevel=1 -shift -shift -shift - -function get() -{ - sed -ne 's/.*\\'"$1"'[[:space:]]*\(.*\)$/\1/p' -} - -function log -{ - echo "$@" | tee -a $log -} - -if [ `uname` = Darwin ]; then - # Non GNU date can't print nanoseconds - function getTime() - { - date +%s - } - - function nproc() { - /usr/sbin/sysctl -o machdep.cpu.core_count | sed -e 's/.*://' - } -else - function getTime() - { - date +%s.%N - } - - if which nproc; then - nproc_exe=`which nproc` - function nproc() { - $nproc_exe - } - else - function nproc() { - echo $defaultMaxProcs - } - fi -fi - -# Adjust default max number of processes -if [ `nproc` -lt $defaultMaxProcs ]; then - defaultMaxProcs=`nproc` -fi - -# Some systems don't have DC calculator -echo | dc -if [ $? -ne 0 ]; then - # define a dummy implementation, because it is only used to report - # the time needed by every test - function dc() { - echo 0 - } -fi - - -function lpfrun -{ - bash ../../lpfrun_build "$@" -} - -XUNIT_TESTS=0 -XUNIT_FAILURES=0 -XUNIT_ERRORS=0 -XUNIT_TOTALTIME=0 -rm -f ${junitfile} ${junitfile}.txt - -if [ `uname` = Darwin ]; then - function junit - { - return - } -else - - function junit - { - case $1 in - add) name=$2 - success=$3 - t=$4 - shift - shift - shift - shift - - - XUNIT_TESTS=$((XUNIT_TESTS + 1)) - XUNIT_TOTALTIME=$( (echo $XUNIT_TOTALTIME; echo $t; echo '+'; echo 'p') | dc ) - echo "" >> ${junitfile}.txt - if [ $success -eq 0 ]; then - XUNIT_FAILURES=$((XUNIT_FAILURES + 1)) - echo "> ${junitfile}.txt - cat >> ${junitfile}.txt - echo "]]>" >> ${junitfile}.txt - fi - echo "" >> ${junitfile}.txt - ;; - - - write) echo "" > $junitfile - echo "" >> $junitfile - echo "" >> $junitfile - cat ${junitfile}.txt >> $junitfile - echo "" >> $junitfile - ;; - esac - - } -fi - -rm -f $log -log "============================================================================" -log "RUNNING LPF API TESTS" -allSuccess=1 -suffix="_${lpf_impl_id}_${lpf_impl_config}" -for testexe in $(find . -name "*${suffix}" -or -name "*${suffix}_debug") -do - testname=${testexe%_debug} - if [ "x${testname}" != "x${testexe}" ] ; then - mode=debug; - else - mode=default; - fi - - testname=$(basename ${testname%${suffix}}) - testCase=$(find $dir -name "${testname}.c" -or -name "${testname}.${lpf_impl_id}.c") - description=`get 'test' < $testCase` - message=`get 'return Message:' < $testCase` - exitCode=`get 'return Exit code:' < $testCase` - minProcs=`get 'pre[[:space:]]*P >=' < $testCase` - maxProcs=`get 'pre[[:space:]]*P <=' < $testCase` - extraParams=`get 'note Extra lpfrun parameters:' < $testCase` - indepProcs=`get 'note Independent processes:' < $testCase` - - if echo "${testexe}" | grep -qf $dir/exception_list ; then - log "----------------------------------------------------------------------------" - log " IGNORING: $testname" - log " Description: $description" - continue - fi - - if [ x$testname = x ]; then - log "Warning: Can't read testname from $testCase. Test case skipped" ; - allSuccess=0; - continue - fi - if [ x$exitCode = x ]; then - log "Error: Can't read expected exit code from $testCase. Test case skipped" ; - allSuccess=0; - continue - fi - if [ '!' '(' $exitCode -ge 0 ')' ]; then - log "Error: Can't read expected exit code from $testCase. Test case skipped" ; - allSuccess=0; - continue - fi - if [ x$minProcs = x ]; then - log "Error: Can't determine lower bound of processes for $testCase. Test case skipped" ; - allSuccess=0; - continue - fi - if [ '!' '(' $minProcs -ge 1 ')' ]; then - log "Error: Lower bound of processes is illegal for test case $testCase. Test case skipped" ; - allSuccess=0; - continue - fi - if [ x$maxProcs = x ]; then - maxProcs=$defaultMaxProcs - fi - if [ '!' '(' $maxProcs -ge 1 ')' ]; then - log "Error: Upper bound of processes is illegal for test case $testCase. Test case skipped" - allSuccess=0; - continue - fi - - if [ x$indepProcs '!=' xyes ]; then - indepProcs=no - fi - - log "----------------------------------------------------------------------------" - log " RUNNING: $testname ( $mode )" - log " Description: $description" - log " Number of processes: $minProcs - $maxProcs" - log " Engine: $lpf_impl_id" - log " Configuration: $lpf_impl_config" - log " Extra lpfrun params: $extraParams" - log " Independent processes: $indepProcs" - log - -#$lpfcc $testCase -o ${testname}.exe -Wall -Wextra >> $log 2>&1 -# compilation=$? - -# if [ '!' $compilation -eq 0 ]; then -# log " TEST FAILURE: Failed to compile $testCase" -# allSuccess=0; -# continue -# fi - - setSuccess=1 - for (( processes=$minProcs; processes <= $maxProcs; ++processes )) - do - success=1 - t0=`getTime` - if [ $indepProcs = no ]; then - # The normal way of running a test - - lpfrun -engine $lpf_impl_id -log $loglevel \ - -n $processes -N $defaultNodes ${extraParams} \ - "$@" ./${testexe} > $intermOutput 2>&1 - actualExitCode=$? - else - # this way of running processes is required to test implementation of - # lpf_hook on MPI implementations - - rm $intermOutput - touch $intermOutput - for (( p = 0; p < processes; ++p )) - do - lpfrun -engine $lpf_impl_id -log $loglevel -np 1 ${extraParams} "$@" \ - ./${testexe} $p ${processes} >> $intermOutput 2>&1 & - done - wait `jobs -p` - actualExitCode=$? - fi - t1=`getTime` - t=$( ( echo $t1 ; echo $t0; echo "-"; echo "p" ) | dc ) - - cat $intermOutput >> $log - # NOTE: Only two exit codes are recognized: failure and success. That's because most - # MPI implementations mangle the exit code. - msg= - if [ \( $actualExitCode -eq 0 -a $exitCode -ne 0 \) -o \ - \( $actualExitCode -ne 0 -a $exitCode -eq 0 \) ]; then - msg=" TEST FAILURE: Expected exit code $exitCode does not match actual exit code $actualExitCode for $testCase on $processes processes" - log "$msg" - allSuccess=0; - setSuccess=0 - success=0 - fi - if [ "x$message" != x ]; then - if grep -q "$message" $intermOutput ; then - let noop=0; - else - msg=" TEST FAILURE: Expected messages does not match for $testCase on $processes processes" - log "$msg" - allSuccess=0 - setSuccess=0 - success=0 - fi - fi - junit add "$testname.$processes" $success $t "$msg" < $intermOutput - done - if [ $setSuccess -eq 1 ]; then - log "TEST SUCCESS" - fi -done - -junit write - -log "----------------------------------------------------------------------------" -if [ $allSuccess -eq 0 ]; then - log "ONE OR MORE TEST FAILURES" - exit 1 -else - log "ALL TESTS SUCCESSFUL" - exit 0 -fi diff --git a/tests/functional/type_lpf_spmd_t.c b/tests/functional/type_lpf_spmd_t.cpp similarity index 86% rename from tests/functional/type_lpf_spmd_t.c rename to tests/functional/type_lpf_spmd_t.cpp index adb8e0c5..e800dc62 100644 --- a/tests/functional/type_lpf_spmd_t.c +++ b/tests/functional/type_lpf_spmd_t.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" void test_spmd( const lpf_t lpf, const lpf_pid_t pid, const lpf_pid_t nprocs, const lpf_args_t args) { @@ -37,7 +37,7 @@ lpf_spmd_t var_c = & test_spmd; * \pre P >= 1 * \return Exit code: 0 */ -TEST( type_lpf_spmd_t ) +TEST( API, type_lpf_spmd_t ) { lpf_spmd_t var_d = NULL; lpf_spmd_t var_e = & test_spmd; @@ -48,8 +48,7 @@ TEST( type_lpf_spmd_t ) lpf_args_t e; (*var_e)(a, b, c, e); - EXPECT_EQ( "%p", (lpf_spmd_t) NULL, var_b ); - EXPECT_EQ( "%p", &test_spmd, var_e ); - EXPECT_EQ( "%p", (lpf_spmd_t) NULL, var_d ); - return 0; + EXPECT_EQ( (lpf_spmd_t) NULL, var_b ); + EXPECT_EQ( &test_spmd, var_e ); + EXPECT_EQ( (lpf_spmd_t) NULL, var_d ); } diff --git a/tests/functional/type_lpf_t.c b/tests/functional/type_lpf_t.cpp similarity index 82% rename from tests/functional/type_lpf_t.c rename to tests/functional/type_lpf_t.cpp index 91353605..3c24afbd 100644 --- a/tests/functional/type_lpf_t.c +++ b/tests/functional/type_lpf_t.cpp @@ -16,7 +16,7 @@ */ #include -#include "Test.h" +#include "gtest/gtest.h" /** @@ -24,7 +24,7 @@ * \pre P >= 1 * \return Exit code: 0 */ -TEST( type_lpf_t ) +TEST( API, type_lpf_t ) { lpf_t var_d = NULL; @@ -34,8 +34,7 @@ TEST( type_lpf_t ) lpf_t var_e = y; y = var_d; - EXPECT_EQ( "%ld", sizeof(lpf_t), sizeof(void *)); - EXPECT_EQ( "%p", NULL, y ); - EXPECT_EQ( "%p", (lpf_t) &x, var_e ); - return 0; + EXPECT_EQ( sizeof(lpf_t), sizeof(void *)); + EXPECT_EQ( NULL, y ); + EXPECT_EQ( (lpf_t) &x, var_e ); } From 0aa7363851193908bdc9323d3510587c83305130 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Tue, 3 Dec 2024 14:56:22 +0100 Subject: [PATCH 04/28] WIP --- include/lpf/noc.h | 451 ++++++++++++++++++ src/MPI/CMakeLists.txt | 1 + src/MPI/core.cpp | 76 +++ src/MPI/ibverbsNoc.cpp | 40 ++ src/MPI/ibverbsNoc.hpp | 23 + src/MPI/interface.cpp | 73 ++- src/MPI/interface.hpp | 17 +- src/MPI/mesgqueue.hpp | 6 +- src/MPI/mesgqueueNoc.cpp | 65 +++ src/MPI/mesgqueueNoc.hpp | 31 ++ src/imp/core.c | 52 ++ tests/functional/CMakeLists.txt | 5 +- .../functional/func_lpf_test_noc_register.cpp | 1 + 13 files changed, 817 insertions(+), 24 deletions(-) create mode 100644 include/lpf/noc.h create mode 100644 src/MPI/ibverbsNoc.cpp create mode 100644 src/MPI/ibverbsNoc.hpp create mode 100644 src/MPI/mesgqueueNoc.cpp create mode 100644 src/MPI/mesgqueueNoc.hpp diff --git a/include/lpf/noc.h b/include/lpf/noc.h new file mode 100644 index 00000000..6f46442f --- /dev/null +++ b/include/lpf/noc.h @@ -0,0 +1,451 @@ + +/* + * Copyright 2021 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LPFLIB_NOC_H +#define LPFLIB_NOC_H + +// import size_t data type for the implementation +#ifndef DOXYGEN + +#ifdef __cplusplus +#include +#else +#include +#endif + +#include + +#endif // DOXYGEN + + +#ifdef __cplusplus +extern "C" { +#endif + +/** \addtogroup LPF_EXTENSIONS LPF API extensions + * + * @{ + * + * \defgroup LPF_NOC Extensions to LPF where it need not maintain consistency. + * + * This extension specifies facilities for (de-)registering memory slots, + * registering RDMA requests, and fencing RDMA requests. These extensions are, + * as far as possible, fully compatible with the core LPF definitions. These + * include LPF contexts (#lpf_t), processor count types (#lpf_pid_t), memory + * slot types (#lpf_memslot_t), and message attributes (#lpf_msg_attr_t). + * + * In this extension, LPF does not maintain consistency amongst processes that + * (de-)register memory slots while RDMA communication may occur. Maintaining + * the required consistency instead becomes the purview of the user. This + * extension specificies exactly what consistency properties the user must + * guarantee. + * + * \warning If LPF is considered a tool for the so-called hero + * programmer, then please note that this variant is even harder + * to program with. + * + * \note At present, no debug layer exists for this extension. It is unclear if + * such a debug layer is even possible (precisely because LPF in this + * extension does not maintain consistency, there is no way a debug layer + * could enforce it). + * + * @{ + */ + + +/** + * The version of this no-conflict LPF specification. All implementations shall + * define this macro. The format is YYYYNN, where YYYY is the year the + * specification was released, and NN the number of the specifications released + * before this one in the same year. + */ +#define _LPF_NOC_VERSION 202400L + +/** + * Resizes the memory register for non-coherent RDMA. + * + * After a successful call to this function, the local process has enough + * resources to register \a max_regs memory regions in a non-coherent way. + * + * Each registration via lpf_noc_register() counts as one. Such registrations + * remain taking up capacity in the register until they are released via a call + * to lpf_noc_deregister(), which lowers the count of used memory registerations + * by one. + * + * There are no runtime out-of-bounds checks prescribed for lpf_noc_register()-- + * this would also be too costly as error checking would require communication. + * + * If memory allocation were successful, the return value is #LPF_SUCCESS and + * the local process may assume the new buffer size \a max_regs. + * + * In the case of insufficient local memory the return value will be + * #LPF_ERR_OUT_OF_MEMORY. In that case, it is as if the call never happened and + * the user may retry the call locally after freeing up unused resources. Should + * retrying not lead to a successful call, the programmer may opt to broadcast + * the error (using existing slots) or to give up by returning from the spmd + * section. + * + * \note The current maximum cannot be retrieved from the runtime. Instead, the + * programmer must track this information herself. To provide + * encapsulation, see lpf_rehook(). + * + * \note When the given memory register capacity is smaller than the current + * capacity, the runtime is allowed but not required to release the + * allocated memory. Such a call shall always be successful and return + * #LPF_SUCCESS. + * + * \note This means that an implementation that allows shrinking the given + * capacity must also ensure the old buffer remains intact in case there + * is not enough memory to allocate a smaller one. + * + * \note The last invocation of lpf_noc_resize_memory_register() determines the + * maximum number of memory registrations using lpf_noc_register() that + * can be maintained concurrently. + * + * \par Thread safety + * This function is safe to be called from different LPF processes only. Any + * further thread safety may be guaranteed by the implementation, but is not + * specified. Similar conditions hold for all LPF primitives that take an + * argument of type #lpf_t; see #lpf_t for more information. + * + * \param[in,out] ctx The runtime state as provided by lpf_exec(). + * \param[in] max_regs The requested maximum number of memory regions that can + * be registered. This value must be the same on all + * processes. + * + * \returns #LPF_SUCCESS + * When this process successfully acquires the resources. + * + * \returns #LPF_ERR_OUT_OF_MEMORY + * When there was not enough memory left on the heap. In this case + * the effect is the same as when this call did not occur at all. + * + * \par BSP costs + * None + * + * See also \ref BSPCOSTS. + * + * \par Runtime costs + * \f$ \Theta( \mathit{max\_regs} ) \f$. + */ +extern _LPFLIB_API +lpf_err_t lpf_noc_resize_memory_register( lpf_t ctx, size_t max_regs ); + +/** + * Registers a local memory area, preparing its use for intra-process + * communication. + * + * The registration process is necessary to enable Remote Direct Memory Access + * (RDMA) primitives, such as lpf_get() and lpf_put(). + * + * This is \em not a collective function. For #lpf_get and #lpf_put, the memory + * slot returned by this function is equivalent to a memory slot returned by + * #lpf_register_local; the \a memslot returned by a successful call to this + * function (hence) is immediately valid. A successful call (hence) immediately + * consumes one memory slot capacity; see also #lpf_resize_memory_register on + * how to ensure sufficient capacity. + * + * Different from a memory slot returned by #lpf_register_local, a memory slot + * returned by a successful call to this function may serve as either a local + * or remote memory slot for #lpf_noc_put and #lpf_noc_get. + * + * Use of the returned memory slot to indicate a remote memory area may only + * occur by copying the returned memory slot to another LPF process. This may + * be done using the standard #lpf_put and #lpf_get methods or by using + * auxiliary communication mechanisms. The memory slot thus communicated only + * refers to a valid memory area on the process it originated from; any other + * use leads to undefined behaviour. + * + * \note Note that the ability to copy memory slots to act as identifiers of + * remote areas exploits the LPF core specification that instances of + * the #lpf_memslot_t type are, indeed, byte-copyable. + * + * A memory slot returned by a successful call to this function may be + * destroyed via a call to the standard #lpf_deregister. The deregistration + * takes effect immediately. No communication using the deregistered slot + * should occur during that superstep, or otherwise undefined behaviour occurs. + * + * Only the process that created the returned memory slot can destroy it; other + * LPF processes than the one which created it that attempt to destroy the + * returned memory slot, invoke undefined behaviour. + * + * Other than the above specified differences, the arguments to this function + * are the same as for #lpf_register_local: + * + * \param[in,out] ctx The runtime state as provided by lpf_exec(). + * \param[in] pointer The pointer to the memory area to register. + * \param[in] size The size of the memory area to register in bytes. + * \param[out] memslot Where to store the memory slot identifier. + * + * \note Registering a slot with zero \a size is valid. The resulting memory + * slot cannot be written to nor read from by remote LPF processes. + * + * \note In particular, passing \c NULL as \a pointer and \c 0 for \a size is + * valid. + * + * \returns #LPF_SUCCESS + * Successfully registered the memory region and successfully + * assigned a memory slot identifier. + * + * \note One registration consumes one memory slot from the pool of locally + * available memory slots, which must have been preallocated by + * lpf_resize_memory_register() or recycled by lpf_deregister(). Always + * use lpf_resize_memory_register() at the start of the SPMD function + * that is executed by lpf_exec(), since lpf_exec() itself does not + * preallocate slots. + * + * \note It is illegal to request more memory slots than have previously been + * registered with lpf_resize_memory_register(). There is no runtime + * check for this error, because a safe way out cannot be guaranteed + * without significant parallel error checking overhead. + * + * \par Thread safety + * This function is safe to be called from different LPF processes only. Any + * further thread safety may be guaranteed by the implementation, but is not + * specified. Similar conditions hold for all LPF primitives that take an + * argument of type #lpf_t; see #lpf_t for more information. + * + * \par BSP costs + * + * None. + * + * \par Runtime costs + * + * \f$ \mathcal{O}( \texttt{size} ) \f$. + * + * \note This asymptotic bound may be attained for implementations that require + * linear-time processing on the registered memory area, such as to effect + * memory pinning. If this is not required, a good implementation will + * require only \f$ \Theta(1) \f$ time. + */ +extern _LPFLIB_API +lpf_err_t lpf_noc_register( + lpf_t ctx, + void * pointer, + size_t size, + lpf_memslot_t * memslot +); + +/** + * Deregisters a memory area previously registered using lpf_noc_register(). + * + * After a successful deregistration, the slot is returned to the pool of free + * memory slots. The total number of memory slots may be set via a call to + * lpf_noc_resize_memory_register(). + * + * Deregistration takes effect immediately. A call to this function is not + * collective, and the other of deregistration does not need to match the order + * of registration. Any local or remote communication using the given \a memslot + * in the current superstep invokes undefined behaviour. + * + * \par Thread safety + * This function is safe to be called from different LPF processes only. Any + * further thread safety may be guaranteed by the implementation, but is not + * specified. Similar conditions hold for all LPF primitives that take an + * argument of type #lpf_t; see #lpf_t for more information. + * + * \param[in,out] ctx The runtime state as provided by lpf_exec(). + * \param[in] memslot The memory slot identifier to de-register. + * + * \returns #LPF_SUCCESS + * Successfully deregistered the memory region. + * + * \par BSP costs + * None. + * + * \par Runtime costs + * \f$ \mathcal{O}(n) \f$, where \f$ n \f$ is the size of the memory region + * corresponding to \a memslot. + */ +extern _LPFLIB_API +lpf_err_t lpf_deregister( + lpf_t ctx, + lpf_memslot_t memslot +); + +/** + * Copies contents of local memory into the memory of remote processes. + * + * This operation is guaranteed to be completed after a call to the next + * lpf_sync() exits. + * + * Until that time it occupies one entry in the operations queue. + * + * Concurrent reads or writes from or to the same memory area are + * allowed in the same way they are for the core primitive #lpf_put. + * + * This primitive differs from #lpf_put in that the \a dst_slot may be the + * result of a successful call to #lpf_noc_register, while \a src_slot \em must + * be the results of such a successful call. In both cases, the slot need + * \em not have been registered before the last call to #lpf_sync. + * + * \par Thread safety + * This function is safe to be called from different LPF processes only. Any + * further thread safety may be guaranteed by the implementation, but is not + * specified. Similar conditions hold for all LPF primitives that take an + * argument of type #lpf_t; see #lpf_t for more information. + * + * \param[in,out] ctx The runtime state as provided by lpf_exec() + * \param[in] src_slot The memory slot of the local source memory area + * registered using lpf_register_local(), + * lpf_register_global(), or lpf_noc_register() + * \param[in] src_offset The offset of reading out the source memory area, + * w.r.t. the base location of the registered area + * expressed in bytes. + * \param[in] dst_pid The process ID of the destination process. + * \param[in] dst_slot The memory slot of the destination memory area at + * \a pid, registered using lpf_register_global() or + * lpf_noc_register(). + * \param[in] dst_offset The offset of writing to the destination memory area + * w.r.t. the base location of the registered area + * expressed in bytes. + * \param[in] size The number of bytes to copy from the source memory area + * to the destination memory area. + * \param[in] attr + * \parblock + * In case an \a attr not equal to #LPF_MSG_DEFAULT is provided, the + * the message created by this function may have modified semantics + * that may be used to extend this API. Examples include: + * + * -# delaying the superstep deadline of delivery, and/or + * -# DRMA with message combining semantics. + * + * These attributes are stored after a call to this function has + * completed and may be modified immediately after without affecting + * any messages already scheduled. + * \endparblock + * + * \note See #lpf_put for notes regarding #lpf_msg_attr_t. + * + * \returns #LPF_SUCCESS + * When the communication request was recorded successfully. + * + * \par BSP costs + * This function will increase + * \f$ t_{c}^{(s)} \f$ + * and + * \f$ r_{c}^{(\mathit{pid})} \f$ + * by \a size, where c is the current superstep number and s is this process ID + * (as provided by #lpf_exec)). See \ref BSPCOSTS on how this affects real-time + * communication costs. + * + * \par Runtime costs + * See \ref BSPCOSTS. + */ +extern _LPFLIB_API +lpf_err_t lpf_noc_put( + lpf_t ctx, + lpf_memslot_t src_slot, + size_t src_offset, + lpf_pid_t dst_pid, + lpf_memslot_t dst_slot, + size_t dst_offset, + size_t size, + lpf_msg_attr_t attr +); + +/** + * Copies contents from remote memory to local memory. + * + * This operation completes after one call to lpf_sync(). + * + * Until that time it occupies one entry in the operations queue. + * + * Concurrent reads or writes from or to the same memory area are allowed in the + * same way it is for #lpf_get. + * + * This primitive differs from #lpf_get in that the \a src_slot may be the + * result of a successful call to #lpf_noc_register, while \a dst_slot \em must + * be the results of such a successful call. In both cases, the slot need + * \em not have been registered before the last call to #lpf_sync. + * + * \par Thread safety + * This function is safe to be called from different LPF processes only. Any + * further thread safety may be guaranteed by the implementation, but is not + * specified. Similar conditions hold for all LPF primitives that take an + * argument of type #lpf_t; see #lpf_t for more information. + * + * \param[in,out] ctx The runtime state as provided by lpf_exec(). + * \param[in] src_pid The process ID of the source process. + * \param[in] src_slot The memory slot of the source memory area at \a pid, as + * globally registered with lpf_register_global() or + * lpf_noc_register(). + * \param[in] src_offset The offset of reading out the source memory area, + * w.r.t. the base location of the registered area + * expressed in bytes. + * \param[in] dst_slot The memory slot of the local destination memory area + * registered using lpf_register_local(), + * lpf_register_global(), or lpf_noc_register(). + * \param[in] dst_offset The offset of writing to the destination memory area + * w.r.t. the base location of the registered area + * expressed in bytes. + * \param[in] size The number of bytes to copy from the source + * remote memory location. + * \param[in] attr + * \parblock + * In case an \a attr not equal to #LPF_MSG_DEFAULT is provided, the + * the message created by this function may have modified semantics + * that may be used to extend this API. Examples include: + * + * -# delaying the superstep deadline of delivery, and/or + * -# DRMA with message combining semantics. + * + * These attributes are stored after a call to this function has + * completed and may be modified immediately after without affecting + * any messages already scheduled. + * \endparblock + * + * \note See #lpf_get for notes on the use of #lpf_msg_attr_t. + * + * \returns #LPF_SUCCESS + * When the communication request was recorded successfully. + * + * \par BSP costs + * This function will increase + * \f$ r_{c}^{(s)} \f$ + * and + * \f$ t_{c}^{(\mathit{pid})} \f$ + * by \a size, where c is the current superstep number and s is this process ID + * (as provided via lpf_exec(). See \ref BSPCOSTS on how this affects real-time + * communication costs. + * + * \par Runtime costs + * See \ref BSPCOSTS. + */ +extern _LPFLIB_API +lpf_err_t lpf_noc_get( + lpf_t ctx, + lpf_pid_t src_pid, + lpf_memslot_t src_slot, + size_t src_offset, + lpf_memslot_t dst_slot, + size_t dst_offset, + size_t size, + lpf_msg_attr_t attr +); + +/** + * @} + * + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/MPI/CMakeLists.txt b/src/MPI/CMakeLists.txt index 9633d1d5..33883854 100644 --- a/src/MPI/CMakeLists.txt +++ b/src/MPI/CMakeLists.txt @@ -61,6 +61,7 @@ if (MPI_FOUND) add_library(raw_${libname} OBJECT memorytable.cpp mesgqueue.cpp + mesgqueueNoc.cpp mpilib.cpp symbol.cpp process.cpp diff --git a/src/MPI/core.cpp b/src/MPI/core.cpp index 4340bd27..1ec798b4 100644 --- a/src/MPI/core.cpp +++ b/src/MPI/core.cpp @@ -15,6 +15,7 @@ * limitations under the License. */ +#include #include #include @@ -392,4 +393,79 @@ lpf_err_t lpf_abort( lpf_t ctx ) { return LPF_SUCCESS; } +lpf_err_t lpf_noc_resize_memory_register( lpf_t ctx, size_t max_regs ) +{ + lpf::Interface * i = realContext(ctx); + if (i->isAborted()) + return LPF_SUCCESS; + + return i->nocResizeMemreg(max_regs); +} + +lpf_err_t lpf_noc_register( + lpf_t ctx, + void * pointer, + size_t size, + lpf_memslot_t * memslot +) +{ + lpf::Interface * i = realContext(ctx); + if (i->isAborted()) + return LPF_SUCCESS; + + *memslot = i->nocRegister(pointer, size); +} + +lpf_err_t lpf_noc_deregister( + lpf_t ctx, + lpf_memslot_t memslot +) +{ + lpf::Interface * i = realContext(ctx); + if (!i->isAborted()) + i->nocDeregister(memslot); + + return LPF_SUCCESS; +} + +lpf_err_t lpf_noc_put( + lpf_t ctx, + lpf_memslot_t src_slot, + size_t src_offset, + lpf_pid_t dst_pid, + lpf_memslot_t dst_slot, + size_t dst_offset, + size_t size, + lpf_msg_attr_t attr +) +{ + (void) attr; // ignore parameter 'msg' since this implementation only + // implements core functionality + lpf::Interface * i = realContext(ctx); + if (!i->isAborted()) + i->nocPut( src_slot, src_offset, dst_pid, dst_slot, dst_offset, size ); + + return LPF_SUCCESS; + +} + +lpf_err_t lpf_noc_get( + lpf_t ctx, + lpf_pid_t pid, + lpf_memslot_t src, + size_t src_offset, + lpf_memslot_t dst, + size_t dst_offset, + size_t size, + lpf_msg_attr_t attr +) +{ + (void) attr; // ignore parameter 'msg' since this implementation only + // implements core functionality + lpf::Interface * i = realContext(ctx); + if (!i->isAborted()) + i->nocGet( pid, src, src_offset, dst, dst_offset, size ); + + return LPF_SUCCESS; +} diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp new file mode 100644 index 00000000..cb4710ad --- /dev/null +++ b/src/MPI/ibverbsNoc.cpp @@ -0,0 +1,40 @@ +namespace lpf +{ +namespace mpi +{ + IBVerbsNoc :: SlotID IBVerbs :: regNoc( void * addr, size_t size ) + { + ASSERT( size <= m_maxRegSize ); + + MemorySlot slot; + if ( size > 0) { + LOG(4, "Registering locally memory area at " << addr << " of size " << size ); + struct ibv_mr * const ibv_mr_new_p = ibv_reg_mr( + m_pd.get(), addr, size, + IBV_ACCESS_REMOTE_READ | IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE + ); + if( ibv_mr_new_p == NULL ) + slot.mr.reset(); + else + slot.mr.reset( ibv_mr_new_p, ibv_dereg_mr ); + if (!slot.mr) { + LOG(1, "Could not register memory area at " + << addr << " of size " << size << " with IB device"); + throw Exception("Could not register memory area"); + } + } + MemoryRegistration local; + local.addr = addr; + local.size = size; + local.lkey = size?slot.mr->lkey:0; + local.rkey = size?slot.mr->rkey:0; + + SlotID id = m_memreg.addNocReg( slot ); + + m_memreg.update( id ).glob.resize( m_nprocs ); + m_memreg.update( id ).glob[m_pid] = local; + LOG(4, "Memory area " << addr << " of size " << size << " has been locally registered. Slot = " << id ); + return id; + } +} // namespace mpi +} // namespace lpf diff --git a/src/MPI/ibverbsNoc.hpp b/src/MPI/ibverbsNoc.hpp new file mode 100644 index 00000000..91544e14 --- /dev/null +++ b/src/MPI/ibverbsNoc.hpp @@ -0,0 +1,23 @@ +#include "ibverbs.hpp" + +namespace lpf +{ + +namespace mpi +{ + class _LPFLIB_LOCAL IBVerbsNoc : public IBVerbs { + public: + IBVerbsNoc(Communication & comm) : IBVerbs(comm) {} + ~IBVerbsNoc() {} + + void putNoc( SlotID srcSlot, size_t srcOffset, + int dstPid, SlotID dstSlot, size_t dstOffset, size_t size ); + + void getNoc( int srcPid, SlotID srcSlot, size_t srcOffset, + SlotID dstSlot, size_t dstOffset, size_t size ); + + SlotID regNoc( void * addr, size_t size ); + + }; +} // namespace mpi +} // namespace lpf diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index 80123e58..c3e9ca81 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -75,7 +75,7 @@ void Interface :: initRoot(int *argc, char ***argv) Interface :: Interface( mpi::Comm machine, Process & subprocess ) try : m_comm( machine ) , m_subprocess( subprocess ) - , m_mesgQueue( m_comm ) + , m_mesgQueueNoc( m_comm ) , m_aborted( false ) { if ( machine.allreduceOr( false ) ) @@ -95,7 +95,7 @@ void Interface :: put( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue.put( srcSlot, srcOffset, + m_mesgQueueNoc.put( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } @@ -107,7 +107,7 @@ void Interface :: lockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue.lockSlot( srcSlot, srcOffset, + m_mesgQueueNoc.lockSlot( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } @@ -116,36 +116,36 @@ void Interface :: unlockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue.unlockSlot( srcSlot, srcOffset, + m_mesgQueueNoc.unlockSlot( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } void Interface :: getRcvdMsgCountPerSlot(size_t * msgs, SlotID slot) { - m_mesgQueue.getRcvdMsgCountPerSlot(msgs, slot); + m_mesgQueueNoc.getRcvdMsgCountPerSlot(msgs, slot); } void Interface :: getSentMsgCountPerSlot(size_t * msgs, SlotID slot) { - m_mesgQueue.getSentMsgCountPerSlot(msgs, slot); + m_mesgQueueNoc.getSentMsgCountPerSlot(msgs, slot); } void Interface :: flushSent() { - m_mesgQueue.flushSent(); + m_mesgQueueNoc.flushSent(); } void Interface :: flushReceived() { - m_mesgQueue.flushReceived(); + m_mesgQueueNoc.flushReceived(); } void Interface :: getRcvdMsgCount(size_t * msgs) { - m_mesgQueue.getRcvdMsgCount(msgs); + m_mesgQueueNoc.getRcvdMsgCount(msgs); } err_t Interface :: countingSyncPerSlot(memslot_t slot, size_t expected_sent, size_t expected_rcvd) { if ( 0 == m_aborted ) { - m_aborted = m_mesgQueue.countingSyncPerSlot(slot, expected_sent, expected_rcvd); + m_aborted = m_mesgQueueNoc.countingSyncPerSlot(slot, expected_sent, expected_rcvd); return LPF_SUCCESS; } else @@ -158,7 +158,7 @@ err_t Interface :: syncPerSlot(memslot_t slot) { if ( 0 == m_aborted ) { - m_aborted = m_mesgQueue.syncPerSlot(slot); + m_aborted = m_mesgQueueNoc.syncPerSlot(slot); return LPF_SUCCESS; } else @@ -174,34 +174,34 @@ void Interface :: get( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue.get( srcPid, srcSlot, srcOffset, + m_mesgQueueNoc.get( srcPid, srcSlot, srcOffset, dstSlot, dstOffset, size ); } memslot_t Interface :: registerGlobal( void * mem, size_t size ) { - return m_mesgQueue.addGlobalReg( mem, size ); + return m_mesgQueueNoc.addGlobalReg( mem, size ); } memslot_t Interface :: registerLocal( void * mem, size_t size ) { - return m_mesgQueue.addLocalReg( mem, size ); + return m_mesgQueueNoc.addLocalReg( mem, size ); } void Interface :: deregister( memslot_t slot ) { - m_mesgQueue.removeReg( slot ); + m_mesgQueueNoc.removeReg( slot ); } err_t Interface :: resizeMemreg( size_t nRegs ) { - return m_mesgQueue.resizeMemreg( nRegs ); + return m_mesgQueueNoc.resizeMemreg( nRegs ); } err_t Interface :: resizeMesgQueue( size_t nMsgs ) { - return m_mesgQueue.resizeMesgQueue( nMsgs ); + return m_mesgQueueNoc.resizeMesgQueue( nMsgs ); } void Interface :: abort() @@ -215,10 +215,45 @@ void Interface :: abort() #else // signal all other processes at the start of the next 'sync' that // this process aborted. - m_aborted = m_mesgQueue.sync( true ); + m_aborted = m_mesgQueueNoc.sync( true ); #endif } +/* start NOC extensions */ +memslot_t Interface :: nocRegister( void * mem, size_t size ) +{ + return m_mesgQueueNoc.addNocReg( mem, size ); +} + +void Interface :: nocDeregister( memslot_t slot) +{ + m_mesgQueueNoc.removeNocReg(slot); +} + +err_t Interface :: nocResizeMemreg( size_t nRegs ) +{ + return m_mesgQueueNoc.nocResizeMemreg(nRegs); +} + +void Interface :: nocPut( memslot_t srcSlot, size_t srcOffset, + pid_t dstPid, memslot_t dstSlot, size_t dstOffset, + size_t size ) +{ + m_mesgQueueNoc.nocPut( srcSlot, srcOffset, + dstPid, dstSlot, dstOffset, + size ); +} + +void Interface :: nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, + memslot_t dstSlot, size_t dstOffset, + size_t size ) +{ + m_mesgQueueNoc.nocGet( srcPid, srcSlot, srcOffset, + dstSlot, dstOffset, + size ); +} +/* end NOC extensions */ + pid_t Interface :: isAborted() const { return m_aborted; @@ -228,7 +263,7 @@ err_t Interface :: sync() { if ( 0 == m_aborted ) { - m_aborted = m_mesgQueue.sync( false ); + m_aborted = m_mesgQueueNoc.sync( false ); } if ( 0 == m_aborted ) diff --git a/src/MPI/interface.hpp b/src/MPI/interface.hpp index 02e48b3c..6ffe2bf6 100644 --- a/src/MPI/interface.hpp +++ b/src/MPI/interface.hpp @@ -19,7 +19,7 @@ #define LPF_CORE_MPI_INTERFACE_HPP #include "types.hpp" -#include "mesgqueue.hpp" +#include "mesgqueueNoc.hpp" #include "mpilib.hpp" #include "machineparams.hpp" #include "linkage.hpp" @@ -61,6 +61,19 @@ class _LPFLIB_LOCAL Interface err_t resizeMesgQueue( size_t nMsgs ) ; // nothrow void abort() ; // nothrow + // + /* start NOC extensions */ + memslot_t nocRegister( void * mem, size_t size ) ; // nothrow + void nocDeregister( memslot_t slot) ; // nothrow + err_t nocResizeMemreg( size_t nRegs ) ; // nothrow + void nocPut( memslot_t srcSlot, size_t srcOffset, + pid_t dstPid, memslot_t dstSlot, size_t dstOffset, + size_t size ) ; // nothrow + + void nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, + memslot_t dstSlot, size_t dstOffset, + size_t size ) ;// nothrow + /* end NOC extensions */ pid_t isAborted() const ; @@ -107,7 +120,7 @@ class _LPFLIB_LOCAL Interface private: mpi::Comm m_comm; Process & m_subprocess; - MessageQueue m_mesgQueue; + MessageQueueNoc m_mesgQueueNoc; pid_t m_aborted; static Interface * s_root; diff --git a/src/MPI/mesgqueue.hpp b/src/MPI/mesgqueue.hpp index b4f1f796..35fcd46a 100644 --- a/src/MPI/mesgqueue.hpp +++ b/src/MPI/mesgqueue.hpp @@ -34,7 +34,7 @@ #endif #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero -#include "ibverbs.hpp" +#include "ibverbsNoc.hpp" #endif //only for HiCR @@ -160,11 +160,13 @@ class _LPFLIB_LOCAL MessageQueue std::vector< Body > m_bodySends; std::vector< Body > m_bodyRecvs; mpi::Comm m_comm; + std::vector< char > m_tinyMsgBuf; + +protected: #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero mpi::IBVerbs m_ibverbs; #endif MemoryTable m_memreg; - std::vector< char > m_tinyMsgBuf; }; diff --git a/src/MPI/mesgqueueNoc.cpp b/src/MPI/mesgqueueNoc.cpp new file mode 100644 index 00000000..32908416 --- /dev/null +++ b/src/MPI/mesgqueueNoc.cpp @@ -0,0 +1,65 @@ +#include "mesgqueue.hpp" +#include "mesgqueueNoc.hpp" + +namespace lpf +{ + + MessageQueueNoc :: MessageQueueNoc( Communication & comm ) : + m_ibverbs( comm ), + MessageQueue(comm) + {} + +memslot_t MessageQueueNoc :: addNocReg( void * mem, std::size_t size ) +{ + +#if defined LPF_CORE_MPI_USES_zero + return m_ibverbs.regNoc(mem, size); +#endif + return LPF_INVALID_MEMSLOT; + +} + +void MessageQueueNoc :: removeNocReg( memslot_t slot ) +{ + +#if defined LPF_CORE_MPI_USES_zero + m_ibverbs.dereg(slot); +#endif + +} + +void MessageQueueNoc :: nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, + memslot_t dstSlot, size_t dstOffset, size_t size ) +{ + +#if defined LPF_CORE_MPI_USES_zero + m_ibverbs.getNoc(srcPid, + m_memreg.getVerbID( srcSlot), + srcOffset, + m_memreg.getVerbID( dstSlot), + dstOffset, + size ); +#endif +} + +void MessageQueueNoc :: nocPut( memslot_t srcSlot, size_t srcOffset, + pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) +{ +#if defined LPF_CORE_MPI_USES_zero + m_ibverbs.putNoc( m_memreg.getVerbID( srcSlot), + srcOffset, + dstPid, + m_memreg.getVerbID( dstSlot), + dstOffset, + size); +#endif +} + +err_t MessageQueueNoc :: nocResizeMemreg( size_t nRegs ) +{ +#if defined LPF_CORE_MPI_USES_zero + return m_ibverbs.resizeMemreg(nRegs); +#endif +} + +} // namespace lpf diff --git a/src/MPI/mesgqueueNoc.hpp b/src/MPI/mesgqueueNoc.hpp new file mode 100644 index 00000000..9528bf07 --- /dev/null +++ b/src/MPI/mesgqueueNoc.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "lpf/core.h" +#include "mesgqueue.hpp" +#include "ibverbsNoc.hpp" + +namespace lpf +{ +class _LPFLIB_LOCAL MessageQueueNoc : public MessageQueue +{ + +public: + explicit MessageQueueNoc( Communication & comm ); + /* + * begin NOC extension + */ + memslot_t addNocReg( void * mem, std::size_t size ); + void removeNocReg( memslot_t slot ); + void nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, + memslot_t dstSlot, size_t dstOffset, size_t size ); + void nocPut( memslot_t srcSlot, size_t srcOffset, + pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ); + err_t nocResizeMemreg( size_t nRegs ); + /* + * end NOC extension + */ +protected: + mpi::IBVerbsNoc m_ibverbs; +}; + +} // namespace lpf diff --git a/src/imp/core.c b/src/imp/core.c index 7b4c3db2..a9c7ceb1 100644 --- a/src/imp/core.c +++ b/src/imp/core.c @@ -16,6 +16,7 @@ */ #include +#include #include #include @@ -239,3 +240,54 @@ lpf_err_t lpf_abort( lpf_t lpf) (void) lpf; return LPF_SUCCESS; } + +lpf_err_t lpf_noc_resize_memory_register( lpf_t ctx, size_t max_regs ) +{ + return LPF_SUCCESS; +} + +lpf_err_t lpf_noc_register( + lpf_t ctx, + void * pointer, + size_t size, + lpf_memslot_t * memslot +) +{ + return LPF_SUCCESS; +} + +lpf_err_t lpf_noc_deregister( + lpf_t ctx, + lpf_memslot_t memslot +) +{ + return LPF_SUCCESS; +} + +lpf_err_t lpf_noc_put( + lpf_t ctx, + lpf_memslot_t src_slot, + size_t src_offset, + lpf_pid_t dst_pid, + lpf_memslot_t dst_slot, + size_t dst_offset, + size_t size, + lpf_msg_attr_t attr +) +{ + return LPF_SUCCESS; +} + +lpf_err_t lpf_noc_get( + lpf_t ctx, + lpf_pid_t src_pid, + lpf_memslot_t src_slot, + size_t src_offset, + lpf_memslot_t dst_slot, + size_t dst_offset, + size_t size, + lpf_msg_attr_t attr +) +{ + return LPF_SUCCESS; +} diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 4a404668..45f142e1 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -148,13 +148,16 @@ foreach (LPF_IMPL_ID ${ENGINES}) endforeach(testSource) +endforeach(LPF_IMPL_ID) + # NOC test for HiCR set(baseName "func_lpf_test_noc_register") set(debug OFF) set(mode "") + set(LPF_IMPL_ID "ibverbs") + set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${baseName}.cpp") -endforeach(LPF_IMPL_ID) include_directories(.) diff --git a/tests/functional/func_lpf_test_noc_register.cpp b/tests/functional/func_lpf_test_noc_register.cpp index 178b9289..c026edbc 100644 --- a/tests/functional/func_lpf_test_noc_register.cpp +++ b/tests/functional/func_lpf_test_noc_register.cpp @@ -16,6 +16,7 @@ */ #include +#include #include #include "gtest/gtest.h" From 3c2c337917f6a133b6380923fc162d4316941f91 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Tue, 3 Dec 2024 20:38:55 +0100 Subject: [PATCH 05/28] WIP, now it compiles, but logic incomplete --- src/MPI/CMakeLists.txt | 2 +- src/MPI/ibverbs.hpp | 2 +- src/MPI/ibverbsNoc.cpp | 9 ++++++- src/MPI/ibverbsNoc.hpp | 12 +++------ src/MPI/interface.cpp | 56 +++++++++++++++++++++++----------------- src/MPI/interface.hpp | 3 ++- src/MPI/mesgqueue.cpp | 5 ++++ src/MPI/mesgqueue.hpp | 1 + src/MPI/mesgqueueNoc.cpp | 23 ++++++----------- src/MPI/mesgqueueNoc.hpp | 2 ++ 10 files changed, 64 insertions(+), 51 deletions(-) diff --git a/src/MPI/CMakeLists.txt b/src/MPI/CMakeLists.txt index 33883854..d07bc486 100644 --- a/src/MPI/CMakeLists.txt +++ b/src/MPI/CMakeLists.txt @@ -55,7 +55,7 @@ if (MPI_FOUND) endif() if (LPF_IMPL_ID STREQUAL zero) - set(ibverbs_sources ibverbsZero.cpp) + set(ibverbs_sources ibverbsZero.cpp ibverbsNoc.cpp) endif() add_library(raw_${libname} OBJECT diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index f53c9354..c36db9d1 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -110,7 +110,7 @@ class _LPFLIB_LOCAL IBVerbs void get_rcvd_msg_count(size_t * rcvd_msgs); void get_rcvd_msg_count_per_slot(size_t * rcvd_msgs, SlotID slot); void get_sent_msg_count_per_slot(size_t * sent_msgs, SlotID slot); -private: +protected: IBVerbs & operator=(const IBVerbs & ); // assignment prohibited IBVerbs( const IBVerbs & ); // copying prohibited diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index cb4710ad..09c7137e 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -1,8 +1,15 @@ +#include "ibverbsNoc.hpp" + namespace lpf { namespace mpi { - IBVerbsNoc :: SlotID IBVerbs :: regNoc( void * addr, size_t size ) + + struct IBVerbs::Exception : std::runtime_error { + Exception(const char * what) : std::runtime_error( what ) {} + }; + + IBVerbs::SlotID IBVerbsNoc :: regNoc( void * addr, size_t size ) { ASSERT( size <= m_maxRegSize ); diff --git a/src/MPI/ibverbsNoc.hpp b/src/MPI/ibverbsNoc.hpp index 91544e14..8bdfeed7 100644 --- a/src/MPI/ibverbsNoc.hpp +++ b/src/MPI/ibverbsNoc.hpp @@ -1,3 +1,5 @@ +#pragma once + #include "ibverbs.hpp" namespace lpf @@ -8,15 +10,9 @@ namespace mpi class _LPFLIB_LOCAL IBVerbsNoc : public IBVerbs { public: IBVerbsNoc(Communication & comm) : IBVerbs(comm) {} - ~IBVerbsNoc() {} - - void putNoc( SlotID srcSlot, size_t srcOffset, - int dstPid, SlotID dstSlot, size_t dstOffset, size_t size ); - - void getNoc( int srcPid, SlotID srcSlot, size_t srcOffset, - SlotID dstSlot, size_t dstOffset, size_t size ); + //~IBVerbsNoc() {} - SlotID regNoc( void * addr, size_t size ); + IBVerbs::SlotID regNoc( void * addr, size_t size ); }; } // namespace mpi diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index c3e9ca81..81c6014f 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -75,7 +75,11 @@ void Interface :: initRoot(int *argc, char ***argv) Interface :: Interface( mpi::Comm machine, Process & subprocess ) try : m_comm( machine ) , m_subprocess( subprocess ) - , m_mesgQueueNoc( m_comm ) +#ifdef LPF_CORE_MPI_USES_zero + , m_mesgQueue( new MessageQueueNoc(m_comm)) +#else + , m_mesgQueue( new MessageQueue(m_comm)) +#endif , m_aborted( false ) { if ( machine.allreduceOr( false ) ) @@ -95,7 +99,7 @@ void Interface :: put( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueueNoc.put( srcSlot, srcOffset, + m_mesgQueue->put( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } @@ -107,7 +111,7 @@ void Interface :: lockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueueNoc.lockSlot( srcSlot, srcOffset, + m_mesgQueue->lockSlot( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } @@ -116,36 +120,36 @@ void Interface :: unlockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueueNoc.unlockSlot( srcSlot, srcOffset, + m_mesgQueue->unlockSlot( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } void Interface :: getRcvdMsgCountPerSlot(size_t * msgs, SlotID slot) { - m_mesgQueueNoc.getRcvdMsgCountPerSlot(msgs, slot); + m_mesgQueue->getRcvdMsgCountPerSlot(msgs, slot); } void Interface :: getSentMsgCountPerSlot(size_t * msgs, SlotID slot) { - m_mesgQueueNoc.getSentMsgCountPerSlot(msgs, slot); + m_mesgQueue->getSentMsgCountPerSlot(msgs, slot); } void Interface :: flushSent() { - m_mesgQueueNoc.flushSent(); + m_mesgQueue->flushSent(); } void Interface :: flushReceived() { - m_mesgQueueNoc.flushReceived(); + m_mesgQueue->flushReceived(); } void Interface :: getRcvdMsgCount(size_t * msgs) { - m_mesgQueueNoc.getRcvdMsgCount(msgs); + m_mesgQueue->getRcvdMsgCount(msgs); } err_t Interface :: countingSyncPerSlot(memslot_t slot, size_t expected_sent, size_t expected_rcvd) { if ( 0 == m_aborted ) { - m_aborted = m_mesgQueueNoc.countingSyncPerSlot(slot, expected_sent, expected_rcvd); + m_aborted = m_mesgQueue->countingSyncPerSlot(slot, expected_sent, expected_rcvd); return LPF_SUCCESS; } else @@ -158,7 +162,7 @@ err_t Interface :: syncPerSlot(memslot_t slot) { if ( 0 == m_aborted ) { - m_aborted = m_mesgQueueNoc.syncPerSlot(slot); + m_aborted = m_mesgQueue->syncPerSlot(slot); return LPF_SUCCESS; } else @@ -174,34 +178,34 @@ void Interface :: get( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueueNoc.get( srcPid, srcSlot, srcOffset, + m_mesgQueue->get( srcPid, srcSlot, srcOffset, dstSlot, dstOffset, size ); } memslot_t Interface :: registerGlobal( void * mem, size_t size ) { - return m_mesgQueueNoc.addGlobalReg( mem, size ); + return m_mesgQueue->addGlobalReg( mem, size ); } memslot_t Interface :: registerLocal( void * mem, size_t size ) { - return m_mesgQueueNoc.addLocalReg( mem, size ); + return m_mesgQueue->addLocalReg( mem, size ); } void Interface :: deregister( memslot_t slot ) { - m_mesgQueueNoc.removeReg( slot ); + m_mesgQueue->removeReg( slot ); } err_t Interface :: resizeMemreg( size_t nRegs ) { - return m_mesgQueueNoc.resizeMemreg( nRegs ); + return m_mesgQueue->resizeMemreg( nRegs ); } err_t Interface :: resizeMesgQueue( size_t nMsgs ) { - return m_mesgQueueNoc.resizeMesgQueue( nMsgs ); + return m_mesgQueue->resizeMesgQueue( nMsgs ); } void Interface :: abort() @@ -215,42 +219,46 @@ void Interface :: abort() #else // signal all other processes at the start of the next 'sync' that // this process aborted. - m_aborted = m_mesgQueueNoc.sync( true ); + m_aborted = m_mesgQueue->sync( true ); #endif } /* start NOC extensions */ memslot_t Interface :: nocRegister( void * mem, size_t size ) { - return m_mesgQueueNoc.addNocReg( mem, size ); + return m_mesgQueue->addNocReg( mem, size ); } void Interface :: nocDeregister( memslot_t slot) { - m_mesgQueueNoc.removeNocReg(slot); + m_mesgQueue->removeReg(slot); } err_t Interface :: nocResizeMemreg( size_t nRegs ) { - return m_mesgQueueNoc.nocResizeMemreg(nRegs); + return m_mesgQueue->resizeMemreg(nRegs); } void Interface :: nocPut( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueueNoc.nocPut( srcSlot, srcOffset, +#ifdef LPF_CORE_MPI_USES_zero + m_mesgQueue->put( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); +#endif } void Interface :: nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueueNoc.nocGet( srcPid, srcSlot, srcOffset, +#ifdef LPF_CORE_MPI_USES_zero + m_mesgQueue->get( srcPid, srcSlot, srcOffset, dstSlot, dstOffset, size ); +#endif } /* end NOC extensions */ @@ -263,7 +271,7 @@ err_t Interface :: sync() { if ( 0 == m_aborted ) { - m_aborted = m_mesgQueueNoc.sync( false ); + m_aborted = m_mesgQueue->sync( false ); } if ( 0 == m_aborted ) diff --git a/src/MPI/interface.hpp b/src/MPI/interface.hpp index 6ffe2bf6..5d08dc73 100644 --- a/src/MPI/interface.hpp +++ b/src/MPI/interface.hpp @@ -120,7 +120,8 @@ class _LPFLIB_LOCAL Interface private: mpi::Comm m_comm; Process & m_subprocess; - MessageQueueNoc m_mesgQueueNoc; + std::shared_ptr m_mesgQueue; + pid_t m_aborted; static Interface * s_root; diff --git a/src/MPI/mesgqueue.cpp b/src/MPI/mesgqueue.cpp index f81a618a..27e3330c 100644 --- a/src/MPI/mesgqueue.cpp +++ b/src/MPI/mesgqueue.cpp @@ -243,6 +243,11 @@ err_t MessageQueue :: resizeMemreg( size_t nRegs ) return LPF_SUCCESS; } + +memslot_t MessageQueue :: addNocReg( void * mem, std::size_t size) +{ + return LPF_INVALID_MEMSLOT; +} memslot_t MessageQueue :: addLocalReg( void * mem, std::size_t size) { memslot_t slot = m_memreg.addLocal( mem, size ); diff --git a/src/MPI/mesgqueue.hpp b/src/MPI/mesgqueue.hpp index 35fcd46a..7dc52ccd 100644 --- a/src/MPI/mesgqueue.hpp +++ b/src/MPI/mesgqueue.hpp @@ -54,6 +54,7 @@ class _LPFLIB_LOCAL MessageQueue memslot_t addLocalReg( void * mem, std::size_t size ); memslot_t addGlobalReg( void * mem, std::size_t size ); + memslot_t addNocReg( void * mem, std::size_t size ); void removeReg( memslot_t slot ); void get( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, diff --git a/src/MPI/mesgqueueNoc.cpp b/src/MPI/mesgqueueNoc.cpp index 32908416..f7c4f6cb 100644 --- a/src/MPI/mesgqueueNoc.cpp +++ b/src/MPI/mesgqueueNoc.cpp @@ -1,6 +1,7 @@ -#include "mesgqueue.hpp" #include "mesgqueueNoc.hpp" +#if defined LPF_CORE_MPI_USES_zero + namespace lpf { @@ -12,19 +13,14 @@ namespace lpf memslot_t MessageQueueNoc :: addNocReg( void * mem, std::size_t size ) { -#if defined LPF_CORE_MPI_USES_zero return m_ibverbs.regNoc(mem, size); -#endif - return LPF_INVALID_MEMSLOT; } void MessageQueueNoc :: removeNocReg( memslot_t slot ) { -#if defined LPF_CORE_MPI_USES_zero m_ibverbs.dereg(slot); -#endif } @@ -32,34 +28,31 @@ void MessageQueueNoc :: nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffse memslot_t dstSlot, size_t dstOffset, size_t size ) { -#if defined LPF_CORE_MPI_USES_zero - m_ibverbs.getNoc(srcPid, + m_ibverbs.get(srcPid, m_memreg.getVerbID( srcSlot), srcOffset, m_memreg.getVerbID( dstSlot), dstOffset, size ); -#endif } void MessageQueueNoc :: nocPut( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { -#if defined LPF_CORE_MPI_USES_zero - m_ibverbs.putNoc( m_memreg.getVerbID( srcSlot), + m_ibverbs.put( m_memreg.getVerbID( srcSlot), srcOffset, dstPid, m_memreg.getVerbID( dstSlot), dstOffset, size); -#endif } err_t MessageQueueNoc :: nocResizeMemreg( size_t nRegs ) { -#if defined LPF_CORE_MPI_USES_zero - return m_ibverbs.resizeMemreg(nRegs); -#endif + m_ibverbs.resizeMemreg(nRegs); + return LPF_SUCCESS; } } // namespace lpf + // +#endif diff --git a/src/MPI/mesgqueueNoc.hpp b/src/MPI/mesgqueueNoc.hpp index 9528bf07..6aa914ae 100644 --- a/src/MPI/mesgqueueNoc.hpp +++ b/src/MPI/mesgqueueNoc.hpp @@ -4,6 +4,7 @@ #include "mesgqueue.hpp" #include "ibverbsNoc.hpp" +#ifdef LPF_CORE_MPI_USES_zero namespace lpf { class _LPFLIB_LOCAL MessageQueueNoc : public MessageQueue @@ -29,3 +30,4 @@ class _LPFLIB_LOCAL MessageQueueNoc : public MessageQueue }; } // namespace lpf +#endif From 69608f0c086c597d5f5d03acd45679fc7673b1ac Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Wed, 4 Dec 2024 09:29:39 +0100 Subject: [PATCH 06/28] Use more inheritance instead of separate NOC methods, and fix a few bugs --- src/MPI/ibverbsNoc.cpp | 3 +- src/MPI/ibverbsNoc.hpp | 3 +- src/MPI/interface.cpp | 4 -- src/MPI/memorytable.cpp | 21 +++++++-- src/MPI/memorytable.hpp | 6 ++- src/MPI/mesgqueue.cpp | 47 ++++++++++--------- src/MPI/mesgqueue.hpp | 2 +- src/MPI/mesgqueueNoc.cpp | 2 +- src/common/memreg.hpp | 6 ++- .../functional/func_lpf_test_noc_register.cpp | 2 +- 10 files changed, 55 insertions(+), 41 deletions(-) diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index 09c7137e..520d585b 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -9,7 +9,7 @@ namespace mpi Exception(const char * what) : std::runtime_error( what ) {} }; - IBVerbs::SlotID IBVerbsNoc :: regNoc( void * addr, size_t size ) + IBVerbs::SlotID IBVerbsNoc :: regLocal( void * addr, size_t size ) { ASSERT( size <= m_maxRegSize ); @@ -43,5 +43,6 @@ namespace mpi LOG(4, "Memory area " << addr << " of size " << size << " has been locally registered. Slot = " << id ); return id; } + } // namespace mpi } // namespace lpf diff --git a/src/MPI/ibverbsNoc.hpp b/src/MPI/ibverbsNoc.hpp index 8bdfeed7..a1713e79 100644 --- a/src/MPI/ibverbsNoc.hpp +++ b/src/MPI/ibverbsNoc.hpp @@ -10,10 +10,9 @@ namespace mpi class _LPFLIB_LOCAL IBVerbsNoc : public IBVerbs { public: IBVerbsNoc(Communication & comm) : IBVerbs(comm) {} + IBVerbs::SlotID regLocal( void * addr, size_t size ); //~IBVerbsNoc() {} - IBVerbs::SlotID regNoc( void * addr, size_t size ); - }; } // namespace mpi } // namespace lpf diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index 81c6014f..0e6a7106 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -243,22 +243,18 @@ void Interface :: nocPut( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { -#ifdef LPF_CORE_MPI_USES_zero m_mesgQueue->put( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); -#endif } void Interface :: nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, memslot_t dstSlot, size_t dstOffset, size_t size ) { -#ifdef LPF_CORE_MPI_USES_zero m_mesgQueue->get( srcPid, srcSlot, srcOffset, dstSlot, dstOffset, size ); -#endif } /* end NOC extensions */ diff --git a/src/MPI/memorytable.cpp b/src/MPI/memorytable.cpp index 51947985..c56d26ec 100644 --- a/src/MPI/memorytable.cpp +++ b/src/MPI/memorytable.cpp @@ -24,7 +24,7 @@ namespace lpf { MemoryTable :: MemoryTable( Communication & comm #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - , mpi::IBVerbs & ibverbs + , std::shared_ptr ibverbs #endif ) : m_memreg() @@ -42,11 +42,22 @@ MemoryTable :: MemoryTable( Communication & comm { (void) comm; } +MemoryTable :: Slot +MemoryTable :: addNoc( void * mem, std::size_t size ) // nothrow +{ +#if defined LPF_CORE_MPI_USES_zero || defined LPF_CORE_MPI_USES_ibverbs + Memory rec( mem, size, m_ibverbs->regLocal(mem, size)); +#else + Memory rec(mem, size); +#endif + return m_memreg.addNocReg( rec); +} + MemoryTable :: Slot MemoryTable :: addLocal( void * mem, std::size_t size ) // nothrow { #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - Memory rec( mem, size, m_ibverbs.regLocal( mem, size)); + Memory rec( mem, size, m_ibverbs->regLocal( mem, size)); #else Memory rec( mem, size); #endif @@ -97,7 +108,7 @@ void MemoryTable :: remove( Slot slot ) // nothrow m_added.erase(slot); } else { - m_ibverbs.dereg( m_memreg.lookup(slot).slot ); + m_ibverbs->dereg( m_memreg.lookup(slot).slot ); } m_memreg.removeReg( slot ); #endif @@ -127,7 +138,7 @@ void MemoryTable :: reserve( size_t size ) // throws bad_alloc, strong safe m_memreg.reserve( size ); size_t range = m_memreg.range(); m_added.resize( range ); - m_ibverbs.resizeMemreg( size ); + m_ibverbs->resizeMemreg( size ); #endif m_capacity = size; @@ -204,7 +215,7 @@ void MemoryTable :: sync( ) ASSERT( !isLocalSlot( *i )); void * base = m_memreg.lookup( *i).addr; size_t size = m_memreg.lookup( *i ).size; - mpi::IBVerbs::SlotID s = m_ibverbs.regGlobal( base, size ); + mpi::IBVerbs::SlotID s = m_ibverbs->regGlobal( base, size ); m_memreg.update( *i ).slot = s; } diff --git a/src/MPI/memorytable.hpp b/src/MPI/memorytable.hpp index 05c01eee..e07c43b1 100644 --- a/src/MPI/memorytable.hpp +++ b/src/MPI/memorytable.hpp @@ -65,13 +65,15 @@ class _LPFLIB_LOCAL MemoryTable { return Register::invalidSlot(); } #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - explicit MemoryTable( Communication & comm, mpi::IBVerbs & verbs ); + explicit MemoryTable( Communication & comm, std::shared_ptr verbs ); #else explicit MemoryTable( Communication & comm ); #endif Slot addLocal( void * mem, std::size_t size ) ; // nothrow + Slot addNoc( void * mem, std::size_t size ) ; // nothrow + Slot addGlobal( void * mem, std::size_t size ); // nothrow void remove( Slot slot ); // nothrow @@ -119,7 +121,7 @@ class _LPFLIB_LOCAL MemoryTable #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero DirtyList m_added; - mpi::IBVerbs & m_ibverbs; + std::shared_ptr m_ibverbs; Communication & m_comm; #endif }; diff --git a/src/MPI/mesgqueue.cpp b/src/MPI/mesgqueue.cpp index 27e3330c..7f3211c5 100644 --- a/src/MPI/mesgqueue.cpp +++ b/src/MPI/mesgqueue.cpp @@ -104,7 +104,7 @@ MessageQueue :: MessageQueue( Communication & comm ) , m_bodyRecvs() , m_comm( dynamic_cast(comm) ) #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - , m_ibverbs( m_comm ) + , m_ibverbs(new mpi::IBVerbs(m_comm)) , m_memreg( m_comm, m_ibverbs ) #else , m_memreg( m_comm ) @@ -180,7 +180,7 @@ err_t MessageQueue :: resizeMesgQueue( size_t nMsgs ) m_comm.reserveMsgs( 6* nMsgs ); //another factor three stems from sending edges separately . #endif #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - m_ibverbs.resizeMesgq( 6*nMsgs); + m_ibverbs->resizeMesgq( 6*nMsgs); #endif m_maxNMsgs = maxNMsgs; @@ -246,7 +246,10 @@ err_t MessageQueue :: resizeMemreg( size_t nRegs ) memslot_t MessageQueue :: addNocReg( void * mem, std::size_t size) { - return LPF_INVALID_MEMSLOT; + memslot_t slot = m_memreg.addNoc( mem, size ); + if (size > 0) + m_msgsort.addRegister( slot, static_cast( mem ), size); + return slot; } memslot_t MessageQueue :: addLocalReg( void * mem, std::size_t size) { @@ -276,7 +279,7 @@ void MessageQueue :: get( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, memslot_t dstSlot, size_t dstOffset, size_t size ) { #ifdef LPF_CORE_MPI_USES_zero - m_ibverbs.get(srcPid, + m_ibverbs->get(srcPid, m_memreg.getVerbID( srcSlot), srcOffset, m_memreg.getVerbID( dstSlot), @@ -330,7 +333,7 @@ void MessageQueue :: lockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { #ifdef LPF_CORE_MPI_USES_zero -m_ibverbs.blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 0ULL, 1ULL); +m_ibverbs->blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 0ULL, 1ULL); #endif } @@ -338,7 +341,7 @@ void MessageQueue :: unlockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { #ifdef LPF_CORE_MPI_USES_zero -m_ibverbs.blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 1ULL, 0ULL); +m_ibverbs->blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 1ULL, 0ULL); #endif } @@ -346,7 +349,7 @@ void MessageQueue :: put( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { #ifdef LPF_CORE_MPI_USES_zero - m_ibverbs.put( m_memreg.getVerbID( srcSlot), + m_ibverbs->put( m_memreg.getVerbID( srcSlot), srcOffset, dstPid, m_memreg.getVerbID( dstSlot), @@ -395,7 +398,7 @@ int MessageQueue :: sync( bool abort ) #ifdef LPF_CORE_MPI_USES_zero // if not, deal with normal sync m_memreg.sync(); - m_ibverbs.sync(m_resized); + m_ibverbs->sync(m_resized); m_resized = false; #else @@ -820,14 +823,14 @@ int MessageQueue :: sync( bool abort ) - e.dstOffset + e.srcOffset; if (e.canWriteHead) { - m_ibverbs.get( e.srcPid, m_memreg.getVerbID( e.srcSlot), + m_ibverbs->get( e.srcPid, m_memreg.getVerbID( e.srcSlot), e.srcOffset, m_memreg.getVerbID( m_edgeBufferSlot ), e.bufOffset, headSize ); } if (e.canWriteTail) { - m_ibverbs.get( e.srcPid, m_memreg.getVerbID( e.srcSlot), + m_ibverbs->get( e.srcPid, m_memreg.getVerbID( e.srcSlot), tailOffset, m_memreg.getVerbID( m_edgeBufferSlot ), e.bufOffset + (e.canWriteHead?headSize:0), @@ -878,12 +881,12 @@ int MessageQueue :: sync( bool abort ) #ifdef LPF_CORE_MPI_USES_ibverbs ASSERT( ! m_memreg.isLocalSlot( e.dstSlot ) ) ; if (e.canWriteHead) - m_ibverbs.put( m_memreg.getVerbID( e.srcSlot), e.srcOffset, + m_ibverbs->put( m_memreg.getVerbID( e.srcSlot), e.srcOffset, e.dstPid, m_memreg.getVerbID( m_edgeBufferSlot ), e.bufOffset, headSize ); if (e.canWriteTail) - m_ibverbs.put( m_memreg.getVerbID( e.srcSlot), + m_ibverbs->put( m_memreg.getVerbID( e.srcSlot), e.srcOffset + tailOffset , e.dstPid, m_memreg.getVerbID( m_edgeBufferSlot ), e.bufOffset + (e.canWriteHead?headSize:0), tailSize); @@ -918,7 +921,7 @@ int MessageQueue :: sync( bool abort ) #endif #ifdef LPF_CORE_MPI_USES_ibverbs size_t shift = r.roundedDstOffset - r.dstOffset; - m_ibverbs.get( r.srcPid, + m_ibverbs->get( r.srcPid, m_memreg.getVerbID( r.srcSlot), r.srcOffset + shift, m_memreg.getVerbID( r.dstSlot), r.roundedDstOffset, @@ -950,7 +953,7 @@ int MessageQueue :: sync( bool abort ) r.roundedSize ); #endif #ifdef LPF_CORE_MPI_USES_ibverbs - m_ibverbs.put( m_memreg.getVerbID( r.srcSlot), + m_ibverbs->put( m_memreg.getVerbID( r.srcSlot), r.srcOffset + shift, r.dstPid, m_memreg.getVerbID( r.dstSlot), @@ -974,7 +977,7 @@ int MessageQueue :: sync( bool abort ) m_comm.fenceAll(); #endif #ifdef LPF_CORE_MPI_USES_ibverbs - m_ibverbs.sync( m_resized ); + m_ibverbs->sync( m_resized ); #endif LOG(4, "Copying edges" ); @@ -1031,7 +1034,7 @@ int MessageQueue :: countingSyncPerSlot(SlotID slot, size_t expected_sent, size_ // if not, deal with normal sync m_memreg.sync(); - m_ibverbs.countingSyncPerSlot(m_resized, slot, expected_sent, expected_rcvd); + m_ibverbs->countingSyncPerSlot(m_resized, slot, expected_sent, expected_rcvd); m_resized = false; @@ -1047,7 +1050,7 @@ int MessageQueue :: syncPerSlot(SlotID slot) // if not, deal with normal sync m_memreg.sync(); - m_ibverbs.syncPerSlot(m_resized, slot); + m_ibverbs->syncPerSlot(m_resized, slot); m_resized = false; @@ -1061,7 +1064,7 @@ void MessageQueue :: getRcvdMsgCountPerSlot(size_t * msgs, SlotID slot) #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs.get_rcvd_msg_count_per_slot(msgs, slot); + m_ibverbs->get_rcvd_msg_count_per_slot(msgs, slot); #endif } @@ -1069,7 +1072,7 @@ void MessageQueue :: getRcvdMsgCount(size_t * msgs) { #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs.get_rcvd_msg_count(msgs); + m_ibverbs->get_rcvd_msg_count(msgs); #endif } @@ -1077,21 +1080,21 @@ void MessageQueue :: getSentMsgCountPerSlot(size_t * msgs, SlotID slot) { #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs.get_sent_msg_count_per_slot(msgs, slot); + m_ibverbs->get_sent_msg_count_per_slot(msgs, slot); #endif } void MessageQueue :: flushSent() { #ifdef LPF_CORE_MPI_USES_zero - m_ibverbs.flushSent(); + m_ibverbs->flushSent(); #endif } void MessageQueue :: flushReceived() { #ifdef LPF_CORE_MPI_USES_zero - m_ibverbs.flushReceived(); + m_ibverbs->flushReceived(); #endif } diff --git a/src/MPI/mesgqueue.hpp b/src/MPI/mesgqueue.hpp index 7dc52ccd..fa6d3ee3 100644 --- a/src/MPI/mesgqueue.hpp +++ b/src/MPI/mesgqueue.hpp @@ -165,7 +165,7 @@ class _LPFLIB_LOCAL MessageQueue protected: #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - mpi::IBVerbs m_ibverbs; + std::shared_ptr m_ibverbs; #endif MemoryTable m_memreg; }; diff --git a/src/MPI/mesgqueueNoc.cpp b/src/MPI/mesgqueueNoc.cpp index f7c4f6cb..9f6d4627 100644 --- a/src/MPI/mesgqueueNoc.cpp +++ b/src/MPI/mesgqueueNoc.cpp @@ -13,7 +13,7 @@ namespace lpf memslot_t MessageQueueNoc :: addNocReg( void * mem, std::size_t size ) { - return m_ibverbs.regNoc(mem, size); + return m_ibverbs.regLocal(mem, size); } diff --git a/src/common/memreg.hpp b/src/common/memreg.hpp index 4c92f6c7..a7ad7be1 100644 --- a/src/common/memreg.hpp +++ b/src/common/memreg.hpp @@ -221,7 +221,7 @@ class CombinedMemoryRegister Slot addNocReg( Record record ) // nothrow { - return toNoc( m_local.add( record ) ); + return toNoc( m_noc.add( record ) ); } Slot addGlobalReg( Record record ) // nothrow @@ -245,8 +245,10 @@ class CombinedMemoryRegister return m_local.lookup( fromLocal(slot)); else if (isGlobalSlot(slot)) return m_global.lookup( fromGlobal( slot )); - else // isNocSlot(slot) == true + else {// isNocSlot(slot) == true + printf("THIS IS A NOC SLOT!\n"); return m_noc.lookup( fromNoc( slot )); + } } Record & update( Slot slot ) // nothrow diff --git a/tests/functional/func_lpf_test_noc_register.cpp b/tests/functional/func_lpf_test_noc_register.cpp index c026edbc..304e1cad 100644 --- a/tests/functional/func_lpf_test_noc_register.cpp +++ b/tests/functional/func_lpf_test_noc_register.cpp @@ -55,7 +55,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) * \test Testing a lpf_put with an inactive destination memory slot * \pre P >= 1 * \return Message: destination memory slot was not yet active - * \return Exit code: 6 + * \return Exit code: 0 */ TEST( API, func_lpf_test_noc_register ) { From de50310b5401c138c3ec313b0e5dae52be9b4e17 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Wed, 4 Dec 2024 14:45:16 +0100 Subject: [PATCH 07/28] Revert the use of shared pointers. Nothing really changes, still looking for the reason behind the SIGILL I am getting with the example --- src/MPI/core.cpp | 3 +- src/MPI/ibverbsNoc.cpp | 3 +- src/MPI/interface.cpp | 57 ++++++++++--------- src/MPI/interface.hpp | 2 +- src/MPI/mesgqueue.cpp | 4 ++ src/MPI/mesgqueueNoc.cpp | 4 +- src/common/memreg.hpp | 9 ++- tests/functional/CMakeLists.txt | 2 +- .../functional/func_lpf_test_noc_register.cpp | 6 +- 9 files changed, 53 insertions(+), 37 deletions(-) diff --git a/src/MPI/core.cpp b/src/MPI/core.cpp index 1ec798b4..a386004f 100644 --- a/src/MPI/core.cpp +++ b/src/MPI/core.cpp @@ -412,8 +412,9 @@ lpf_err_t lpf_noc_register( lpf::Interface * i = realContext(ctx); if (i->isAborted()) return LPF_SUCCESS; - + printf("Before nocRegister\n"); *memslot = i->nocRegister(pointer, size); + printf("After nocRegister"); } lpf_err_t lpf_noc_deregister( diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index 520d585b..b32fec56 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -11,6 +11,7 @@ namespace mpi IBVerbs::SlotID IBVerbsNoc :: regLocal( void * addr, size_t size ) { + printf("Enter IBVErbsNoc::regLocal\n"); ASSERT( size <= m_maxRegSize ); MemorySlot slot; @@ -40,7 +41,7 @@ namespace mpi m_memreg.update( id ).glob.resize( m_nprocs ); m_memreg.update( id ).glob[m_pid] = local; - LOG(4, "Memory area " << addr << " of size " << size << " has been locally registered. Slot = " << id ); + LOG(4, "Memory area " << addr << " of size " << size << " has been locally registered as NOC slot. Slot = " << id ); return id; } diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index 0e6a7106..ecfbf5fb 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -75,11 +75,10 @@ void Interface :: initRoot(int *argc, char ***argv) Interface :: Interface( mpi::Comm machine, Process & subprocess ) try : m_comm( machine ) , m_subprocess( subprocess ) -#ifdef LPF_CORE_MPI_USES_zero - , m_mesgQueue( new MessageQueueNoc(m_comm)) -#else - , m_mesgQueue( new MessageQueue(m_comm)) -#endif + +//#if defined (LPF_CORE_MPI_USES_zero) || defined (LPF_CORE_MPI_USES_ibverbs) + ,m_mesgQueue( m_comm) +//#endif , m_aborted( false ) { if ( machine.allreduceOr( false ) ) @@ -99,7 +98,7 @@ void Interface :: put( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue->put( srcSlot, srcOffset, + m_mesgQueue.put( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } @@ -111,7 +110,7 @@ void Interface :: lockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue->lockSlot( srcSlot, srcOffset, + m_mesgQueue.lockSlot( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } @@ -120,36 +119,36 @@ void Interface :: unlockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue->unlockSlot( srcSlot, srcOffset, + m_mesgQueue.unlockSlot( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } void Interface :: getRcvdMsgCountPerSlot(size_t * msgs, SlotID slot) { - m_mesgQueue->getRcvdMsgCountPerSlot(msgs, slot); + m_mesgQueue.getRcvdMsgCountPerSlot(msgs, slot); } void Interface :: getSentMsgCountPerSlot(size_t * msgs, SlotID slot) { - m_mesgQueue->getSentMsgCountPerSlot(msgs, slot); + m_mesgQueue.getSentMsgCountPerSlot(msgs, slot); } void Interface :: flushSent() { - m_mesgQueue->flushSent(); + m_mesgQueue.flushSent(); } void Interface :: flushReceived() { - m_mesgQueue->flushReceived(); + m_mesgQueue.flushReceived(); } void Interface :: getRcvdMsgCount(size_t * msgs) { - m_mesgQueue->getRcvdMsgCount(msgs); + m_mesgQueue.getRcvdMsgCount(msgs); } err_t Interface :: countingSyncPerSlot(memslot_t slot, size_t expected_sent, size_t expected_rcvd) { if ( 0 == m_aborted ) { - m_aborted = m_mesgQueue->countingSyncPerSlot(slot, expected_sent, expected_rcvd); + m_aborted = m_mesgQueue.countingSyncPerSlot(slot, expected_sent, expected_rcvd); return LPF_SUCCESS; } else @@ -162,7 +161,7 @@ err_t Interface :: syncPerSlot(memslot_t slot) { if ( 0 == m_aborted ) { - m_aborted = m_mesgQueue->syncPerSlot(slot); + m_aborted = m_mesgQueue.syncPerSlot(slot); return LPF_SUCCESS; } else @@ -178,34 +177,34 @@ void Interface :: get( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue->get( srcPid, srcSlot, srcOffset, + m_mesgQueue.get( srcPid, srcSlot, srcOffset, dstSlot, dstOffset, size ); } memslot_t Interface :: registerGlobal( void * mem, size_t size ) { - return m_mesgQueue->addGlobalReg( mem, size ); + return m_mesgQueue.addGlobalReg( mem, size ); } memslot_t Interface :: registerLocal( void * mem, size_t size ) { - return m_mesgQueue->addLocalReg( mem, size ); + return m_mesgQueue.addLocalReg( mem, size ); } void Interface :: deregister( memslot_t slot ) { - m_mesgQueue->removeReg( slot ); + m_mesgQueue.removeReg( slot ); } err_t Interface :: resizeMemreg( size_t nRegs ) { - return m_mesgQueue->resizeMemreg( nRegs ); + return m_mesgQueue.resizeMemreg( nRegs ); } err_t Interface :: resizeMesgQueue( size_t nMsgs ) { - return m_mesgQueue->resizeMesgQueue( nMsgs ); + return m_mesgQueue.resizeMesgQueue( nMsgs ); } void Interface :: abort() @@ -219,31 +218,33 @@ void Interface :: abort() #else // signal all other processes at the start of the next 'sync' that // this process aborted. - m_aborted = m_mesgQueue->sync( true ); + m_aborted = m_mesgQueue.sync( true ); #endif } /* start NOC extensions */ memslot_t Interface :: nocRegister( void * mem, size_t size ) { - return m_mesgQueue->addNocReg( mem, size ); + printf("Enter Interface::nocRegister\n"); + memslot_t ret = m_mesgQueue.addNocReg( mem, size ); + printf("Exiting Interface::nocRegister\n"); } void Interface :: nocDeregister( memslot_t slot) { - m_mesgQueue->removeReg(slot); + m_mesgQueue.removeReg(slot); } err_t Interface :: nocResizeMemreg( size_t nRegs ) { - return m_mesgQueue->resizeMemreg(nRegs); + return m_mesgQueue.resizeMemreg(nRegs); } void Interface :: nocPut( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue->put( srcSlot, srcOffset, + m_mesgQueue.put( srcSlot, srcOffset, dstPid, dstSlot, dstOffset, size ); } @@ -252,7 +253,7 @@ void Interface :: nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, memslot_t dstSlot, size_t dstOffset, size_t size ) { - m_mesgQueue->get( srcPid, srcSlot, srcOffset, + m_mesgQueue.get( srcPid, srcSlot, srcOffset, dstSlot, dstOffset, size ); } @@ -267,7 +268,7 @@ err_t Interface :: sync() { if ( 0 == m_aborted ) { - m_aborted = m_mesgQueue->sync( false ); + m_aborted = m_mesgQueue.sync( false ); } if ( 0 == m_aborted ) diff --git a/src/MPI/interface.hpp b/src/MPI/interface.hpp index 5d08dc73..c81cab6e 100644 --- a/src/MPI/interface.hpp +++ b/src/MPI/interface.hpp @@ -120,7 +120,7 @@ class _LPFLIB_LOCAL Interface private: mpi::Comm m_comm; Process & m_subprocess; - std::shared_ptr m_mesgQueue; + MessageQueue m_mesgQueue; pid_t m_aborted; diff --git a/src/MPI/mesgqueue.cpp b/src/MPI/mesgqueue.cpp index 7f3211c5..2ecfe13d 100644 --- a/src/MPI/mesgqueue.cpp +++ b/src/MPI/mesgqueue.cpp @@ -246,11 +246,15 @@ err_t MessageQueue :: resizeMemreg( size_t nRegs ) memslot_t MessageQueue :: addNocReg( void * mem, std::size_t size) { + printf("Enter MessageQueue::addNocReg\n"); memslot_t slot = m_memreg.addNoc( mem, size ); if (size > 0) m_msgsort.addRegister( slot, static_cast( mem ), size); + printf("Will return slot in MessageQueue::addNocReg\n"); return slot; } + + memslot_t MessageQueue :: addLocalReg( void * mem, std::size_t size) { memslot_t slot = m_memreg.addLocal( mem, size ); diff --git a/src/MPI/mesgqueueNoc.cpp b/src/MPI/mesgqueueNoc.cpp index 9f6d4627..e8b3e9fa 100644 --- a/src/MPI/mesgqueueNoc.cpp +++ b/src/MPI/mesgqueueNoc.cpp @@ -10,11 +10,12 @@ namespace lpf MessageQueue(comm) {} + /* memslot_t MessageQueueNoc :: addNocReg( void * mem, std::size_t size ) { + printf("Enter MessageQueueNoc::addNocReg\n"); return m_ibverbs.regLocal(mem, size); - } void MessageQueueNoc :: removeNocReg( memslot_t slot ) @@ -52,6 +53,7 @@ err_t MessageQueueNoc :: nocResizeMemreg( size_t nRegs ) m_ibverbs.resizeMemreg(nRegs); return LPF_SUCCESS; } +*/ } // namespace lpf // diff --git a/src/common/memreg.hpp b/src/common/memreg.hpp index a7ad7be1..f327cb6f 100644 --- a/src/common/memreg.hpp +++ b/src/common/memreg.hpp @@ -221,7 +221,10 @@ class CombinedMemoryRegister Slot addNocReg( Record record ) // nothrow { - return toNoc( m_noc.add( record ) ); + printf("Will call toNoc in addNocReg\n"); + Slot a = toNoc( m_noc.add( record ) ); + printf("Called toNoc in addNocReg\n"); + return a; } Slot addGlobalReg( Record record ) // nothrow @@ -255,8 +258,10 @@ class CombinedMemoryRegister { if (isLocalSlot(slot)) return m_local.update( fromLocal(slot)); - else + else if (isGlobalSlot(slot)) return m_global.update( fromGlobal( slot )); + else // noc Slot + return m_noc.update(fromNoc(slot)); } void reserve( size_t size, const Record & defaultRecord = Record() ) diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 45f142e1..45b0d65c 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -154,7 +154,7 @@ endforeach(LPF_IMPL_ID) set(baseName "func_lpf_test_noc_register") set(debug OFF) set(mode "") - set(LPF_IMPL_ID "ibverbs") + set(LPF_IMPL_ID "zero") set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${baseName}.cpp") diff --git a/tests/functional/func_lpf_test_noc_register.cpp b/tests/functional/func_lpf_test_noc_register.cpp index 304e1cad..48a9afd9 100644 --- a/tests/functional/func_lpf_test_noc_register.cpp +++ b/tests/functional/func_lpf_test_noc_register.cpp @@ -28,7 +28,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t xSlot = LPF_INVALID_MEMSLOT; lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; - lpf_err_t rc = lpf_resize_memory_register( lpf, 2 ); + printf("Hello\n"); + lpf_err_t rc = lpf_resize_memory_register( lpf, 3); EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 1 ); @@ -53,7 +54,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) /** * \test Testing a lpf_put with an inactive destination memory slot - * \pre P >= 1 + * \pre P >= 2 + * \pre P <= 2 * \return Message: destination memory slot was not yet active * \return Exit code: 0 */ From b37b1eb77583c81b6e7231d1736b9d2da330b1f7 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Wed, 4 Dec 2024 17:47:15 +0100 Subject: [PATCH 08/28] Remove use of shared_ptr, suspecting SIGILL is due to that --- src/MPI/ibverbs.hpp | 44 ++++++++++++++++++++++------------------- src/MPI/interface.cpp | 4 ++-- src/MPI/memorytable.cpp | 12 +++++------ src/MPI/memorytable.hpp | 6 +++--- src/MPI/mesgqueue.cpp | 43 ++++++++++++++++++++-------------------- src/MPI/mesgqueue.hpp | 7 +++---- 6 files changed, 60 insertions(+), 56 deletions(-) diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index c36db9d1..0b70be9c 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -61,6 +61,19 @@ using std::tr1::shared_ptr; class _LPFLIB_LOCAL IBVerbs { public: + + struct MemoryRegistration { + void * addr; + size_t size; + uint32_t lkey; + uint32_t rkey; + }; + + struct MemorySlot { + shared_ptr< struct ibv_mr > mr; // verbs structure + std::vector< MemoryRegistration > glob; // array for global registrations + }; + struct Exception; typedef size_t SlotID; @@ -110,7 +123,8 @@ class _LPFLIB_LOCAL IBVerbs void get_rcvd_msg_count(size_t * rcvd_msgs); void get_rcvd_msg_count_per_slot(size_t * rcvd_msgs, SlotID slot); void get_sent_msg_count_per_slot(size_t * sent_msgs, SlotID slot); -protected: + +private: IBVerbs & operator=(const IBVerbs & ); // assignment prohibited IBVerbs( const IBVerbs & ); // copying prohibited @@ -123,20 +137,6 @@ class _LPFLIB_LOCAL IBVerbs void doProgress(); void tryIncrement(Op op, Phase phase, SlotID slot); - struct MemoryRegistration { - void * addr; - size_t size; - uint32_t lkey; - uint32_t rkey; - }; - - struct MemorySlot { - shared_ptr< struct ibv_mr > mr; // verbs structure - std::vector< MemoryRegistration > glob; // array for global registrations - }; - - int m_pid; // local process ID - int m_nprocs; // number of processes std::atomic_size_t m_numMsgs; //std::atomic_size_t m_sendTotalInitMsgCount; std::atomic_size_t m_recvTotalInitMsgCount; @@ -151,9 +151,7 @@ class _LPFLIB_LOCAL IBVerbs int m_gidIdx; uint16_t m_lid; // LID of the IB port ibv_mtu m_mtu; - struct ibv_device_attr m_deviceAttr; - size_t m_maxRegSize; - size_t m_maxMsgSize; + struct ibv_device_attr m_deviceAttr; size_t m_cqSize; size_t m_minNrMsgs; size_t m_maxSrs; // maximum number of sends requests per QP @@ -161,7 +159,6 @@ class _LPFLIB_LOCAL IBVerbs size_t m_recvCount; shared_ptr< struct ibv_context > m_device; // device handle - shared_ptr< struct ibv_pd > m_pd; // protection domain shared_ptr< struct ibv_cq > m_cq; // complation queue shared_ptr< struct ibv_cq > m_cqLocal; // completion queue shared_ptr< struct ibv_cq > m_cqRemote; // completion queue @@ -188,13 +185,20 @@ class _LPFLIB_LOCAL IBVerbs std::vector< struct ibv_sge > m_sges; // array of scatter/gather entries std::vector< struct ibv_wc > m_wcs; // array of work completions - CombinedMemoryRegister< MemorySlot > m_memreg; shared_ptr< struct ibv_mr > m_dummyMemReg; // registration of dummy buffer std::vector< char > m_dummyBuffer; // dummy receive buffer Communication & m_comm; + + protected: + size_t m_maxRegSize; + size_t m_maxMsgSize; + shared_ptr< struct ibv_pd > m_pd; // protection domain + int m_pid; // local process ID + int m_nprocs; // number of processes + CombinedMemoryRegister< MemorySlot > m_memreg; }; diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index ecfbf5fb..30a26ace 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -225,9 +225,9 @@ void Interface :: abort() /* start NOC extensions */ memslot_t Interface :: nocRegister( void * mem, size_t size ) { - printf("Enter Interface::nocRegister\n"); + //printf("Enter Interface::nocRegister\n"); memslot_t ret = m_mesgQueue.addNocReg( mem, size ); - printf("Exiting Interface::nocRegister\n"); + //printf("Exiting Interface::nocRegister\n"); } void Interface :: nocDeregister( memslot_t slot) diff --git a/src/MPI/memorytable.cpp b/src/MPI/memorytable.cpp index c56d26ec..3c94d0fa 100644 --- a/src/MPI/memorytable.cpp +++ b/src/MPI/memorytable.cpp @@ -24,7 +24,7 @@ namespace lpf { MemoryTable :: MemoryTable( Communication & comm #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - , std::shared_ptr ibverbs + , mpi::IBVerbs & ibverbs #endif ) : m_memreg() @@ -46,7 +46,7 @@ MemoryTable :: Slot MemoryTable :: addNoc( void * mem, std::size_t size ) // nothrow { #if defined LPF_CORE_MPI_USES_zero || defined LPF_CORE_MPI_USES_ibverbs - Memory rec( mem, size, m_ibverbs->regLocal(mem, size)); + Memory rec( mem, size, m_ibverbs.regLocal(mem, size)); #else Memory rec(mem, size); #endif @@ -57,7 +57,7 @@ MemoryTable :: Slot MemoryTable :: addLocal( void * mem, std::size_t size ) // nothrow { #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - Memory rec( mem, size, m_ibverbs->regLocal( mem, size)); + Memory rec( mem, size, m_ibverbs.regLocal( mem, size)); #else Memory rec( mem, size); #endif @@ -108,7 +108,7 @@ void MemoryTable :: remove( Slot slot ) // nothrow m_added.erase(slot); } else { - m_ibverbs->dereg( m_memreg.lookup(slot).slot ); + m_ibverbs.dereg( m_memreg.lookup(slot).slot ); } m_memreg.removeReg( slot ); #endif @@ -138,7 +138,7 @@ void MemoryTable :: reserve( size_t size ) // throws bad_alloc, strong safe m_memreg.reserve( size ); size_t range = m_memreg.range(); m_added.resize( range ); - m_ibverbs->resizeMemreg( size ); + m_ibverbs.resizeMemreg( size ); #endif m_capacity = size; @@ -215,7 +215,7 @@ void MemoryTable :: sync( ) ASSERT( !isLocalSlot( *i )); void * base = m_memreg.lookup( *i).addr; size_t size = m_memreg.lookup( *i ).size; - mpi::IBVerbs::SlotID s = m_ibverbs->regGlobal( base, size ); + mpi::IBVerbs::SlotID s = m_ibverbs.regGlobal( base, size ); m_memreg.update( *i ).slot = s; } diff --git a/src/MPI/memorytable.hpp b/src/MPI/memorytable.hpp index e07c43b1..d00cc474 100644 --- a/src/MPI/memorytable.hpp +++ b/src/MPI/memorytable.hpp @@ -23,7 +23,7 @@ #include "assert.hpp" #include "linkage.hpp" -#if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero +#if defined (LPF_CORE_MPI_USES_ibverbs) || defined (LPF_CORE_MPI_USES_zero) #include "ibverbs.hpp" #endif @@ -65,7 +65,7 @@ class _LPFLIB_LOCAL MemoryTable { return Register::invalidSlot(); } #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - explicit MemoryTable( Communication & comm, std::shared_ptr verbs ); + explicit MemoryTable( Communication & comm, mpi::IBVerbs & verbs ); #else explicit MemoryTable( Communication & comm ); #endif @@ -121,7 +121,7 @@ class _LPFLIB_LOCAL MemoryTable #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero DirtyList m_added; - std::shared_ptr m_ibverbs; + mpi::IBVerbs & m_ibverbs; Communication & m_comm; #endif }; diff --git a/src/MPI/mesgqueue.cpp b/src/MPI/mesgqueue.cpp index 2ecfe13d..60ad269c 100644 --- a/src/MPI/mesgqueue.cpp +++ b/src/MPI/mesgqueue.cpp @@ -104,7 +104,7 @@ MessageQueue :: MessageQueue( Communication & comm ) , m_bodyRecvs() , m_comm( dynamic_cast(comm) ) #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - , m_ibverbs(new mpi::IBVerbs(m_comm)) + , m_ibverbs(m_comm) , m_memreg( m_comm, m_ibverbs ) #else , m_memreg( m_comm ) @@ -180,7 +180,7 @@ err_t MessageQueue :: resizeMesgQueue( size_t nMsgs ) m_comm.reserveMsgs( 6* nMsgs ); //another factor three stems from sending edges separately . #endif #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - m_ibverbs->resizeMesgq( 6*nMsgs); + m_ibverbs.resizeMesgq( 6*nMsgs); #endif m_maxNMsgs = maxNMsgs; @@ -248,6 +248,7 @@ memslot_t MessageQueue :: addNocReg( void * mem, std::size_t size) { printf("Enter MessageQueue::addNocReg\n"); memslot_t slot = m_memreg.addNoc( mem, size ); + ASSERT(slot != LPF_INVALID_MEMSLOT); if (size > 0) m_msgsort.addRegister( slot, static_cast( mem ), size); printf("Will return slot in MessageQueue::addNocReg\n"); @@ -283,7 +284,7 @@ void MessageQueue :: get( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, memslot_t dstSlot, size_t dstOffset, size_t size ) { #ifdef LPF_CORE_MPI_USES_zero - m_ibverbs->get(srcPid, + m_ibverbs.get(srcPid, m_memreg.getVerbID( srcSlot), srcOffset, m_memreg.getVerbID( dstSlot), @@ -337,7 +338,7 @@ void MessageQueue :: lockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { #ifdef LPF_CORE_MPI_USES_zero -m_ibverbs->blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 0ULL, 1ULL); +m_ibverbs.blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 0ULL, 1ULL); #endif } @@ -345,7 +346,7 @@ void MessageQueue :: unlockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { #ifdef LPF_CORE_MPI_USES_zero -m_ibverbs->blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 1ULL, 0ULL); +m_ibverbs.blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 1ULL, 0ULL); #endif } @@ -353,7 +354,7 @@ void MessageQueue :: put( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { #ifdef LPF_CORE_MPI_USES_zero - m_ibverbs->put( m_memreg.getVerbID( srcSlot), + m_ibverbs.put( m_memreg.getVerbID( srcSlot), srcOffset, dstPid, m_memreg.getVerbID( dstSlot), @@ -402,7 +403,7 @@ int MessageQueue :: sync( bool abort ) #ifdef LPF_CORE_MPI_USES_zero // if not, deal with normal sync m_memreg.sync(); - m_ibverbs->sync(m_resized); + m_ibverbs.sync(m_resized); m_resized = false; #else @@ -827,14 +828,14 @@ int MessageQueue :: sync( bool abort ) - e.dstOffset + e.srcOffset; if (e.canWriteHead) { - m_ibverbs->get( e.srcPid, m_memreg.getVerbID( e.srcSlot), + m_ibverbs.get( e.srcPid, m_memreg.getVerbID( e.srcSlot), e.srcOffset, m_memreg.getVerbID( m_edgeBufferSlot ), e.bufOffset, headSize ); } if (e.canWriteTail) { - m_ibverbs->get( e.srcPid, m_memreg.getVerbID( e.srcSlot), + m_ibverbs.get( e.srcPid, m_memreg.getVerbID( e.srcSlot), tailOffset, m_memreg.getVerbID( m_edgeBufferSlot ), e.bufOffset + (e.canWriteHead?headSize:0), @@ -885,12 +886,12 @@ int MessageQueue :: sync( bool abort ) #ifdef LPF_CORE_MPI_USES_ibverbs ASSERT( ! m_memreg.isLocalSlot( e.dstSlot ) ) ; if (e.canWriteHead) - m_ibverbs->put( m_memreg.getVerbID( e.srcSlot), e.srcOffset, + m_ibverbs.put( m_memreg.getVerbID( e.srcSlot), e.srcOffset, e.dstPid, m_memreg.getVerbID( m_edgeBufferSlot ), e.bufOffset, headSize ); if (e.canWriteTail) - m_ibverbs->put( m_memreg.getVerbID( e.srcSlot), + m_ibverbs.put( m_memreg.getVerbID( e.srcSlot), e.srcOffset + tailOffset , e.dstPid, m_memreg.getVerbID( m_edgeBufferSlot ), e.bufOffset + (e.canWriteHead?headSize:0), tailSize); @@ -925,7 +926,7 @@ int MessageQueue :: sync( bool abort ) #endif #ifdef LPF_CORE_MPI_USES_ibverbs size_t shift = r.roundedDstOffset - r.dstOffset; - m_ibverbs->get( r.srcPid, + m_ibverbs.get( r.srcPid, m_memreg.getVerbID( r.srcSlot), r.srcOffset + shift, m_memreg.getVerbID( r.dstSlot), r.roundedDstOffset, @@ -957,7 +958,7 @@ int MessageQueue :: sync( bool abort ) r.roundedSize ); #endif #ifdef LPF_CORE_MPI_USES_ibverbs - m_ibverbs->put( m_memreg.getVerbID( r.srcSlot), + m_ibverbs.put( m_memreg.getVerbID( r.srcSlot), r.srcOffset + shift, r.dstPid, m_memreg.getVerbID( r.dstSlot), @@ -981,7 +982,7 @@ int MessageQueue :: sync( bool abort ) m_comm.fenceAll(); #endif #ifdef LPF_CORE_MPI_USES_ibverbs - m_ibverbs->sync( m_resized ); + m_ibverbs.sync( m_resized ); #endif LOG(4, "Copying edges" ); @@ -1038,7 +1039,7 @@ int MessageQueue :: countingSyncPerSlot(SlotID slot, size_t expected_sent, size_ // if not, deal with normal sync m_memreg.sync(); - m_ibverbs->countingSyncPerSlot(m_resized, slot, expected_sent, expected_rcvd); + m_ibverbs.countingSyncPerSlot(m_resized, slot, expected_sent, expected_rcvd); m_resized = false; @@ -1054,7 +1055,7 @@ int MessageQueue :: syncPerSlot(SlotID slot) // if not, deal with normal sync m_memreg.sync(); - m_ibverbs->syncPerSlot(m_resized, slot); + m_ibverbs.syncPerSlot(m_resized, slot); m_resized = false; @@ -1068,7 +1069,7 @@ void MessageQueue :: getRcvdMsgCountPerSlot(size_t * msgs, SlotID slot) #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs->get_rcvd_msg_count_per_slot(msgs, slot); + m_ibverbs.get_rcvd_msg_count_per_slot(msgs, slot); #endif } @@ -1076,7 +1077,7 @@ void MessageQueue :: getRcvdMsgCount(size_t * msgs) { #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs->get_rcvd_msg_count(msgs); + m_ibverbs.get_rcvd_msg_count(msgs); #endif } @@ -1084,21 +1085,21 @@ void MessageQueue :: getSentMsgCountPerSlot(size_t * msgs, SlotID slot) { #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs->get_sent_msg_count_per_slot(msgs, slot); + m_ibverbs.get_sent_msg_count_per_slot(msgs, slot); #endif } void MessageQueue :: flushSent() { #ifdef LPF_CORE_MPI_USES_zero - m_ibverbs->flushSent(); + m_ibverbs.flushSent(); #endif } void MessageQueue :: flushReceived() { #ifdef LPF_CORE_MPI_USES_zero - m_ibverbs->flushReceived(); + m_ibverbs.flushReceived(); #endif } diff --git a/src/MPI/mesgqueue.hpp b/src/MPI/mesgqueue.hpp index fa6d3ee3..a6fc696e 100644 --- a/src/MPI/mesgqueue.hpp +++ b/src/MPI/mesgqueue.hpp @@ -162,11 +162,10 @@ class _LPFLIB_LOCAL MessageQueue std::vector< Body > m_bodyRecvs; mpi::Comm m_comm; std::vector< char > m_tinyMsgBuf; - protected: -#if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - std::shared_ptr m_ibverbs; -#endif + #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero + mpi::IBVerbs m_ibverbs; + #endif MemoryTable m_memreg; }; From 47178f4d03b2041e89bc29a780eaf9471c34cfea Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Thu, 5 Dec 2024 20:32:05 +0100 Subject: [PATCH 09/28] Two important changes. First, refactor the NOC example to be an IBVerbs-based example similar to ibverbs.t.cpp. Second, revert a change in ibverbs.hpp, which created a but -- I changed the order of declaration of attributes, which leads to bugs when using the constructor initializer list. --- src/MPI/CMakeLists.txt | 11 +++ src/MPI/core.cpp | 8 +- src/MPI/func_lpf_test_noc_register.cpp | 89 +++++++++++++++++++ src/MPI/ibverbs.hpp | 44 +++++---- src/MPI/ibverbsNoc.cpp | 6 +- src/MPI/ibverbsNoc.hpp | 2 +- src/MPI/ibverbsZero.cpp | 1 + src/MPI/interface.cpp | 2 +- tests/functional/CMakeLists.txt | 9 -- .../functional/func_lpf_test_noc_register.cpp | 66 -------------- 10 files changed, 131 insertions(+), 107 deletions(-) create mode 100644 src/MPI/func_lpf_test_noc_register.cpp delete mode 100644 tests/functional/func_lpf_test_noc_register.cpp diff --git a/src/MPI/CMakeLists.txt b/src/MPI/CMakeLists.txt index d07bc486..f4fa342b 100644 --- a/src/MPI/CMakeLists.txt +++ b/src/MPI/CMakeLists.txt @@ -201,6 +201,17 @@ if (MPI_FOUND) add_gtest( zero_test "zero" ON ${CMAKE_CURRENT_SOURCE_DIR}/ibverbs.t.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ibverbsZero.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mpilib.cpp) + + # NOC test for HiCR + set(mode "") + set(LPF_IMPL_ID "zero") + set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) + set(exeName "func_lpf_test_noc_register_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") + add_gtest(${exeName} ${LPF_IMPL_ID} ON ${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_test_noc_register.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ibverbsZero.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ibverbsNoc.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mpilib.cpp) + endif() foreach (engine ${MPI_ENGINES}) diff --git a/src/MPI/core.cpp b/src/MPI/core.cpp index a386004f..d0289f0b 100644 --- a/src/MPI/core.cpp +++ b/src/MPI/core.cpp @@ -410,11 +410,9 @@ lpf_err_t lpf_noc_register( ) { lpf::Interface * i = realContext(ctx); - if (i->isAborted()) - return LPF_SUCCESS; - printf("Before nocRegister\n"); - *memslot = i->nocRegister(pointer, size); - printf("After nocRegister"); + if (!i->isAborted()) + *memslot = i->nocRegister(pointer, size); + return LPF_SUCCESS; } lpf_err_t lpf_noc_deregister( diff --git a/src/MPI/func_lpf_test_noc_register.cpp b/src/MPI/func_lpf_test_noc_register.cpp new file mode 100644 index 00000000..12a33d9a --- /dev/null +++ b/src/MPI/func_lpf_test_noc_register.cpp @@ -0,0 +1,89 @@ + +/* + * Copyright 2021 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ibverbsNoc.hpp" +#include "mpilib.hpp" +#include +#include "gtest/gtest.h" + + +using namespace lpf::mpi; + +extern "C" const int LPF_MPI_AUTO_INITIALIZE=0; + + +/** + * \test Testing NOC functionality + * \pre P >= 2 + * \pre P <= 2 + * \return Exit code: 0 + */ +TEST( API, func_lpf_test_noc_register ) +{ + + char buf1[30] = "HELLO\0"; + char buf2[30] = "\0"; + + MPI_Init(NULL, NULL); + Lib::instance(); + Comm * comm = new Comm(); + *comm = Lib::instance().world(); + assert(comm->nprocs() > 0); + comm->barrier(); + IBVerbsNoc * verbs = new IBVerbsNoc( *comm ); + //IBVerbs * verbs = new IBVerbs( *comm ); + + verbs->resizeMemreg(3); + comm->barrier(); + + verbs->resizeMesgq( 2 ); + comm->barrier(); + + IBVerbs::SlotID b1 = verbs->regLocal( buf1, sizeof(buf1) ); + IBVerbs::SlotID b2 = verbs->regLocal( buf2, sizeof(buf2) ); + + + /* + * Every LPF MemorySlot struct consists of + * - shared_ptr + * - std::vector + * + * For global slots, the vector of registrations needs + * to be allgathered. + * In the case of NOC slots, this functionality needs to + * be performed out-of-band + * + * Specific for THIS example, we can use direct + * MPI communication to send to left-hand + * partner the MemoryRegistration information + * Left-hand partner then puts data into the slot + * of its right-hand partner. + */ + + comm->barrier(); + + verbs->put( b1, 0, (comm->pid() + 1)%comm->nprocs(), b2, 0, sizeof(buf1)); + + verbs->sync(true); + // Every process should copy + EXPECT_EQ(buf2, "HELLO\0"); + verbs->dereg(b1); + verbs->dereg(b2); + delete verbs; + delete comm; + MPI_Finalize(); +} diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index 0b70be9c..c36db9d1 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -61,19 +61,6 @@ using std::tr1::shared_ptr; class _LPFLIB_LOCAL IBVerbs { public: - - struct MemoryRegistration { - void * addr; - size_t size; - uint32_t lkey; - uint32_t rkey; - }; - - struct MemorySlot { - shared_ptr< struct ibv_mr > mr; // verbs structure - std::vector< MemoryRegistration > glob; // array for global registrations - }; - struct Exception; typedef size_t SlotID; @@ -123,8 +110,7 @@ class _LPFLIB_LOCAL IBVerbs void get_rcvd_msg_count(size_t * rcvd_msgs); void get_rcvd_msg_count_per_slot(size_t * rcvd_msgs, SlotID slot); void get_sent_msg_count_per_slot(size_t * sent_msgs, SlotID slot); - -private: +protected: IBVerbs & operator=(const IBVerbs & ); // assignment prohibited IBVerbs( const IBVerbs & ); // copying prohibited @@ -137,6 +123,20 @@ class _LPFLIB_LOCAL IBVerbs void doProgress(); void tryIncrement(Op op, Phase phase, SlotID slot); + struct MemoryRegistration { + void * addr; + size_t size; + uint32_t lkey; + uint32_t rkey; + }; + + struct MemorySlot { + shared_ptr< struct ibv_mr > mr; // verbs structure + std::vector< MemoryRegistration > glob; // array for global registrations + }; + + int m_pid; // local process ID + int m_nprocs; // number of processes std::atomic_size_t m_numMsgs; //std::atomic_size_t m_sendTotalInitMsgCount; std::atomic_size_t m_recvTotalInitMsgCount; @@ -151,7 +151,9 @@ class _LPFLIB_LOCAL IBVerbs int m_gidIdx; uint16_t m_lid; // LID of the IB port ibv_mtu m_mtu; - struct ibv_device_attr m_deviceAttr; + struct ibv_device_attr m_deviceAttr; + size_t m_maxRegSize; + size_t m_maxMsgSize; size_t m_cqSize; size_t m_minNrMsgs; size_t m_maxSrs; // maximum number of sends requests per QP @@ -159,6 +161,7 @@ class _LPFLIB_LOCAL IBVerbs size_t m_recvCount; shared_ptr< struct ibv_context > m_device; // device handle + shared_ptr< struct ibv_pd > m_pd; // protection domain shared_ptr< struct ibv_cq > m_cq; // complation queue shared_ptr< struct ibv_cq > m_cqLocal; // completion queue shared_ptr< struct ibv_cq > m_cqRemote; // completion queue @@ -185,20 +188,13 @@ class _LPFLIB_LOCAL IBVerbs std::vector< struct ibv_sge > m_sges; // array of scatter/gather entries std::vector< struct ibv_wc > m_wcs; // array of work completions + CombinedMemoryRegister< MemorySlot > m_memreg; shared_ptr< struct ibv_mr > m_dummyMemReg; // registration of dummy buffer std::vector< char > m_dummyBuffer; // dummy receive buffer Communication & m_comm; - - protected: - size_t m_maxRegSize; - size_t m_maxMsgSize; - shared_ptr< struct ibv_pd > m_pd; // protection domain - int m_pid; // local process ID - int m_nprocs; // number of processes - CombinedMemoryRegister< MemorySlot > m_memreg; }; diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index b32fec56..220f7ccd 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -5,10 +5,14 @@ namespace lpf namespace mpi { - struct IBVerbs::Exception : std::runtime_error { + struct IBVerbsNoc::Exception : std::runtime_error { Exception(const char * what) : std::runtime_error( what ) {} }; + IBVerbsNoc::IBVerbsNoc(Communication & comm) : IBVerbs(comm) + { + } + IBVerbs::SlotID IBVerbsNoc :: regLocal( void * addr, size_t size ) { printf("Enter IBVErbsNoc::regLocal\n"); diff --git a/src/MPI/ibverbsNoc.hpp b/src/MPI/ibverbsNoc.hpp index a1713e79..6926e4c9 100644 --- a/src/MPI/ibverbsNoc.hpp +++ b/src/MPI/ibverbsNoc.hpp @@ -9,7 +9,7 @@ namespace mpi { class _LPFLIB_LOCAL IBVerbsNoc : public IBVerbs { public: - IBVerbsNoc(Communication & comm) : IBVerbs(comm) {} + IBVerbsNoc(Communication & comm); IBVerbs::SlotID regLocal( void * addr, size_t size ); //~IBVerbsNoc() {} diff --git a/src/MPI/ibverbsZero.cpp b/src/MPI/ibverbsZero.cpp index c20b2078..bac48243 100644 --- a/src/MPI/ibverbsZero.cpp +++ b/src/MPI/ibverbsZero.cpp @@ -321,6 +321,7 @@ void IBVerbs :: stageQPs( size_t maxMsgs ) attr.cap.max_recv_sge = 1; struct ibv_qp * const ibv_new_qp_p = ibv_create_qp( m_pd.get(), &attr ); + ASSERT(m_stagedQps.size() > i); if( ibv_new_qp_p == NULL ) { m_stagedQps[i].reset(); } else { diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index 30a26ace..f316bf71 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -226,7 +226,7 @@ void Interface :: abort() memslot_t Interface :: nocRegister( void * mem, size_t size ) { //printf("Enter Interface::nocRegister\n"); - memslot_t ret = m_mesgQueue.addNocReg( mem, size ); + return m_mesgQueue.addNocReg( mem, size ); //printf("Exiting Interface::nocRegister\n"); } diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 45b0d65c..8c321628 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -150,15 +150,6 @@ foreach (LPF_IMPL_ID ${ENGINES}) endforeach(LPF_IMPL_ID) - # NOC test for HiCR - set(baseName "func_lpf_test_noc_register") - set(debug OFF) - set(mode "") - set(LPF_IMPL_ID "zero") - set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) - set(exeName "${baseName}_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") - add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${baseName}.cpp") - include_directories(.) add_subdirectory(debug) diff --git a/tests/functional/func_lpf_test_noc_register.cpp b/tests/functional/func_lpf_test_noc_register.cpp deleted file mode 100644 index 48a9afd9..00000000 --- a/tests/functional/func_lpf_test_noc_register.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -/* - * Copyright 2021 Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "gtest/gtest.h" - - -void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) -{ - (void) args; - int x = 3, y = 6; - lpf_memslot_t xSlot = LPF_INVALID_MEMSLOT; - lpf_memslot_t ySlot = LPF_INVALID_MEMSLOT; - - printf("Hello\n"); - lpf_err_t rc = lpf_resize_memory_register( lpf, 3); - EXPECT_EQ( LPF_SUCCESS, rc ); - - rc = lpf_resize_message_queue( lpf, 1 ); - EXPECT_EQ( LPF_SUCCESS, rc ); - - rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); - EXPECT_EQ( LPF_SUCCESS, rc ); - - rc = lpf_noc_register( lpf, &x, sizeof(x), &xSlot ); - EXPECT_EQ( LPF_SUCCESS, rc ); - - rc = lpf_noc_register( lpf, &y, sizeof(x), &ySlot ); - EXPECT_EQ( LPF_SUCCESS, rc ); - - rc = lpf_noc_put( lpf, ySlot, 0, (pid+1)%nprocs, xSlot, 0, sizeof(x), LPF_MSG_DEFAULT ); - EXPECT_EQ( LPF_SUCCESS, rc ); - rc = lpf_sync(lpf, LPF_SYNC_DEFAULT); - EXPECT_EQ( LPF_SUCCESS, rc ); - // Every process should copy - EXPECT_EQ(x, 6); -} - -/** - * \test Testing a lpf_put with an inactive destination memory slot - * \pre P >= 2 - * \pre P <= 2 - * \return Message: destination memory slot was not yet active - * \return Exit code: 0 - */ -TEST( API, func_lpf_test_noc_register ) -{ - lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); - EXPECT_EQ( LPF_SUCCESS, rc ); -} From 43a6544681dd09e3506df3de906e10e24b4f9fbc Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Fri, 6 Dec 2024 13:17:11 +0100 Subject: [PATCH 10/28] Fix string comparison, it seems I need to convert to std::string or they are not equal --- src/MPI/func_lpf_test_noc_register.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MPI/func_lpf_test_noc_register.cpp b/src/MPI/func_lpf_test_noc_register.cpp index 12a33d9a..992c4116 100644 --- a/src/MPI/func_lpf_test_noc_register.cpp +++ b/src/MPI/func_lpf_test_noc_register.cpp @@ -35,8 +35,10 @@ extern "C" const int LPF_MPI_AUTO_INITIALIZE=0; TEST( API, func_lpf_test_noc_register ) { - char buf1[30] = "HELLO\0"; - char buf2[30] = "\0"; + char buf1[30] = {'\0'}; + char buf2[30] = {'\0'}; + + strcpy(buf1, "HELLO"); MPI_Init(NULL, NULL); Lib::instance(); @@ -80,7 +82,7 @@ TEST( API, func_lpf_test_noc_register ) verbs->sync(true); // Every process should copy - EXPECT_EQ(buf2, "HELLO\0"); + EXPECT_EQ(std::string(buf2), std::string(buf1)); verbs->dereg(b1); verbs->dereg(b2); delete verbs; From b63f5b0e3a567b44f45a3c1e67302247941093d7 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Sat, 7 Dec 2024 13:16:59 +0100 Subject: [PATCH 11/28] First working version! ToDo: implement serializable objects --- src/MPI/func_lpf_test_noc_register.cpp | 28 ++++++++++++++++++++++---- src/MPI/ibverbs.cpp | 1 + src/MPI/ibverbs.hpp | 15 +++++++------- src/MPI/ibverbsNoc.cpp | 13 +++++++++++- src/MPI/ibverbsNoc.hpp | 3 ++- src/MPI/interface.cpp | 2 -- src/common/memreg.hpp | 3 --- 7 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/MPI/func_lpf_test_noc_register.cpp b/src/MPI/func_lpf_test_noc_register.cpp index 992c4116..9908121e 100644 --- a/src/MPI/func_lpf_test_noc_register.cpp +++ b/src/MPI/func_lpf_test_noc_register.cpp @@ -44,10 +44,10 @@ TEST( API, func_lpf_test_noc_register ) Lib::instance(); Comm * comm = new Comm(); *comm = Lib::instance().world(); + int rank = comm->pid(); assert(comm->nprocs() > 0); comm->barrier(); IBVerbsNoc * verbs = new IBVerbsNoc( *comm ); - //IBVerbs * verbs = new IBVerbs( *comm ); verbs->resizeMemreg(3); comm->barrier(); @@ -58,7 +58,6 @@ TEST( API, func_lpf_test_noc_register ) IBVerbs::SlotID b1 = verbs->regLocal( buf1, sizeof(buf1) ); IBVerbs::SlotID b2 = verbs->regLocal( buf2, sizeof(buf2) ); - /* * Every LPF MemorySlot struct consists of * - shared_ptr @@ -75,10 +74,31 @@ TEST( API, func_lpf_test_noc_register ) * Left-hand partner then puts data into the slot * of its right-hand partner. */ - + auto mr = verbs->getMR(b2, rank); + + MPI_Aint addr; + uint32_t rmtLkey, rmtRkey; + MPI_Aint rmtAddr; + size_t rmtSize; + MPI_Get_address(mr.addr, &addr); + + int left = (comm->nprocs() + rank - 1) % comm->nprocs(); + int right = (rank + 1) % comm->nprocs(); + MPI_Sendrecv(&addr, 1, MPI_AINT, left, 0, &rmtAddr, 1, MPI_AINT, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Sendrecv(&mr.lkey, 1, MPI_UINT32_T, left, 0, &rmtLkey, 1, MPI_UINT32_T, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Sendrecv(&mr.rkey, 1, MPI_UINT32_T, left, 0, &rmtRkey, 1, MPI_UINT32_T, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Sendrecv(&mr.size, 1, MPI_AINT, left, 0, &rmtSize, 1, MPI_AINT, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + // translate Aint to address + void * rmtAddrAsPtr = (void *) rmtAddr; + + + // Populate the memory region + IBVerbs::MemoryRegistration newMr{rmtAddrAsPtr, rmtSize, rmtLkey, rmtRkey}; + verbs->setMR(b2, right, newMr); comm->barrier(); - verbs->put( b1, 0, (comm->pid() + 1)%comm->nprocs(), b2, 0, sizeof(buf1)); + + verbs->put( b1, 0, right, b2, 0, sizeof(buf1)); verbs->sync(true); // Every process should copy diff --git a/src/MPI/ibverbs.cpp b/src/MPI/ibverbs.cpp index 5dcdbfc8..a69551cc 100644 --- a/src/MPI/ibverbs.cpp +++ b/src/MPI/ibverbs.cpp @@ -586,6 +586,7 @@ void IBVerbs :: put( SlotID srcSlot, size_t srcOffset, = static_cast(src.glob[m_pid].addr) + srcOffset; const char * remoteAddr = static_cast(dst.glob[dstPid].addr) + dstOffset; + printf("DEBUG: rank %d localAddr %p remoteAddr %p\n", m_pid, localAddr, remoteAddr); sge.addr = reinterpret_cast( localAddr ); sge.length = std::min(size, m_maxMsgSize ); diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index c36db9d1..b8fa077e 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -110,6 +110,14 @@ class _LPFLIB_LOCAL IBVerbs void get_rcvd_msg_count(size_t * rcvd_msgs); void get_rcvd_msg_count_per_slot(size_t * rcvd_msgs, SlotID slot); void get_sent_msg_count_per_slot(size_t * sent_msgs, SlotID slot); + + + struct MemoryRegistration { + void * addr; + size_t size; + uint32_t lkey; + uint32_t rkey; + }; protected: IBVerbs & operator=(const IBVerbs & ); // assignment prohibited IBVerbs( const IBVerbs & ); // copying prohibited @@ -123,13 +131,6 @@ class _LPFLIB_LOCAL IBVerbs void doProgress(); void tryIncrement(Op op, Phase phase, SlotID slot); - struct MemoryRegistration { - void * addr; - size_t size; - uint32_t lkey; - uint32_t rkey; - }; - struct MemorySlot { shared_ptr< struct ibv_mr > mr; // verbs structure std::vector< MemoryRegistration > glob; // array for global registrations diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index 220f7ccd..11f8fc81 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -9,13 +9,24 @@ namespace mpi Exception(const char * what) : std::runtime_error( what ) {} }; + IBVerbsNoc::MemoryRegistration IBVerbsNoc :: getMR(SlotID slotId, int pid) + { + const MemorySlot & slot = m_memreg.lookup( slotId ); + IBVerbsNoc::MemoryRegistration mr = slot.glob[pid]; + return mr; + } + + void IBVerbsNoc::setMR(SlotID slotId, int pid, MemoryRegistration & mr) + { + m_memreg.update(slotId ).glob[pid] = mr; + } + IBVerbsNoc::IBVerbsNoc(Communication & comm) : IBVerbs(comm) { } IBVerbs::SlotID IBVerbsNoc :: regLocal( void * addr, size_t size ) { - printf("Enter IBVErbsNoc::regLocal\n"); ASSERT( size <= m_maxRegSize ); MemorySlot slot; diff --git a/src/MPI/ibverbsNoc.hpp b/src/MPI/ibverbsNoc.hpp index 6926e4c9..d66e8e29 100644 --- a/src/MPI/ibverbsNoc.hpp +++ b/src/MPI/ibverbsNoc.hpp @@ -11,7 +11,8 @@ namespace mpi public: IBVerbsNoc(Communication & comm); IBVerbs::SlotID regLocal( void * addr, size_t size ); - //~IBVerbsNoc() {} + MemoryRegistration getMR(SlotID slotId, int pid); + void setMR(SlotID slotId, int pid, MemoryRegistration & mr); }; } // namespace mpi diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index f316bf71..216089fd 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -225,9 +225,7 @@ void Interface :: abort() /* start NOC extensions */ memslot_t Interface :: nocRegister( void * mem, size_t size ) { - //printf("Enter Interface::nocRegister\n"); return m_mesgQueue.addNocReg( mem, size ); - //printf("Exiting Interface::nocRegister\n"); } void Interface :: nocDeregister( memslot_t slot) diff --git a/src/common/memreg.hpp b/src/common/memreg.hpp index f327cb6f..9e6c4b87 100644 --- a/src/common/memreg.hpp +++ b/src/common/memreg.hpp @@ -221,9 +221,7 @@ class CombinedMemoryRegister Slot addNocReg( Record record ) // nothrow { - printf("Will call toNoc in addNocReg\n"); Slot a = toNoc( m_noc.add( record ) ); - printf("Called toNoc in addNocReg\n"); return a; } @@ -249,7 +247,6 @@ class CombinedMemoryRegister else if (isGlobalSlot(slot)) return m_global.lookup( fromGlobal( slot )); else {// isNocSlot(slot) == true - printf("THIS IS A NOC SLOT!\n"); return m_noc.lookup( fromNoc( slot )); } } From d2d6ce9774308655132b886d7f809e5307c4f22e Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Tue, 10 Dec 2024 10:25:44 +0100 Subject: [PATCH 12/28] Implement serialize/deserialize methods for memory region class. Unfortunately, the implementation is currently not working for binary streams. Investigating still... --- src/MPI/func_lpf_test_noc_register.cpp | 54 +++++++++++++++++++------- src/MPI/ibverbs.cpp | 30 +++++++------- src/MPI/ibverbs.hpp | 54 +++++++++++++++++++++++--- src/MPI/ibverbsNoc.cpp | 12 +++--- src/MPI/ibverbsZero.cpp | 34 ++++++++-------- 5 files changed, 125 insertions(+), 59 deletions(-) diff --git a/src/MPI/func_lpf_test_noc_register.cpp b/src/MPI/func_lpf_test_noc_register.cpp index 9908121e..4d9efa7a 100644 --- a/src/MPI/func_lpf_test_noc_register.cpp +++ b/src/MPI/func_lpf_test_noc_register.cpp @@ -71,33 +71,57 @@ TEST( API, func_lpf_test_noc_register ) * Specific for THIS example, we can use direct * MPI communication to send to left-hand * partner the MemoryRegistration information - * Left-hand partner then puts data into the slot - * of its right-hand partner. */ auto mr = verbs->getMR(b2, rank); - - MPI_Aint addr; - uint32_t rmtLkey, rmtRkey; - MPI_Aint rmtAddr; - size_t rmtSize; - MPI_Get_address(mr.addr, &addr); + char * buffer; + size_t bufSize = mr.serialize(&buffer); + std::cout << " BUF SIZE = " << bufSize << std::endl; + +// MPI_Aint addr; +// uint32_t rmtLkey, rmtRkey; +// MPI_Aint rmtAddr; +// size_t rmtSize; +// MPI_Get_address(mr.addr, &addr); int left = (comm->nprocs() + rank - 1) % comm->nprocs(); int right = (rank + 1) % comm->nprocs(); - MPI_Sendrecv(&addr, 1, MPI_AINT, left, 0, &rmtAddr, 1, MPI_AINT, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Sendrecv(&mr.lkey, 1, MPI_UINT32_T, left, 0, &rmtLkey, 1, MPI_UINT32_T, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Sendrecv(&mr.rkey, 1, MPI_UINT32_T, left, 0, &rmtRkey, 1, MPI_UINT32_T, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Sendrecv(&mr.size, 1, MPI_AINT, left, 0, &rmtSize, 1, MPI_AINT, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + char buff[bufSize]; + char rmtBuff[bufSize]; + size_t lclSize = * (size_t *)(buff + sizeof(char *)); + std::cout << "Got local size = " << lclSize << std::endl; + MPI_Sendrecv(buff, bufSize, MPI_BYTE, left, 0, rmtBuff, bufSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); +// MPI_Sendrecv(&addr, 1, MPI_AINT, left, 0, &rmtAddr, 1, MPI_AINT, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); +// MPI_Sendrecv(&mr.lkey, 1, MPI_UINT32_T, left, 0, &rmtLkey, 1, MPI_UINT32_T, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); +// MPI_Sendrecv(&mr.rkey, 1, MPI_UINT32_T, left, 0, &rmtRkey, 1, MPI_UINT32_T, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); +// MPI_Sendrecv(&mr.size, 1, MPI_AINT, left, 0, &rmtSize, 1, MPI_AINT, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); // translate Aint to address - void * rmtAddrAsPtr = (void *) rmtAddr; + //void * rmtAddrAsPtr = (void *) rmtAddr; + size_t rmtSize = * (size_t *)(rmtBuff + sizeof(char *)); + std::cout << "Got remote size = " << rmtSize << std::endl; // Populate the memory region - IBVerbs::MemoryRegistration newMr{rmtAddrAsPtr, rmtSize, rmtLkey, rmtRkey}; - verbs->setMR(b2, right, newMr); + if (rank == 0) { + for (int i=0; isize = " << newMr->_size << std::endl; + verbs->setMR(b2, right, *newMr); comm->barrier(); + /* Having exchanged out-of-band the slot information, + * each left-hand partner then puts data into the slot + * of its right-hand partner. + */ verbs->put( b1, 0, right, b2, 0, sizeof(buf1)); verbs->sync(true); diff --git a/src/MPI/ibverbs.cpp b/src/MPI/ibverbs.cpp index a69551cc..1de91cc3 100644 --- a/src/MPI/ibverbs.cpp +++ b/src/MPI/ibverbs.cpp @@ -508,10 +508,10 @@ IBVerbs :: SlotID IBVerbs :: regLocal( void * addr, size_t size ) } } MemoryRegistration local; - local.addr = addr; - local.size = size; - local.lkey = size?slot.mr->lkey:0; - local.rkey = size?slot.mr->rkey:0; + local._addr = (char *) addr; + local._size = size; + local._lkey = size?slot.mr->lkey:0; + local._rkey = size?slot.mr->rkey:0; SlotID id = m_memreg.addLocalReg( slot ); @@ -552,10 +552,10 @@ IBVerbs :: SlotID IBVerbs :: regGlobal( void * addr, size_t size ) ref.glob.resize(m_nprocs); MemoryRegistration local; - local.addr = addr; - local.size = size; - local.lkey = size?slot.mr->lkey:0; - local.rkey = size?slot.mr->rkey:0; + local._addr = (char *) addr; + local._size = size; + local._lkey = size?slot.mr->lkey:0; + local._rkey = size?slot.mr->rkey:0; LOG(4, "All-gathering memory register data" ); @@ -583,14 +583,14 @@ void IBVerbs :: put( SlotID srcSlot, size_t srcOffset, struct ibv_send_wr sr; std::memset(&sr, 0, sizeof(sr)); const char * localAddr - = static_cast(src.glob[m_pid].addr) + srcOffset; + = static_cast(src.glob[m_pid]._addr) + srcOffset; const char * remoteAddr - = static_cast(dst.glob[dstPid].addr) + dstOffset; + = static_cast(dst.glob[dstPid]._addr) + dstOffset; printf("DEBUG: rank %d localAddr %p remoteAddr %p\n", m_pid, localAddr, remoteAddr); sge.addr = reinterpret_cast( localAddr ); sge.length = std::min(size, m_maxMsgSize ); - sge.lkey = src.mr->lkey; + sge.lkey = src.mr->lkey; m_sges.push_back( sge ); bool lastMsg = ! m_activePeers.contains( dstPid ); @@ -604,7 +604,7 @@ void IBVerbs :: put( SlotID srcSlot, size_t srcOffset, sr.num_sge = 1; sr.opcode = IBV_WR_RDMA_WRITE; sr.wr.rdma.remote_addr = reinterpret_cast( remoteAddr ); - sr.wr.rdma.rkey = dst.glob[dstPid].rkey; + sr.wr.rdma.rkey = dst.glob[dstPid]._rkey; m_srsHeads[ dstPid ] = m_srs.size(); m_srs.push_back( sr ); @@ -633,9 +633,9 @@ void IBVerbs :: get( int srcPid, SlotID srcSlot, size_t srcOffset, struct ibv_send_wr sr; std::memset(&sr, 0, sizeof(sr)); const char * localAddr - = static_cast(dst.glob[m_pid].addr) + dstOffset; + = static_cast(dst.glob[m_pid]._addr) + dstOffset; const char * remoteAddr - = static_cast(src.glob[srcPid].addr) + srcOffset; + = static_cast(src.glob[srcPid]._addr) + srcOffset; sge.addr = reinterpret_cast( localAddr ); sge.length = std::min(size, m_maxMsgSize ); @@ -653,7 +653,7 @@ void IBVerbs :: get( int srcPid, SlotID srcSlot, size_t srcOffset, sr.num_sge = 1; sr.opcode = IBV_WR_RDMA_READ; sr.wr.rdma.remote_addr = reinterpret_cast( remoteAddr ); - sr.wr.rdma.rkey = src.glob[srcPid].rkey; + sr.wr.rdma.rkey = src.glob[srcPid]._rkey; m_srsHeads[ srcPid ] = m_srs.size(); m_srs.push_back( sr ); diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index b8fa077e..06ac340b 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -58,6 +58,54 @@ using std::shared_ptr; using std::tr1::shared_ptr; #endif +class MemoryRegistration { + public: + char * _addr; + size_t _size; + uint32_t _lkey; + uint32_t _rkey; + MemoryRegistration(char * addr, size_t size, uint32_t lkey, uint32_t rkey) : _addr(addr), + _size(size), _lkey(lkey), _rkey(rkey) + {} + MemoryRegistration() : _addr(nullptr), _size(0), _lkey(0), _rkey(0) + {} + size_t serialize(char ** buf) { + size_t bufSize = sizeof(_addr) + sizeof(_size) + sizeof(_lkey) + sizeof(_rkey); + *buf = new char[bufSize]; + //char * ptr = *buf; + memcpy(&buf[0], &_addr, sizeof(char *)); + //ptr += sizeof(_addr); + memcpy(&buf[sizeof(char *)], &_size, sizeof(size_t)); + std::cout << "SIZE is now = " << * (size_t *) &buf[sizeof(char *)] << " in serialize\n"; + std::cout << "COPYING size = " << _size << " in serialize\n"; + //*ptr += sizeof(_size); + memcpy(&buf[sizeof(char *) + sizeof(size_t)], &_lkey, sizeof(uint32_t)); + //*ptr += sizeof(_rkey); + memcpy(&buf[sizeof(char *) + sizeof(size_t) + sizeof(uint32_t)], &_rkey, sizeof(uint32_t)); + return bufSize; + } + static MemoryRegistration * deserialize(char * buf) { + + char * addr; + size_t size; + uint32_t lkey; + uint32_t rkey; + //char ** ptr = &buf; + memcpy(&addr, &buf, sizeof(char *)); + //*ptr += sizeof(addr); + std::cout << "COPYING addr = " << addr << " in deserialize\n"; + memcpy(&size, &buf[sizeof(char *)], sizeof(size_t)); + std::cout << "COPYING size = " << size << std::endl; + //*ptr += sizeof(size); + memcpy(&lkey, &buf[sizeof(char *) + sizeof(size_t)], sizeof(uint32_t)); + //*ptr += sizeof(lkey); + memcpy(&rkey, &buf[sizeof(char *) + sizeof(size_t) + sizeof(uint32_t)], sizeof(uint32_t)); + return new MemoryRegistration(addr, size, lkey, rkey); + } + +}; + + class _LPFLIB_LOCAL IBVerbs { public: @@ -112,12 +160,6 @@ class _LPFLIB_LOCAL IBVerbs void get_sent_msg_count_per_slot(size_t * sent_msgs, SlotID slot); - struct MemoryRegistration { - void * addr; - size_t size; - uint32_t lkey; - uint32_t rkey; - }; protected: IBVerbs & operator=(const IBVerbs & ); // assignment prohibited IBVerbs( const IBVerbs & ); // copying prohibited diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index 11f8fc81..16e474a7 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -9,10 +9,10 @@ namespace mpi Exception(const char * what) : std::runtime_error( what ) {} }; - IBVerbsNoc::MemoryRegistration IBVerbsNoc :: getMR(SlotID slotId, int pid) + MemoryRegistration IBVerbsNoc :: getMR(SlotID slotId, int pid) { const MemorySlot & slot = m_memreg.lookup( slotId ); - IBVerbsNoc::MemoryRegistration mr = slot.glob[pid]; + MemoryRegistration mr = slot.glob[pid]; return mr; } @@ -47,10 +47,10 @@ namespace mpi } } MemoryRegistration local; - local.addr = addr; - local.size = size; - local.lkey = size?slot.mr->lkey:0; - local.rkey = size?slot.mr->rkey:0; + local._addr = (char *) addr; + local._size = size; + local._lkey = size?slot.mr->lkey:0; + local._rkey = size?slot.mr->rkey:0; SlotID id = m_memreg.addNocReg( slot ); diff --git a/src/MPI/ibverbsZero.cpp b/src/MPI/ibverbsZero.cpp index bac48243..633a1f4e 100644 --- a/src/MPI/ibverbsZero.cpp +++ b/src/MPI/ibverbsZero.cpp @@ -618,10 +618,10 @@ IBVerbs :: SlotID IBVerbs :: regLocal( void * addr, size_t size ) } } MemoryRegistration local; - local.addr = addr; - local.size = size; - local.lkey = size?slot.mr->lkey:0; - local.rkey = size?slot.mr->rkey:0; + local._addr = (char *) addr; + local._size = size; + local._lkey = size?slot.mr->lkey:0; + local._rkey = size?slot.mr->rkey:0; SlotID id = m_memreg.addLocalReg( slot ); tryIncrement(Op::SEND/* <- dummy for init */, Phase::INIT, id); @@ -664,10 +664,10 @@ IBVerbs :: SlotID IBVerbs :: regGlobal( void * addr, size_t size ) ref.glob.resize(m_nprocs); MemoryRegistration local; - local.addr = addr; - local.size = size; - local.lkey = size?slot.mr->lkey:0; - local.rkey = size?slot.mr->rkey:0; + local._addr = (char *) addr; + local._size = size; + local._lkey = size?slot.mr->lkey:0; + local._rkey = size?slot.mr->rkey:0; LOG(4, "All-gathering memory register data" ); @@ -695,9 +695,9 @@ void IBVerbs :: blockingCompareAndSwap(SlotID srcSlot, size_t srcOffset, int dst const MemorySlot & dst = m_memreg.lookup( dstSlot); char * localAddr - = static_cast(src.glob[m_pid].addr) + srcOffset; + = static_cast(src.glob[m_pid]._addr) + srcOffset; const char * remoteAddr - = static_cast(dst.glob[dstPid].addr) + dstOffset; + = static_cast(dst.glob[dstPid]._addr) + dstOffset; struct ibv_sge sge; memset(&sge, 0, sizeof(sge)); @@ -717,7 +717,7 @@ void IBVerbs :: blockingCompareAndSwap(SlotID srcSlot, size_t srcOffset, int dst wr.wr.atomic.remote_addr = reinterpret_cast(remoteAddr); wr.wr.atomic.compare_add = compare_add; wr.wr.atomic.swap = swap; - wr.wr.atomic.rkey = dst.glob[dstPid].rkey; + wr.wr.atomic.rkey = dst.glob[dstPid]._rkey; struct ibv_send_wr *bad_wr; int error; std::vector opcodes; @@ -777,9 +777,9 @@ void IBVerbs :: put( SlotID srcSlot, size_t srcOffset, sge = &sges[i]; std::memset(sge, 0, sizeof(ibv_sge)); sr = &srs[i]; std::memset(sr, 0, sizeof(ibv_send_wr)); const char * localAddr - = static_cast(src.glob[m_pid].addr) + srcOffset; + = static_cast(src.glob[m_pid]._addr) + srcOffset; const char * remoteAddr - = static_cast(dst.glob[dstPid].addr) + dstOffset; + = static_cast(dst.glob[dstPid]._addr) + dstOffset; sge->addr = reinterpret_cast( localAddr ); sge->length = std::min(size, m_maxMsgSize ); @@ -803,7 +803,7 @@ void IBVerbs :: put( SlotID srcSlot, size_t srcOffset, sr->sg_list = &sges[i]; sr->num_sge = 1; sr->wr.rdma.remote_addr = reinterpret_cast( remoteAddr ); - sr->wr.rdma.rkey = dst.glob[dstPid].rkey; + sr->wr.rdma.rkey = dst.glob[dstPid]._rkey; srs[i] = *sr; size -= sge->length; @@ -845,9 +845,9 @@ void IBVerbs :: get( int srcPid, SlotID srcSlot, size_t srcOffset, sr = &srs[i]; std::memset(sr, 0, sizeof(ibv_send_wr)); const char * localAddr - = static_cast(dst.glob[m_pid].addr) + dstOffset; + = static_cast(dst.glob[m_pid]._addr) + dstOffset; const char * remoteAddr - = static_cast(src.glob[srcPid].addr) + srcOffset; + = static_cast(src.glob[srcPid]._addr) + srcOffset; sge->addr = reinterpret_cast( localAddr ); sge->length = std::min(size, m_maxMsgSize ); @@ -863,7 +863,7 @@ void IBVerbs :: get( int srcPid, SlotID srcSlot, size_t srcOffset, sr->num_sge = 1; sr->opcode = IBV_WR_RDMA_READ; sr->wr.rdma.remote_addr = reinterpret_cast( remoteAddr ); - sr->wr.rdma.rkey = src.glob[srcPid].rkey; + sr->wr.rdma.rkey = src.glob[srcPid]._rkey; // This logic is reversed compared to ::put // (not srcSlot, as this slot is remote) sr->wr_id = dstSlot; // <= DO NOT CHANGE THIS !!! From bfed254426c02b463638f5a6237d81b5e4ad68c6 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Wed, 11 Dec 2024 21:26:11 +0100 Subject: [PATCH 13/28] Working version using strings for serialize/deserialize. Will improve to binary now --- src/MPI/func_lpf_test_noc_register.cpp | 41 ++++----------------- src/MPI/ibverbs.hpp | 51 ++++++++++++++------------ src/MPI/ibverbsNoc.cpp | 5 +-- 3 files changed, 38 insertions(+), 59 deletions(-) diff --git a/src/MPI/func_lpf_test_noc_register.cpp b/src/MPI/func_lpf_test_noc_register.cpp index 4d9efa7a..85c185ff 100644 --- a/src/MPI/func_lpf_test_noc_register.cpp +++ b/src/MPI/func_lpf_test_noc_register.cpp @@ -72,48 +72,23 @@ TEST( API, func_lpf_test_noc_register ) * MPI communication to send to left-hand * partner the MemoryRegistration information */ - auto mr = verbs->getMR(b2, rank); + auto mr = verbs->getMR(b1, rank); + mr = verbs->getMR(b2, rank); + assert(mr._addr != nullptr); char * buffer; size_t bufSize = mr.serialize(&buffer); - std::cout << " BUF SIZE = " << bufSize << std::endl; - -// MPI_Aint addr; -// uint32_t rmtLkey, rmtRkey; -// MPI_Aint rmtAddr; -// size_t rmtSize; -// MPI_Get_address(mr.addr, &addr); + std::string bufAsString(buffer); int left = (comm->nprocs() + rank - 1) % comm->nprocs(); int right = (rank + 1) % comm->nprocs(); - char buff[bufSize]; char rmtBuff[bufSize]; - size_t lclSize = * (size_t *)(buff + sizeof(char *)); - std::cout << "Got local size = " << lclSize << std::endl; - MPI_Sendrecv(buff, bufSize, MPI_BYTE, left, 0, rmtBuff, bufSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); -// MPI_Sendrecv(&addr, 1, MPI_AINT, left, 0, &rmtAddr, 1, MPI_AINT, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); -// MPI_Sendrecv(&mr.lkey, 1, MPI_UINT32_T, left, 0, &rmtLkey, 1, MPI_UINT32_T, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); -// MPI_Sendrecv(&mr.rkey, 1, MPI_UINT32_T, left, 0, &rmtRkey, 1, MPI_UINT32_T, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); -// MPI_Sendrecv(&mr.size, 1, MPI_AINT, left, 0, &rmtSize, 1, MPI_AINT, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - // translate Aint to address - //void * rmtAddrAsPtr = (void *) rmtAddr; - - size_t rmtSize = * (size_t *)(rmtBuff + sizeof(char *)); - std::cout << "Got remote size = " << rmtSize << std::endl; + std::stringstream ss(buffer); + + MPI_Sendrecv(buffer, bufSize, MPI_BYTE, left, 0, rmtBuff, bufSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); // Populate the memory region - if (rank == 0) { - for (int i=0; isize = " << newMr->_size << std::endl; verbs->setMR(b2, right, *newMr); comm->barrier(); diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index 06ac340b..c178b6b4 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -70,19 +70,13 @@ class MemoryRegistration { MemoryRegistration() : _addr(nullptr), _size(0), _lkey(0), _rkey(0) {} size_t serialize(char ** buf) { - size_t bufSize = sizeof(_addr) + sizeof(_size) + sizeof(_lkey) + sizeof(_rkey); - *buf = new char[bufSize]; - //char * ptr = *buf; - memcpy(&buf[0], &_addr, sizeof(char *)); - //ptr += sizeof(_addr); - memcpy(&buf[sizeof(char *)], &_size, sizeof(size_t)); - std::cout << "SIZE is now = " << * (size_t *) &buf[sizeof(char *)] << " in serialize\n"; - std::cout << "COPYING size = " << _size << " in serialize\n"; - //*ptr += sizeof(_size); - memcpy(&buf[sizeof(char *) + sizeof(size_t)], &_lkey, sizeof(uint32_t)); - //*ptr += sizeof(_rkey); - memcpy(&buf[sizeof(char *) + sizeof(size_t) + sizeof(uint32_t)], &_rkey, sizeof(uint32_t)); - return bufSize; + std::stringstream ss; + ss << reinterpret_cast(_addr) << "-"<< _size << "-" << _lkey << "-" << _rkey; + std::string asStr = ss.str(); + *buf = new char[strlen(asStr.c_str())]; + strcpy(*buf, asStr.c_str()); + std::string s1; + return asStr.size(); } static MemoryRegistration * deserialize(char * buf) { @@ -90,16 +84,27 @@ class MemoryRegistration { size_t size; uint32_t lkey; uint32_t rkey; - //char ** ptr = &buf; - memcpy(&addr, &buf, sizeof(char *)); - //*ptr += sizeof(addr); - std::cout << "COPYING addr = " << addr << " in deserialize\n"; - memcpy(&size, &buf[sizeof(char *)], sizeof(size_t)); - std::cout << "COPYING size = " << size << std::endl; - //*ptr += sizeof(size); - memcpy(&lkey, &buf[sizeof(char *) + sizeof(size_t)], sizeof(uint32_t)); - //*ptr += sizeof(lkey); - memcpy(&rkey, &buf[sizeof(char *) + sizeof(size_t) + sizeof(uint32_t)], sizeof(uint32_t)); + std::stringstream ss(buf); + std::string tokens[4]; + std::getline(ss, tokens[0], '-'); + std::stringstream ss2; + ss2 << tokens[0]; + uintptr_t addrAsUintPtr; + ss2 >> addrAsUintPtr; + addr = reinterpret_cast(addrAsUintPtr); + std::getline(ss, tokens[1], '-'); + ss2.clear(); + ss2 << tokens[1]; + ss2 >> size; + std::getline(ss, tokens[2], '-'); + ss2.clear(); + ss2 << tokens[2]; + ss2 >> lkey; + std::getline(ss, tokens[3], '\0'); + ss2.clear(); + ss2 << tokens[3]; + ss2 >> rkey; + return new MemoryRegistration(addr, size, lkey, rkey); } diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index 16e474a7..ef6c40e5 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -12,13 +12,12 @@ namespace mpi MemoryRegistration IBVerbsNoc :: getMR(SlotID slotId, int pid) { const MemorySlot & slot = m_memreg.lookup( slotId ); - MemoryRegistration mr = slot.glob[pid]; - return mr; + return slot.glob[pid]; } void IBVerbsNoc::setMR(SlotID slotId, int pid, MemoryRegistration & mr) { - m_memreg.update(slotId ).glob[pid] = mr; + m_memreg.update(slotId).glob[pid] = mr; } IBVerbsNoc::IBVerbsNoc(Communication & comm) : IBVerbs(comm) From d121723730ff86adb4de31766bd8046006ec5463 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Wed, 11 Dec 2024 21:35:29 +0100 Subject: [PATCH 14/28] Replace string and string stream with direct binary copying via memcpy --- src/MPI/ibverbs.hpp | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index c178b6b4..c5e09deb 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -71,12 +71,18 @@ class MemoryRegistration { {} size_t serialize(char ** buf) { std::stringstream ss; - ss << reinterpret_cast(_addr) << "-"<< _size << "-" << _lkey << "-" << _rkey; - std::string asStr = ss.str(); - *buf = new char[strlen(asStr.c_str())]; - strcpy(*buf, asStr.c_str()); - std::string s1; - return asStr.size(); + size_t bufSize = sizeof(uintptr_t) + sizeof(size_t) + 2*sizeof(uint32_t); + *buf = new char[bufSize]; + char *ptr = *buf; + uintptr_t addrAsUintPtr = reinterpret_cast(_addr); + memcpy(ptr, &addrAsUintPtr, sizeof(uintptr_t)); + ptr += sizeof(uintptr_t); + memcpy(ptr, &_size, sizeof(size_t)); + ptr += sizeof(size_t); + memcpy(ptr, &_lkey, sizeof(uint32_t)); + ptr += sizeof(uint32_t); + memcpy(ptr, &_rkey, sizeof(uint32_t)); + return bufSize; } static MemoryRegistration * deserialize(char * buf) { @@ -84,27 +90,16 @@ class MemoryRegistration { size_t size; uint32_t lkey; uint32_t rkey; - std::stringstream ss(buf); - std::string tokens[4]; - std::getline(ss, tokens[0], '-'); - std::stringstream ss2; - ss2 << tokens[0]; uintptr_t addrAsUintPtr; - ss2 >> addrAsUintPtr; + char * ptr = buf; + memcpy(&addrAsUintPtr, ptr, sizeof(uintptr_t)); addr = reinterpret_cast(addrAsUintPtr); - std::getline(ss, tokens[1], '-'); - ss2.clear(); - ss2 << tokens[1]; - ss2 >> size; - std::getline(ss, tokens[2], '-'); - ss2.clear(); - ss2 << tokens[2]; - ss2 >> lkey; - std::getline(ss, tokens[3], '\0'); - ss2.clear(); - ss2 << tokens[3]; - ss2 >> rkey; - + ptr += sizeof(uintptr_t); + memcpy(&size, ptr, sizeof(size_t)); + ptr += sizeof(size_t); + memcpy(&lkey, ptr, sizeof(uint32_t)); + ptr += sizeof(uint32_t); + memcpy(&rkey, ptr, sizeof(uint32_t)); return new MemoryRegistration(addr, size, lkey, rkey); } From 9d3a1d99845b390cc2545c5ac2de8a7b53b92bb5 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Thu, 12 Dec 2024 10:19:21 +0100 Subject: [PATCH 15/28] Implemented Noc within LPF layer (not only IBVerbs). Now fixing compiler warnings --- CMakeLists.txt | 4 +- include/lpf/noc.h | 23 ++++++++- src/MPI/CMakeLists.txt | 4 +- src/MPI/core.cpp | 28 +++++++++++ ...r.cpp => func_verbs_test_noc_register.cpp} | 0 src/MPI/ibverbs.cpp | 9 +++- src/MPI/ibverbs.hpp | 35 +------------- src/MPI/ibverbsNoc.cpp | 35 ++++++++++++++ src/MPI/interface.cpp | 10 ++++ src/MPI/interface.hpp | 4 ++ src/MPI/mesgqueue.cpp | 31 +++++++++++- src/MPI/mesgqueue.hpp | 18 ++++--- src/imp/core.c | 48 +++++++++++++++++++ src/pthreads/barrier.cpp | 10 ++-- src/pthreads/core.cpp | 2 + src/pthreads/threadlocaldata.cpp | 4 ++ tests/functional/CMakeLists.txt | 8 ++++ 17 files changed, 221 insertions(+), 52 deletions(-) rename src/MPI/{func_lpf_test_noc_register.cpp => func_verbs_test_noc_register.cpp} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0850a84..c6f1aa53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -194,10 +194,10 @@ message( STATUS "The following engines will be built: ${ENGINES}") # Enable all warning diagnostics by default if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wfatal-errors -Wall -Wextra") endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wfatal-errors -Wall -Wextra") endif() if (CMAKE_C_COMPILER_ID STREQUAL "Clang") set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") diff --git a/include/lpf/noc.h b/include/lpf/noc.h index 6f46442f..0b878c3b 100644 --- a/include/lpf/noc.h +++ b/include/lpf/noc.h @@ -272,7 +272,7 @@ lpf_err_t lpf_noc_register( * corresponding to \a memslot. */ extern _LPFLIB_API -lpf_err_t lpf_deregister( +lpf_err_t lpf_noc_deregister( lpf_t ctx, lpf_memslot_t memslot ); @@ -438,6 +438,27 @@ lpf_err_t lpf_noc_get( lpf_msg_attr_t attr ); +extern _LPFLIB_API +lpf_err_t lpf_serialize_slot( + lpf_t ctx, + lpf_memslot_t slot, + char ** buff, + size_t * buff_size +); +/* + * lpf_deserialize_slot may only be called on a slot + * already registered via lpf_noc_register. + * This call sets the memory registration attributes from + * the byte array buff with byte size buff_size. + * This array must have been created via a call to + * @lpf_serialize_slot + */ +extern _LPFLIB_API + lpf_err_t lpf_deserialize_slot( + lpf_t ctx, + char * buff, + lpf_memslot_t slot +); /** * @} * diff --git a/src/MPI/CMakeLists.txt b/src/MPI/CMakeLists.txt index f4fa342b..55ba3e94 100644 --- a/src/MPI/CMakeLists.txt +++ b/src/MPI/CMakeLists.txt @@ -206,8 +206,8 @@ if (MPI_FOUND) set(mode "") set(LPF_IMPL_ID "zero") set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) - set(exeName "func_lpf_test_noc_register_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") - add_gtest(${exeName} ${LPF_IMPL_ID} ON ${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_test_noc_register.cpp + set(exeName "func_verbs_test_noc_register_${LPF_IMPL_ID}_${LPF_IMPL_CONFIG}${mode}") + add_gtest(${exeName} ${LPF_IMPL_ID} ON ${CMAKE_CURRENT_SOURCE_DIR}/func_verbs_test_noc_register.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ibverbsZero.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ibverbsNoc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mpilib.cpp) diff --git a/src/MPI/core.cpp b/src/MPI/core.cpp index d0289f0b..c71b39bd 100644 --- a/src/MPI/core.cpp +++ b/src/MPI/core.cpp @@ -468,3 +468,31 @@ lpf_err_t lpf_noc_get( return LPF_SUCCESS; } +lpf_err_t lpf_serialize_slot( + lpf_t ctx, + lpf_memslot_t slot, + char ** buff, + size_t * buff_size +) +{ + lpf::Interface * i = realContext(ctx); + if (!i->isAborted()) + return i->serializeSlot(slot, buff, buff_size); + + return LPF_ERR_FATAL; +} + +lpf_err_t lpf_deserialize_slot( + lpf_t ctx, + char * buff, + lpf_memslot_t slot +) +{ + lpf::Interface * i = realContext(ctx); + if (!i->isAborted()) + return i->deserializeSlot( buff, slot); + + return LPF_ERR_FATAL; + +} + diff --git a/src/MPI/func_lpf_test_noc_register.cpp b/src/MPI/func_verbs_test_noc_register.cpp similarity index 100% rename from src/MPI/func_lpf_test_noc_register.cpp rename to src/MPI/func_verbs_test_noc_register.cpp diff --git a/src/MPI/ibverbs.cpp b/src/MPI/ibverbs.cpp index 1de91cc3..2cfe0342 100644 --- a/src/MPI/ibverbs.cpp +++ b/src/MPI/ibverbs.cpp @@ -45,6 +45,14 @@ namespace { } } +size_t MemoryRegistration :: serialize(char ** buf) { + throw IBVerbs::Exception( "MemoryRegistration::serialize(char ** buf) not implemented for base IBVerbs class"); +} + +MemoryRegistration * MemoryRegistration :: deserialize(char * buf) +{ + throw IBVerbs::Exception( "MemoryRegistration::deserialize(char * buf) not implemented for base IBVerbs class"); +} IBVerbs :: IBVerbs( Communication & comm ) : m_pid( comm.pid() ) @@ -97,7 +105,6 @@ IBVerbs :: IBVerbs( Communication & comm ) throw Exception( "No Infiniband devices available" ); } - std::string wantDevName = Config::instance().getIBDeviceName(); LOG( 3, "Searching for device '"<< wantDevName << "'" ); struct ibv_device * dev = NULL; diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index c5e09deb..db964ff4 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -69,39 +69,8 @@ class MemoryRegistration { {} MemoryRegistration() : _addr(nullptr), _size(0), _lkey(0), _rkey(0) {} - size_t serialize(char ** buf) { - std::stringstream ss; - size_t bufSize = sizeof(uintptr_t) + sizeof(size_t) + 2*sizeof(uint32_t); - *buf = new char[bufSize]; - char *ptr = *buf; - uintptr_t addrAsUintPtr = reinterpret_cast(_addr); - memcpy(ptr, &addrAsUintPtr, sizeof(uintptr_t)); - ptr += sizeof(uintptr_t); - memcpy(ptr, &_size, sizeof(size_t)); - ptr += sizeof(size_t); - memcpy(ptr, &_lkey, sizeof(uint32_t)); - ptr += sizeof(uint32_t); - memcpy(ptr, &_rkey, sizeof(uint32_t)); - return bufSize; - } - static MemoryRegistration * deserialize(char * buf) { - - char * addr; - size_t size; - uint32_t lkey; - uint32_t rkey; - uintptr_t addrAsUintPtr; - char * ptr = buf; - memcpy(&addrAsUintPtr, ptr, sizeof(uintptr_t)); - addr = reinterpret_cast(addrAsUintPtr); - ptr += sizeof(uintptr_t); - memcpy(&size, ptr, sizeof(size_t)); - ptr += sizeof(size_t); - memcpy(&lkey, ptr, sizeof(uint32_t)); - ptr += sizeof(uint32_t); - memcpy(&rkey, ptr, sizeof(uint32_t)); - return new MemoryRegistration(addr, size, lkey, rkey); - } + size_t serialize(char ** buf); + static MemoryRegistration * deserialize(char * buf); }; diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index ef6c40e5..6c0d7f1d 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -5,6 +5,41 @@ namespace lpf namespace mpi { + size_t MemoryRegistration :: serialize(char ** buf) { + std::stringstream ss; + size_t bufSize = sizeof(uintptr_t) + sizeof(size_t) + 2*sizeof(uint32_t); + *buf = new char[bufSize]; + char *ptr = *buf; + uintptr_t addrAsUintPtr = reinterpret_cast(_addr); + memcpy(ptr, &addrAsUintPtr, sizeof(uintptr_t)); + ptr += sizeof(uintptr_t); + memcpy(ptr, &_size, sizeof(size_t)); + ptr += sizeof(size_t); + memcpy(ptr, &_lkey, sizeof(uint32_t)); + ptr += sizeof(uint32_t); + memcpy(ptr, &_rkey, sizeof(uint32_t)); + return bufSize; + } + + MemoryRegistration * MemoryRegistration :: deserialize(char * buf) { + + char * addr; + size_t size; + uint32_t lkey; + uint32_t rkey; + uintptr_t addrAsUintPtr; + char * ptr = buf; + memcpy(&addrAsUintPtr, ptr, sizeof(uintptr_t)); + addr = reinterpret_cast(addrAsUintPtr); + ptr += sizeof(uintptr_t); + memcpy(&size, ptr, sizeof(size_t)); + ptr += sizeof(size_t); + memcpy(&lkey, ptr, sizeof(uint32_t)); + ptr += sizeof(uint32_t); + memcpy(&rkey, ptr, sizeof(uint32_t)); + return new MemoryRegistration(addr, size, lkey, rkey); + } + struct IBVerbsNoc::Exception : std::runtime_error { Exception(const char * what) : std::runtime_error( what ) {} }; diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index 216089fd..1223bfb2 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -255,6 +255,16 @@ void Interface :: nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, dstSlot, dstOffset, size ); } + +err_t Interface :: serializeSlot(SlotID slot, char ** buff, size_t *buff_size) +{ + return m_mesgQueue.serializeSlot(slot, buff, buff_size); +} + +err_t Interface :: deserializeSlot(char * buff, SlotID slot) +{ + return m_mesgQueue.deserializeSlot(buff, slot); +} /* end NOC extensions */ pid_t Interface :: isAborted() const diff --git a/src/MPI/interface.hpp b/src/MPI/interface.hpp index c81cab6e..dee8583e 100644 --- a/src/MPI/interface.hpp +++ b/src/MPI/interface.hpp @@ -73,6 +73,10 @@ class _LPFLIB_LOCAL Interface void nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, memslot_t dstSlot, size_t dstOffset, size_t size ) ;// nothrow + + err_t serializeSlot(memslot_t slot, char ** buff, size_t *buff_size); + + err_t deserializeSlot(char * buff, memslot_t slot); /* end NOC extensions */ pid_t isAborted() const ; diff --git a/src/MPI/mesgqueue.cpp b/src/MPI/mesgqueue.cpp index 60ad269c..19810bb3 100644 --- a/src/MPI/mesgqueue.cpp +++ b/src/MPI/mesgqueue.cpp @@ -16,6 +16,7 @@ */ #include "mesgqueue.hpp" +#include "ibverbs.hpp" #include "mpilib.hpp" #include "log.hpp" #include "assert.hpp" @@ -246,15 +247,41 @@ err_t MessageQueue :: resizeMemreg( size_t nRegs ) memslot_t MessageQueue :: addNocReg( void * mem, std::size_t size) { - printf("Enter MessageQueue::addNocReg\n"); memslot_t slot = m_memreg.addNoc( mem, size ); ASSERT(slot != LPF_INVALID_MEMSLOT); if (size > 0) m_msgsort.addRegister( slot, static_cast( mem ), size); - printf("Will return slot in MessageQueue::addNocReg\n"); return slot; } +err_t MessageQueue :: serializeSlot(SlotID slot, char ** mem, std::size_t * size) +{ + ASSERT(slot != LPF_INVALID_MEMSLOT); +#ifdef LPF_CORE_MPI_USES_zero + auto mr = m_ibverbs.getMR(slot, m_pid); + *size = mr.serialize(mem); + return LPF_SUCCESS; +#else + LOG( 3, "Error: serialize slot is only implemented for zero engine at the moment."); + return LPF_ERR_FATAL; +#endif + +} + +err_t MessageQueue :: deserializeSlot(char * mem, SlotID slot) +{ + ASSERT(slot != LPF_INVALID_MEMSLOT); +#ifdef LPF_CORE_MPI_USES_zero + auto mr = mpi::MemoryRegistration::deserialize(mem); + m_ibverbs.setMR(slot, m_pid, *mr); + return LPF_SUCCESS; +#else + LOG( 3, "Error: deserialize slot is only implemented for zero engine at the moment."); + return LPF_ERR_FATAL; +#endif + +} + memslot_t MessageQueue :: addLocalReg( void * mem, std::size_t size) { diff --git a/src/MPI/mesgqueue.hpp b/src/MPI/mesgqueue.hpp index a6fc696e..ee4d2ddc 100644 --- a/src/MPI/mesgqueue.hpp +++ b/src/MPI/mesgqueue.hpp @@ -33,7 +33,7 @@ #include #endif -#if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero +#if defined LPF_CORE_MPI_USES_zero #include "ibverbsNoc.hpp" #endif @@ -53,8 +53,9 @@ class _LPFLIB_LOCAL MessageQueue memslot_t addLocalReg( void * mem, std::size_t size ); + memslot_t addGlobalReg( void * mem, std::size_t size ); - memslot_t addNocReg( void * mem, std::size_t size ); + void removeReg( memslot_t slot ); void get( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, @@ -68,7 +69,6 @@ class _LPFLIB_LOCAL MessageQueue int sync( bool abort ); //only for HiCR -//#ifdef void lockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ); @@ -88,8 +88,12 @@ class _LPFLIB_LOCAL MessageQueue int countingSyncPerSlot(SlotID slot, size_t expected_sent, size_t expected_rcvd); int syncPerSlot(SlotID slot); + // NOC extensions + memslot_t addNocReg( void * mem, std::size_t size ); + + err_t serializeSlot(memslot_t slot, char ** buff, std::size_t * buff_size); + err_t deserializeSlot(char * buff, memslot_t slot); // end only for HiCR -//#endif private: enum Msgs { BufPut , @@ -163,9 +167,11 @@ class _LPFLIB_LOCAL MessageQueue mpi::Comm m_comm; std::vector< char > m_tinyMsgBuf; protected: - #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero +#if defined LPF_CORE_MPI_USES_ibverbs mpi::IBVerbs m_ibverbs; - #endif +#elif defined LPF_CORE_MPI_USES_zero + mpi::IBVerbsNoc m_ibverbs; +#endif MemoryTable m_memreg; }; diff --git a/src/imp/core.c b/src/imp/core.c index a9c7ceb1..5caf0840 100644 --- a/src/imp/core.c +++ b/src/imp/core.c @@ -142,6 +142,9 @@ lpf_err_t lpf_counting_sync_per_slot( lpf_t lpf, lpf_sync_attr_t attr, lpf_memsl { (void) lpf; (void) attr; + (void) slot; + (void) expected_sent; + (void) expected_rcvd; return LPF_SUCCESS; } @@ -155,6 +158,15 @@ lpf_err_t lpf_lock_slot( size_t size, lpf_msg_attr_t attr ) { + + (void) ctx; + (void) src_slot; + (void) src_offset; + (void) dst_pid; + (void) dst_slot; + (void) dst_offset; + (void) size; + (void) attr; return LPF_SUCCESS; } @@ -168,6 +180,14 @@ lpf_err_t lpf_unlock_slot( size_t size, lpf_msg_attr_t attr ) { + (void) ctx; + (void) src_slot; + (void) src_offset; + (void) dst_pid; + (void) dst_slot; + (void) dst_offset; + (void) size; + (void) attr; return LPF_SUCCESS; } @@ -216,17 +236,20 @@ lpf_err_t lpf_resize_memory_register( lpf_t lpf, size_t max_regs ) lpf_err_t lpf_get_rcvd_msg_count_per_slot( lpf_t lpf, size_t * rcvd_msgs, lpf_memslot_t slot) { (void) lpf; *rcvd_msgs = 0; + (void) slot; return LPF_SUCCESS; } lpf_err_t lpf_get_rcvd_msg_count( lpf_t lpf, size_t * rcvd_msgs) { (void) lpf; + *rcvd_msgs = 0; return LPF_SUCCESS; } lpf_err_t lpf_get_sent_msg_count_per_slot( lpf_t lpf, size_t * sent_msgs, lpf_memslot_t slot) { (void) lpf; *sent_msgs = 0; + (void) slot; return LPF_SUCCESS; } @@ -243,6 +266,8 @@ lpf_err_t lpf_abort( lpf_t lpf) lpf_err_t lpf_noc_resize_memory_register( lpf_t ctx, size_t max_regs ) { + (void) ctx; + (void) max_regs; return LPF_SUCCESS; } @@ -253,6 +278,10 @@ lpf_err_t lpf_noc_register( lpf_memslot_t * memslot ) { + (void) ctx; + (void) pointer; + (void) size; + (void) memslot; return LPF_SUCCESS; } @@ -261,6 +290,8 @@ lpf_err_t lpf_noc_deregister( lpf_memslot_t memslot ) { + (void) ctx; + (void) memslot; return LPF_SUCCESS; } @@ -275,6 +306,14 @@ lpf_err_t lpf_noc_put( lpf_msg_attr_t attr ) { + (void) ctx; + (void) src_slot; + (void) src_offset; + (void) dst_pid; + (void) dst_slot; + (void) dst_offset; + (void) size; + (void) attr; return LPF_SUCCESS; } @@ -289,5 +328,14 @@ lpf_err_t lpf_noc_get( lpf_msg_attr_t attr ) { + (void) ctx; + (void) src_pid; + (void) src_slot; + (void) src_offset; + (void) dst_slot; + (void) dst_offset; + (void) size; + (void) attr; + return LPF_SUCCESS; } diff --git a/src/pthreads/barrier.cpp b/src/pthreads/barrier.cpp index cacfbbf8..92442474 100644 --- a/src/pthreads/barrier.cpp +++ b/src/pthreads/barrier.cpp @@ -82,9 +82,9 @@ namespace { { #ifdef VALGRIND_MEMCHECK #ifdef LPF_ON_MACOS - pthread_yield_np(); + sched_yield_np(); #else - pthread_yield(); // allow other processes to progress + sched_yield(); // allow other processes to progress #endif #endif } @@ -145,7 +145,7 @@ namespace { if (m_available ) _mm_mwait(0, 0); else - pthread_yield(); + sched_yield(); } bool m_available; @@ -160,9 +160,9 @@ namespace { void pause() { #ifdef LPF_ON_MACOS - pthread_yield_np(); + sched_yield_np(); #else - if (pthread_yield()) { + if (sched_yield()) { LOG(2, "While waiting, the Posix thread library failed to " "yield the CPU to the OS" ); } diff --git a/src/pthreads/core.cpp b/src/pthreads/core.cpp index 763d9a44..7f6d833d 100644 --- a/src/pthreads/core.cpp +++ b/src/pthreads/core.cpp @@ -386,6 +386,7 @@ lpf_err_t lpf_resize_memory_register( lpf_t ctx, size_t max_regs ) } lpf_err_t lpf_get_rcvd_msg_count_per_slot(lpf_t ctx, size_t * msgs, lpf_memslot_t slot) { + (void) slot; *msgs = 0; lpf::ThreadLocalData * t = realCtx(ctx); if (t->isAborted()) @@ -404,6 +405,7 @@ lpf_err_t lpf_get_rcvd_msg_count(lpf_t ctx, size_t * msgs) { lpf_err_t lpf_get_sent_msg_count_per_slot(lpf_t ctx, size_t * msgs, lpf_memslot_t slot) { *msgs = 0; + (void) slot; lpf::ThreadLocalData * t = realCtx(ctx); if (t->isAborted()) return LPF_SUCCESS; diff --git a/src/pthreads/threadlocaldata.cpp b/src/pthreads/threadlocaldata.cpp index 6a62e4d3..1923b272 100644 --- a/src/pthreads/threadlocaldata.cpp +++ b/src/pthreads/threadlocaldata.cpp @@ -442,6 +442,10 @@ err_t ThreadLocalData :: sync( bool expectExit) } err_t ThreadLocalData :: countingSyncPerSlot(bool expectExit, lpf_memslot_t slot, size_t expected_sent, size_t expected_rcvd) { + (void) expectExit; + (void) slot; + (void) expected_sent; + (void) expected_rcvd; return LPF_SUCCESS; } diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 8c321628..115d12b4 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -150,6 +150,14 @@ foreach (LPF_IMPL_ID ${ENGINES}) endforeach(LPF_IMPL_ID) +# Individual test for NOC (Non-coherence) protocol, only for zero engine +# (part of HiCR project) + set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) + set(mode "_debug") + set(exeName "func_lpf_test_noc_register_zero_${LPF_IMPL_CONFIG}${mode}") + add_gtest(${exeName} "zero" ON "${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_test_noc_register.cpp") + + include_directories(.) add_subdirectory(debug) From 0e3a1c27fe6fc76b364d6842b41a6cb4615c184d Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Thu, 12 Dec 2024 20:37:25 +0100 Subject: [PATCH 16/28] A lot of refactoring treating every GCC warning as error. I think that improved the code quality. On the way, I resolved an error in the implementation of getting sent and received messages - with and without slot parameters. Still need to validate the NOC example --- include/lpf/core.h | 9 +++++++ include/lpf/static_dispatch.h | 2 ++ src/MPI/core.cpp | 9 +++++++ src/MPI/ibverbs.cpp | 6 +++-- src/MPI/ibverbs.hpp | 23 ++++++++-------- src/MPI/ibverbsZero.cpp | 41 +++++++++++++++------------- src/MPI/interface.cpp | 13 ++++++--- src/MPI/interface.hpp | 2 ++ src/MPI/mesgqueue.cpp | 51 ++++++++++++++++++++++++++++------- src/MPI/mesgqueue.hpp | 2 ++ src/MPI/mesgqueueNoc.cpp | 2 +- src/MPI/mesgqueueNoc.hpp | 4 +-- src/debug/core.cpp | 11 ++++++++ src/hybrid/core.cpp | 24 ++++++++++++++--- src/hybrid/dispatch.hpp | 12 ++++++--- src/hybrid/state.hpp | 18 ++++++------- src/imp/core.c | 6 +++++ src/pthreads/core.cpp | 8 ++++++ 18 files changed, 178 insertions(+), 65 deletions(-) diff --git a/include/lpf/core.h b/include/lpf/core.h index c9a7f921..7d101fc5 100644 --- a/include/lpf/core.h +++ b/include/lpf/core.h @@ -2425,6 +2425,15 @@ lpf_err_t lpf_get_rcvd_msg_count( lpf_t ctx, size_t *rcvd_msgs); extern _LPFLIB_API lpf_err_t lpf_get_sent_msg_count_per_slot( lpf_t ctx, size_t *sent_msgs, lpf_memslot_t slot); +/** + * This function returns in @rcvd_msgs the total received message count. + * It is only implemented for the zero backend (on Infiniband) + * \param[in] ctx The LPF context + * \param[out] sent_msgs Sent message count + */ +extern _LPFLIB_API +lpf_err_t lpf_get_sent_msg_count( lpf_t ctx, size_t *sent_msgs); + /** * This function blocks until all the scheduled messages via * ibv_post_send are completed (via ibv_poll_cq). This includes diff --git a/include/lpf/static_dispatch.h b/include/lpf/static_dispatch.h index 8816f9e9..2bd7dbc7 100644 --- a/include/lpf/static_dispatch.h +++ b/include/lpf/static_dispatch.h @@ -45,6 +45,7 @@ #undef lpf_register_local #undef lpf_get_rcvd_msg_count #undef lpf_get_rcvd_msg_count_per_slot +#undef lpf_get_sent_msg_count #undef lpf_get_sent_msg_count_per_slot #undef lpf_register_global #undef lpf_flush_sent @@ -96,6 +97,7 @@ #define lpf_register_local LPF_FUNC(register_local) #define lpf_get_rcvd_msg_count LPF_FUNC(get_rcvd_msg_count) #define lpf_get_rcvd_msg_count_per_slot LPF_FUNC(get_rcvd_msg_count_per_slot) +#define lpf_get_sent_msg_count LPF_FUNC(get_sent_msg_count) #define lpf_get_sent_msg_count_per_slot LPF_FUNC(get_sent_msg_count_per_slot) #define lpf_flush_sent LPF_FUNC(flush_sent) #define lpf_flush_received LPF_FUNC(flush_received) diff --git a/src/MPI/core.cpp b/src/MPI/core.cpp index c71b39bd..f8d2c9ad 100644 --- a/src/MPI/core.cpp +++ b/src/MPI/core.cpp @@ -332,6 +332,15 @@ lpf_err_t lpf_get_rcvd_msg_count( lpf_t ctx, size_t * rcvd_msgs) return LPF_SUCCESS; } +lpf_err_t lpf_get_sent_msg_count( lpf_t ctx, size_t * sent_msgs) +{ + lpf::Interface * i = realContext(ctx); + if (!i->isAborted()) { + i->getSentMsgCount(sent_msgs); + } + return LPF_SUCCESS; +} + lpf_err_t lpf_get_sent_msg_count_per_slot( lpf_t ctx, size_t * sent_msgs, lpf_memslot_t slot) { lpf::Interface * i = realContext(ctx); diff --git a/src/MPI/ibverbs.cpp b/src/MPI/ibverbs.cpp index 2cfe0342..8d88cf04 100644 --- a/src/MPI/ibverbs.cpp +++ b/src/MPI/ibverbs.cpp @@ -46,16 +46,19 @@ namespace { } size_t MemoryRegistration :: serialize(char ** buf) { + (void) buf; throw IBVerbs::Exception( "MemoryRegistration::serialize(char ** buf) not implemented for base IBVerbs class"); } MemoryRegistration * MemoryRegistration :: deserialize(char * buf) { + (void) buf; throw IBVerbs::Exception( "MemoryRegistration::deserialize(char * buf) not implemented for base IBVerbs class"); } IBVerbs :: IBVerbs( Communication & comm ) - : m_pid( comm.pid() ) + : m_comm( comm ) + , m_pid( comm.pid() ) , m_nprocs( comm.nprocs() ) , m_devName() , m_ibPort( Config::instance().getIBPort() ) @@ -80,7 +83,6 @@ IBVerbs :: IBVerbs( Communication & comm ) , m_memreg() , m_dummyMemReg() , m_dummyBuffer() - , m_comm( comm ) { m_peerList.reserve( m_nprocs ); diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index db964ff4..3c53cbff 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -110,7 +110,7 @@ class _LPFLIB_LOCAL IBVerbs void doRemoteProgress(); - void countingSyncPerSlot(bool resized, SlotID tag, size_t sent, size_t recvd); + void countingSyncPerSlot(SlotID tag, size_t sent, size_t recvd); /** * @syncPerSlot only guarantees that all already scheduled sends (via put), * or receives (via get) associated with a slot are completed. It does @@ -118,17 +118,17 @@ class _LPFLIB_LOCAL IBVerbs * no guarantee that a remote process will wait til data is put into its * memory, as it does schedule the operation (one-sided). */ - void syncPerSlot(bool resized, SlotID slot); + void syncPerSlot(SlotID slot); // Do the communication and synchronize // 'Reconnect' must be a globally replicated value void sync( bool reconnect); void get_rcvd_msg_count(size_t * rcvd_msgs); + void get_sent_msg_count(size_t * sent_msgs); void get_rcvd_msg_count_per_slot(size_t * rcvd_msgs, SlotID slot); void get_sent_msg_count_per_slot(size_t * sent_msgs, SlotID slot); - protected: IBVerbs & operator=(const IBVerbs & ); // assignment prohibited IBVerbs( const IBVerbs & ); // copying prohibited @@ -147,6 +147,8 @@ class _LPFLIB_LOCAL IBVerbs std::vector< MemoryRegistration > glob; // array for global registrations }; + + Communication & m_comm; int m_pid; // local process ID int m_nprocs; // number of processes std::atomic_size_t m_numMsgs; @@ -169,8 +171,6 @@ class _LPFLIB_LOCAL IBVerbs size_t m_cqSize; size_t m_minNrMsgs; size_t m_maxSrs; // maximum number of sends requests per QP - size_t m_postCount; - size_t m_recvCount; shared_ptr< struct ibv_context > m_device; // device handle shared_ptr< struct ibv_pd > m_pd; // protection domain @@ -185,10 +185,6 @@ class _LPFLIB_LOCAL IBVerbs // Connected queue pairs std::vector< shared_ptr > m_connectedQps; - std::vector rcvdMsgCount; - std::vector sentMsgCount; - std::vector getMsgCount; - std::vector slotActive; std::vector< struct ibv_send_wr > m_srs; // array of send requests @@ -205,8 +201,13 @@ class _LPFLIB_LOCAL IBVerbs shared_ptr< struct ibv_mr > m_dummyMemReg; // registration of dummy buffer std::vector< char > m_dummyBuffer; // dummy receive buffer - - Communication & m_comm; + // + std::vector rcvdMsgCount; + std::vector sentMsgCount; + std::vector getMsgCount; + std::vector slotActive; + size_t m_postCount; + size_t m_recvCount; }; diff --git a/src/MPI/ibverbsZero.cpp b/src/MPI/ibverbsZero.cpp index 633a1f4e..09287058 100644 --- a/src/MPI/ibverbsZero.cpp +++ b/src/MPI/ibverbsZero.cpp @@ -53,14 +53,20 @@ namespace { IBVerbs :: IBVerbs( Communication & comm ) - : m_pid( comm.pid() ) + : m_comm( comm ) + , m_pid( comm.pid() ) , m_nprocs( comm.nprocs() ) + , m_numMsgs(0) + , m_recvTotalInitMsgCount(0) + , m_sentMsgs(0) + , m_recvdMsgs(0) , m_devName() , m_ibPort( Config::instance().getIBPort() ) , m_gidIdx( Config::instance().getIBGidIndex() ) , m_mtu( getMTU( Config::instance().getIBMTU() )) , m_maxRegSize(0) , m_maxMsgSize(0) + , m_cqSize(1) , m_minNrMsgs(0) , m_maxSrs(0) , m_device() @@ -78,14 +84,8 @@ IBVerbs :: IBVerbs( Communication & comm ) , m_memreg() , m_dummyMemReg() , m_dummyBuffer() - , m_comm( comm ) - , m_cqSize(1) , m_postCount(0) , m_recvCount(0) - , m_numMsgs(0) - , m_recvTotalInitMsgCount(0) - , m_sentMsgs(0) - , m_recvdMsgs(0) { // arrays instead of hashmap for counters @@ -306,7 +306,7 @@ inline void IBVerbs :: tryIncrement(Op op, Phase phase, SlotID slot) { void IBVerbs :: stageQPs( size_t maxMsgs ) { // create the queue pairs - for ( int i = 0; i < m_nprocs; ++i) { + for ( size_t i = 0; i < static_cast(m_nprocs); ++i) { struct ibv_qp_init_attr attr; std::memset(&attr, 0, sizeof(attr)); @@ -464,7 +464,6 @@ void IBVerbs :: reconnectQPs() struct ibv_recv_wr rr; std::memset(&rr, 0, sizeof(rr)); struct ibv_sge sge; std::memset(&sge, 0, sizeof(sge)); - struct ibv_recv_wr *bad_wr = NULL; sge.addr = reinterpret_cast(m_dummyBuffer.data()); sge.length = m_dummyBuffer.size(); sge.lkey = m_dummyMemReg->lkey; @@ -705,7 +704,6 @@ void IBVerbs :: blockingCompareAndSwap(SlotID srcSlot, size_t srcOffset, int dst sge.length = std::min(size, m_maxMsgSize ); sge.lkey = src.mr->lkey; - struct ibv_wc wcs[POLL_BATCH]; struct ibv_send_wr wr; memset(&wr, 0, sizeof(wr)); wr.wr_id = srcSlot; @@ -892,6 +890,10 @@ void IBVerbs :: get_rcvd_msg_count(size_t * rcvd_msgs) { *rcvd_msgs = m_recvdMsgs; } +void IBVerbs :: get_sent_msg_count(size_t * sent_msgs) { + *sent_msgs = m_sentMsgs; +} + void IBVerbs :: get_rcvd_msg_count_per_slot(size_t * rcvd_msgs, SlotID slot) { *rcvd_msgs = rcvdMsgCount[slot]; @@ -982,10 +984,8 @@ void IBVerbs :: flushSent() } -void IBVerbs :: countingSyncPerSlot(bool resized, SlotID slot, size_t expectedSent, size_t expectedRecvd) { +void IBVerbs :: countingSyncPerSlot(SlotID slot, size_t expectedSent, size_t expectedRecvd) { - size_t actualRecvd; - size_t actualSent; int error; if (slotActive[slot]) { do { @@ -997,14 +997,20 @@ void IBVerbs :: countingSyncPerSlot(bool resized, SlotID slot, size_t expectedSe // this call triggers doRemoteProgress doRemoteProgress(); - } while ( + } while (( + // do we have messages (sent or received) + // which are only initiated but incomplete? (rcvdMsgCount[slot] < m_recvInitMsgCount[slot]) || (sentMsgCount[slot] < m_sendInitMsgCount[slot]) - ); + ) && + // do the sent and received messages + // match our expectations? + (rcvdMsgCount[slot] < expectedRecvd + || sentMsgCount[slot] < expectedSent)); } } -void IBVerbs :: syncPerSlot(bool resized, SlotID slot) { +void IBVerbs :: syncPerSlot(SlotID slot) { int error; do { @@ -1036,8 +1042,7 @@ void IBVerbs :: syncPerSlot(bool resized, SlotID slot) { void IBVerbs :: sync(bool resized) { - - int error = 0; + (void) resized; // flush send queues flushSent(); diff --git a/src/MPI/interface.cpp b/src/MPI/interface.cpp index 1223bfb2..53203042 100644 --- a/src/MPI/interface.cpp +++ b/src/MPI/interface.cpp @@ -132,6 +132,15 @@ void Interface :: getSentMsgCountPerSlot(size_t * msgs, SlotID slot) { m_mesgQueue.getSentMsgCountPerSlot(msgs, slot); } + +void Interface :: getRcvdMsgCount(size_t * msgs) { + m_mesgQueue.getRcvdMsgCount(msgs); +} + +void Interface :: getSentMsgCount(size_t * msgs) { + m_mesgQueue.getSentMsgCount(msgs); +} + void Interface :: flushSent() { m_mesgQueue.flushSent(); } @@ -140,10 +149,6 @@ void Interface :: flushReceived() { m_mesgQueue.flushReceived(); } -void Interface :: getRcvdMsgCount(size_t * msgs) { - m_mesgQueue.getRcvdMsgCount(msgs); -} - err_t Interface :: countingSyncPerSlot(memslot_t slot, size_t expected_sent, size_t expected_rcvd) { if ( 0 == m_aborted ) diff --git a/src/MPI/interface.hpp b/src/MPI/interface.hpp index dee8583e..b620d4a9 100644 --- a/src/MPI/interface.hpp +++ b/src/MPI/interface.hpp @@ -99,6 +99,8 @@ class _LPFLIB_LOCAL Interface void getSentMsgCountPerSlot(size_t * msgs, SlotID slot); + void getSentMsgCount(size_t * msgs); + void getRcvdMsgCount(size_t * msgs); void flushSent(); diff --git a/src/MPI/mesgqueue.cpp b/src/MPI/mesgqueue.cpp index 19810bb3..c653895c 100644 --- a/src/MPI/mesgqueue.cpp +++ b/src/MPI/mesgqueue.cpp @@ -104,13 +104,13 @@ MessageQueue :: MessageQueue( Communication & comm ) , m_bodySends() , m_bodyRecvs() , m_comm( dynamic_cast(comm) ) + , m_tinyMsgBuf( m_tinyMsgSize + largestHeader(m_nprocs, m_memRange, 0, 0)) #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero , m_ibverbs(m_comm) , m_memreg( m_comm, m_ibverbs ) #else , m_memreg( m_comm ) #endif - , m_tinyMsgBuf( m_tinyMsgSize + largestHeader(m_nprocs, m_memRange, 0, 0)) { m_memreg.reserve(1); // reserve slot for edgeBuffer } @@ -257,6 +257,8 @@ memslot_t MessageQueue :: addNocReg( void * mem, std::size_t size) err_t MessageQueue :: serializeSlot(SlotID slot, char ** mem, std::size_t * size) { ASSERT(slot != LPF_INVALID_MEMSLOT); + ASSERT(mem != nullptr); + ASSERT(size != nullptr); #ifdef LPF_CORE_MPI_USES_zero auto mr = m_ibverbs.getMR(slot, m_pid); *size = mr.serialize(mem); @@ -270,6 +272,7 @@ err_t MessageQueue :: serializeSlot(SlotID slot, char ** mem, std::size_t * size err_t MessageQueue :: deserializeSlot(char * mem, SlotID slot) { + ASSERT(mem != nullptr); ASSERT(slot != LPF_INVALID_MEMSLOT); #ifdef LPF_CORE_MPI_USES_zero auto mr = mpi::MemoryRegistration::deserialize(mem); @@ -364,6 +367,12 @@ void MessageQueue :: get( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, void MessageQueue :: lockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { + ASSERT(srcSlot != LPF_INVALID_MEMSLOT); + ASSERT(dstSlot != LPF_INVALID_MEMSLOT); + (void) srcOffset; + (void) dstOffset; + (void) dstPid; + (void) size; #ifdef LPF_CORE_MPI_USES_zero m_ibverbs.blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 0ULL, 1ULL); #endif @@ -372,6 +381,12 @@ m_ibverbs.blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, void MessageQueue :: unlockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) { + ASSERT(srcSlot != LPF_INVALID_MEMSLOT); + ASSERT(dstSlot != LPF_INVALID_MEMSLOT); + (void) srcOffset; + (void) dstOffset; + (void) dstPid; + (void) size; #ifdef LPF_CORE_MPI_USES_zero m_ibverbs.blockingCompareAndSwap(m_memreg.getVerbID(srcSlot), srcOffset, dstPid, m_memreg.getVerbID(dstSlot), dstOffset, size, 1ULL, 0ULL); #endif @@ -429,6 +444,7 @@ int MessageQueue :: sync( bool abort ) { #ifdef LPF_CORE_MPI_USES_zero // if not, deal with normal sync + (void) abort; m_memreg.sync(); m_ibverbs.sync(m_resized); m_resized = false; @@ -1061,15 +1077,17 @@ int MessageQueue :: sync( bool abort ) int MessageQueue :: countingSyncPerSlot(SlotID slot, size_t expected_sent, size_t expected_rcvd) { + ASSERT(slot != LPF_INVALID_MEMSLOT); + (void) expected_sent; + (void) expected_rcvd; #ifdef LPF_CORE_MPI_USES_zero // if not, deal with normal sync m_memreg.sync(); - - m_ibverbs.countingSyncPerSlot(m_resized, slot, expected_sent, expected_rcvd); - + m_ibverbs.countingSyncPerSlot(slot, expected_sent, expected_rcvd); m_resized = false; + #endif return 0; } @@ -1077,13 +1095,12 @@ int MessageQueue :: countingSyncPerSlot(SlotID slot, size_t expected_sent, size_ int MessageQueue :: syncPerSlot(SlotID slot) { + ASSERT(slot != LPF_INVALID_MEMSLOT); #ifdef LPF_CORE_MPI_USES_zero // if not, deal with normal sync m_memreg.sync(); - - m_ibverbs.syncPerSlot(m_resized, slot); - + m_ibverbs.syncPerSlot(slot); m_resized = false; #endif @@ -1094,25 +1111,39 @@ int MessageQueue :: syncPerSlot(SlotID slot) void MessageQueue :: getRcvdMsgCountPerSlot(size_t * msgs, SlotID slot) { + ASSERT(msgs != nullptr); + ASSERT(slot != LPF_INVALID_MEMSLOT); #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs.get_rcvd_msg_count_per_slot(msgs, slot); + m_ibverbs.get_rcvd_msg_count_per_slot(msgs, slot); #endif } void MessageQueue :: getRcvdMsgCount(size_t * msgs) { + ASSERT(msgs != nullptr); +#ifdef LPF_CORE_MPI_USES_zero + *msgs = 0; + m_ibverbs.get_rcvd_msg_count(msgs); +#endif +} + +void MessageQueue :: getSentMsgCount(size_t * msgs) +{ + ASSERT(msgs != nullptr); #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs.get_rcvd_msg_count(msgs); + m_ibverbs.get_sent_msg_count(msgs); #endif } void MessageQueue :: getSentMsgCountPerSlot(size_t * msgs, SlotID slot) { + ASSERT(msgs != nullptr); + ASSERT(slot != LPF_INVALID_MEMSLOT); #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs.get_sent_msg_count_per_slot(msgs, slot); + m_ibverbs.get_sent_msg_count_per_slot(msgs, slot); #endif } diff --git a/src/MPI/mesgqueue.hpp b/src/MPI/mesgqueue.hpp index ee4d2ddc..f85d60ce 100644 --- a/src/MPI/mesgqueue.hpp +++ b/src/MPI/mesgqueue.hpp @@ -81,6 +81,8 @@ class _LPFLIB_LOCAL MessageQueue void getSentMsgCountPerSlot(size_t * msgs, SlotID slot); + void getSentMsgCount(size_t * msgs); + void flushSent(); void flushReceived(); diff --git a/src/MPI/mesgqueueNoc.cpp b/src/MPI/mesgqueueNoc.cpp index e8b3e9fa..4f6c1f5c 100644 --- a/src/MPI/mesgqueueNoc.cpp +++ b/src/MPI/mesgqueueNoc.cpp @@ -6,7 +6,7 @@ namespace lpf { MessageQueueNoc :: MessageQueueNoc( Communication & comm ) : - m_ibverbs( comm ), + //m_ibverbs( comm ), MessageQueue(comm) {} diff --git a/src/MPI/mesgqueueNoc.hpp b/src/MPI/mesgqueueNoc.hpp index 6aa914ae..3ff00489 100644 --- a/src/MPI/mesgqueueNoc.hpp +++ b/src/MPI/mesgqueueNoc.hpp @@ -25,8 +25,8 @@ class _LPFLIB_LOCAL MessageQueueNoc : public MessageQueue /* * end NOC extension */ -protected: - mpi::IBVerbsNoc m_ibverbs; +//protected: + //mpi::IBVerbsNoc m_ibverbs; }; } // namespace lpf diff --git a/src/debug/core.cpp b/src/debug/core.cpp index 00f025f6..f9c788ce 100644 --- a/src/debug/core.cpp +++ b/src/debug/core.cpp @@ -32,6 +32,7 @@ #undef lpf_abort #undef lpf_get_rcvd_msg_count #undef lpf_get_rcvd_msg_count_per_slot +#undef lpf_get_sent_msg_count #undef lpf_get_sent_msg_count_per_slot #undef lpf_flush #undef lpf_abort @@ -704,14 +705,24 @@ class _LPFLIB_LOCAL Interface { } lpf_err_t get_rcvd_msg_count_per_slot(size_t *msgs, lpf_memslot_t slot) { + ASSERT(msgs != nullptr); + ASSERT(slot != LPF_INVALID_MEMSLOT); return LPF_SUCCESS; } lpf_err_t get_sent_msg_count_per_slot(size_t *msgs, lpf_memslot_t slot) { + ASSERT(msgs != nullptr); + ASSERT(slot != LPF_INVALID_MEMSLOT); return LPF_SUCCESS; } lpf_err_t get_rcvd_msg_count(size_t *msgs) { + ASSERT(msgs != nullptr); + return LPF_SUCCESS; + } + + lpf_err_t get_sent_msg_count(size_t *msgs) { + ASSERT(msgs != nullptr); return LPF_SUCCESS; } diff --git a/src/hybrid/core.cpp b/src/hybrid/core.cpp index 39226a18..cec834ea 100644 --- a/src/hybrid/core.cpp +++ b/src/hybrid/core.cpp @@ -414,11 +414,15 @@ _LPFLIB_API lpf_err_t lpf_get_rcvd_msg_count( lpf_t ctx, size_t * rcvd_msgs) _LPFLIB_API lpf_err_t lpf_get_rcvd_msg_count_per_slot( lpf_t ctx, size_t * rcvd_msgs, lpf_memslot_t slot ) { + using namespace lpf::hybrid; + if (ctx == LPF_SINGLE_PROCESS) + return LPF_SUCCESS; ThreadState * t = realContext(ctx); - MPI mpi = t->nodeState().mpi(); - mpi.abort(); - return LPF_SUCCESS; + if (!t->error()) + return t->getRcvdMsgCountPerSlot(rcvd_msgs, slot); + else + return LPF_SUCCESS; } _LPFLIB_API lpf_err_t lpf_get_sent_msg_count_per_slot( lpf_t ctx, size_t * sent_msgs, lpf_memslot_t slot ) @@ -428,7 +432,19 @@ _LPFLIB_API lpf_err_t lpf_get_sent_msg_count_per_slot( lpf_t ctx, size_t * sent_ return LPF_SUCCESS; ThreadState * t = realContext(ctx); if (!t->error()) - return t->getSentMsgCount(sent_msgs, slot); + return t->getSentMsgCountPerSlot(sent_msgs, slot); + else + return LPF_SUCCESS; +} + +_LPFLIB_API lpf_err_t lpf_get_sent_msg_count( lpf_t ctx, size_t * sent_msgs) +{ + using namespace lpf::hybrid; + if (ctx == LPF_SINGLE_PROCESS) + return LPF_SUCCESS; + ThreadState * t = realContext(ctx); + if (!t->error()) + return t->getSentMsgCount(sent_msgs); else return LPF_SUCCESS; } diff --git a/src/hybrid/dispatch.hpp b/src/hybrid/dispatch.hpp index 2dc83c2b..31492e1c 100644 --- a/src/hybrid/dispatch.hpp +++ b/src/hybrid/dispatch.hpp @@ -121,6 +121,9 @@ namespace lpf { namespace hybrid { err_t get_rcvd_msg_count( size_t * rcvd_msgs) { return USE_THREAD( get_rcvd_msg_count)(m_ctx, rcvd_msgs); } + err_t get_sent_msg_count( size_t * sent_msgs) + { return USE_THREAD( get_sent_msg_count)(m_ctx, sent_msgs); } + err_t flush_sent() { return USE_THREAD(flush_sent)(m_ctx); } @@ -223,15 +226,18 @@ namespace lpf { namespace hybrid { err_t deregister( memslot_t memslot) { return USE_MPI( deregister)(m_ctx, memslot); } + err_t get_rcvd_msg_count( size_t * rcvd_msgs) + { return USE_MPI( get_rcvd_msg_count)(m_ctx, rcvd_msgs); } + err_t get_rcvd_msg_count_per_slot(size_t *rcvd_msgs, lpf_memslot_t slot) { return USE_MPI( get_rcvd_msg_count_per_slot)( m_ctx, rcvd_msgs, slot); } + err_t get_sent_msg_count( size_t * sent_msgs) + { return USE_MPI( get_sent_msg_count)(m_ctx, sent_msgs); } + err_t get_sent_msg_count_per_slot(size_t *sent_msgs, lpf_memslot_t slot) { return USE_MPI( get_sent_msg_count_per_slot)( m_ctx, sent_msgs, slot); } - err_t get_rcvd_msg_count( size_t * rcvd_msgs) - { return USE_MPI( get_rcvd_msg_count)(m_ctx, rcvd_msgs); } - err_t flush_sent() {return USE_MPI( flush_sent)(m_ctx);} diff --git a/src/hybrid/state.hpp b/src/hybrid/state.hpp index 06e8faf3..f890be6b 100644 --- a/src/hybrid/state.hpp +++ b/src/hybrid/state.hpp @@ -111,13 +111,6 @@ class _LPFLIB_LOCAL NodeState { return m_mpi.sync(); } -// MPI::err_t counting_sync_per_slot(lpf_memslot_t slot, size_t expected_sent, size_t expected_rcvd) -// { -// m_memreg.flush( m_mpi ); -// m_msgQueue.flush( m_mpi, m_memreg ); -// return m_mpi.counting_sync_per_slot(slot, expected_sent, expected_rcvd); -// } - static double messageGap( lpf_pid_t nprocs, size_t minMsgSize, lpf_sync_attr_t attr) { (void) nprocs; @@ -422,14 +415,19 @@ class _LPFLIB_LOCAL ThreadState { bool error() const { return m_error; } - lpf_pid_t getRcvdMsgCount(size_t * rcvd_msgs, lpf_memslot_t slot) { + lpf_pid_t getRcvdMsgCountPerSlot(size_t * rcvd_msgs, lpf_memslot_t slot) { return m_nodeState.mpi().get_rcvd_msg_count_per_slot(rcvd_msgs, slot); } - lpf_pid_t getSentMsgCount(size_t * sent_msgs, lpf_memslot_t slot) { + lpf_pid_t getSentMsgCountPerSlot(size_t * rcvd_msgs, lpf_memslot_t slot) { + + return m_nodeState.mpi().get_sent_msg_count_per_slot(rcvd_msgs, slot); + } + + lpf_pid_t getSentMsgCount(size_t * sent_msgs) { - return m_nodeState.mpi().get_sent_msg_count_per_slot(sent_msgs, slot); + return m_nodeState.mpi().get_sent_msg_count(sent_msgs); } lpf_pid_t getRcvdMsgCount(size_t * rcvd_msgs) { diff --git a/src/imp/core.c b/src/imp/core.c index 5caf0840..4ad623c0 100644 --- a/src/imp/core.c +++ b/src/imp/core.c @@ -246,6 +246,12 @@ lpf_err_t lpf_get_rcvd_msg_count( lpf_t lpf, size_t * rcvd_msgs) { return LPF_SUCCESS; } +lpf_err_t lpf_get_sent_msg_count( lpf_t lpf, size_t * sent_msgs) { + (void) lpf; + *sent_msgs = 0; + return LPF_SUCCESS; +} + lpf_err_t lpf_get_sent_msg_count_per_slot( lpf_t lpf, size_t * sent_msgs, lpf_memslot_t slot) { (void) lpf; *sent_msgs = 0; diff --git a/src/pthreads/core.cpp b/src/pthreads/core.cpp index 7f6d833d..253683cb 100644 --- a/src/pthreads/core.cpp +++ b/src/pthreads/core.cpp @@ -412,6 +412,14 @@ lpf_err_t lpf_get_sent_msg_count_per_slot(lpf_t ctx, size_t * msgs, lpf_memslot_ return LPF_SUCCESS; } +lpf_err_t lpf_get_sent_msg_count(lpf_t ctx, size_t * msgs) { + *msgs = 0; + lpf::ThreadLocalData * t = realCtx(ctx); + if (t->isAborted()) + return LPF_SUCCESS; + return LPF_SUCCESS; +} + lpf_err_t lpf_abort(lpf_t ctx) { (void) ctx; // Using std::abort is not portable From ac3161d2e7a959b7fe1ab353010e2a50c4450346 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Thu, 12 Dec 2024 21:38:06 +0100 Subject: [PATCH 17/28] Forgot to add the new LPF-based NOC functionality test. Remove mesgqueueNoc structure, because I don't need it so far. Also, disable debug layer for NOC, as it is currently not correctly validating (future work). --- src/MPI/CMakeLists.txt | 1 - src/MPI/interface.hpp | 2 +- src/MPI/mesgqueue.hpp | 13 ++- src/MPI/mesgqueueNoc.cpp | 60 ------------- src/MPI/mesgqueueNoc.hpp | 33 ------- tests/functional/CMakeLists.txt | 4 +- .../functional/func_lpf_test_noc_register.cpp | 87 +++++++++++++++++++ 7 files changed, 96 insertions(+), 104 deletions(-) delete mode 100644 src/MPI/mesgqueueNoc.cpp delete mode 100644 src/MPI/mesgqueueNoc.hpp create mode 100644 tests/functional/func_lpf_test_noc_register.cpp diff --git a/src/MPI/CMakeLists.txt b/src/MPI/CMakeLists.txt index 55ba3e94..db95d256 100644 --- a/src/MPI/CMakeLists.txt +++ b/src/MPI/CMakeLists.txt @@ -61,7 +61,6 @@ if (MPI_FOUND) add_library(raw_${libname} OBJECT memorytable.cpp mesgqueue.cpp - mesgqueueNoc.cpp mpilib.cpp symbol.cpp process.cpp diff --git a/src/MPI/interface.hpp b/src/MPI/interface.hpp index b620d4a9..004e9edc 100644 --- a/src/MPI/interface.hpp +++ b/src/MPI/interface.hpp @@ -19,7 +19,7 @@ #define LPF_CORE_MPI_INTERFACE_HPP #include "types.hpp" -#include "mesgqueueNoc.hpp" +#include "mesgqueue.hpp" #include "mpilib.hpp" #include "machineparams.hpp" #include "linkage.hpp" diff --git a/src/MPI/mesgqueue.hpp b/src/MPI/mesgqueue.hpp index f85d60ce..0284ebcb 100644 --- a/src/MPI/mesgqueue.hpp +++ b/src/MPI/mesgqueue.hpp @@ -26,6 +26,9 @@ #include "messagesort.hpp" #include "mpilib.hpp" #include "linkage.hpp" +#if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero +#include "ibverbsNoc.hpp" +#endif #if __cplusplus >= 201103L #include @@ -33,10 +36,6 @@ #include #endif -#if defined LPF_CORE_MPI_USES_zero -#include "ibverbsNoc.hpp" -#endif - //only for HiCR typedef size_t SlotID; @@ -169,10 +168,10 @@ class _LPFLIB_LOCAL MessageQueue mpi::Comm m_comm; std::vector< char > m_tinyMsgBuf; protected: -#if defined LPF_CORE_MPI_USES_ibverbs - mpi::IBVerbs m_ibverbs; +#if defined LPF_CORE_MPI_USES_ibverbs + mpi::IBVerbs m_ibverbs; #elif defined LPF_CORE_MPI_USES_zero - mpi::IBVerbsNoc m_ibverbs; + mpi::IBVerbsNoc m_ibverbs; #endif MemoryTable m_memreg; }; diff --git a/src/MPI/mesgqueueNoc.cpp b/src/MPI/mesgqueueNoc.cpp deleted file mode 100644 index 4f6c1f5c..00000000 --- a/src/MPI/mesgqueueNoc.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "mesgqueueNoc.hpp" - -#if defined LPF_CORE_MPI_USES_zero - -namespace lpf -{ - - MessageQueueNoc :: MessageQueueNoc( Communication & comm ) : - //m_ibverbs( comm ), - MessageQueue(comm) - {} - - /* -memslot_t MessageQueueNoc :: addNocReg( void * mem, std::size_t size ) -{ - - printf("Enter MessageQueueNoc::addNocReg\n"); - return m_ibverbs.regLocal(mem, size); -} - -void MessageQueueNoc :: removeNocReg( memslot_t slot ) -{ - - m_ibverbs.dereg(slot); - -} - -void MessageQueueNoc :: nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, - memslot_t dstSlot, size_t dstOffset, size_t size ) -{ - - m_ibverbs.get(srcPid, - m_memreg.getVerbID( srcSlot), - srcOffset, - m_memreg.getVerbID( dstSlot), - dstOffset, - size ); -} - -void MessageQueueNoc :: nocPut( memslot_t srcSlot, size_t srcOffset, - pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ) -{ - m_ibverbs.put( m_memreg.getVerbID( srcSlot), - srcOffset, - dstPid, - m_memreg.getVerbID( dstSlot), - dstOffset, - size); -} - -err_t MessageQueueNoc :: nocResizeMemreg( size_t nRegs ) -{ - m_ibverbs.resizeMemreg(nRegs); - return LPF_SUCCESS; -} -*/ - -} // namespace lpf - // -#endif diff --git a/src/MPI/mesgqueueNoc.hpp b/src/MPI/mesgqueueNoc.hpp deleted file mode 100644 index 3ff00489..00000000 --- a/src/MPI/mesgqueueNoc.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "lpf/core.h" -#include "mesgqueue.hpp" -#include "ibverbsNoc.hpp" - -#ifdef LPF_CORE_MPI_USES_zero -namespace lpf -{ -class _LPFLIB_LOCAL MessageQueueNoc : public MessageQueue -{ - -public: - explicit MessageQueueNoc( Communication & comm ); - /* - * begin NOC extension - */ - memslot_t addNocReg( void * mem, std::size_t size ); - void removeNocReg( memslot_t slot ); - void nocGet( pid_t srcPid, memslot_t srcSlot, size_t srcOffset, - memslot_t dstSlot, size_t dstOffset, size_t size ); - void nocPut( memslot_t srcSlot, size_t srcOffset, - pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ); - err_t nocResizeMemreg( size_t nRegs ); - /* - * end NOC extension - */ -//protected: - //mpi::IBVerbsNoc m_ibverbs; -}; - -} // namespace lpf -#endif diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 115d12b4..4eac9862 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -153,9 +153,9 @@ endforeach(LPF_IMPL_ID) # Individual test for NOC (Non-coherence) protocol, only for zero engine # (part of HiCR project) set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) - set(mode "_debug") + set(mode "") set(exeName "func_lpf_test_noc_register_zero_${LPF_IMPL_CONFIG}${mode}") - add_gtest(${exeName} "zero" ON "${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_test_noc_register.cpp") + add_gtest(${exeName} "zero" OFF "${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_test_noc_register.cpp") diff --git a/tests/functional/func_lpf_test_noc_register.cpp b/tests/functional/func_lpf_test_noc_register.cpp new file mode 100644 index 00000000..28d357fb --- /dev/null +++ b/tests/functional/func_lpf_test_noc_register.cpp @@ -0,0 +1,87 @@ + +/* + * Copyright 2021 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "gtest/gtest.h" + +void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) +{ + (void) args; // ignore args parameter + + lpf_err_t rc = LPF_SUCCESS; + + char buf1[30] = {'\0'}; + char buf2[30] = {'\0'}; + + strcpy(buf1, "HELLO"); + rc = lpf_resize_memory_register(lpf, 2); + //rc = lpf_noc_resize_memory_register(lpf, 1); + EXPECT_EQ( LPF_SUCCESS, rc ); + EXPECT_EQ( LPF_SUCCESS, rc ); + rc = lpf_resize_message_queue( lpf, 2); + EXPECT_EQ( LPF_SUCCESS, rc ); + + rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); + EXPECT_EQ( LPF_SUCCESS, rc ); + +/** + * \test Testing NOC functionality + * \pre P >= 2 + * \pre P <= 2 + * \return Exit code: 0 + */ + + lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; + lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; + rc = lpf_register_local( lpf, buf1, sizeof(buf1), &xslot ); + EXPECT_EQ( LPF_SUCCESS, rc ); + rc = lpf_noc_register( lpf, buf2, sizeof(buf2), &yslot ); + EXPECT_EQ( LPF_SUCCESS, rc ); + + + char * buffer; + size_t bufferSize; + lpf_serialize_slot(lpf, xslot, &buffer, &bufferSize); + + //int left = (nprocs + pid - 1) % nprocs; + int right = ( pid + 1) % nprocs; + //char rmtBuff[bufSize]; + + //MPI_Sendrecv(buffer, bufSize, MPI_BYTE, left, 0, rmtBuff, bufSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + + + + lpf_deserialize_slot(lpf, buffer, yslot); + lpf_noc_put(lpf, xslot, 0, right, yslot, 0, sizeof(buf1), LPF_MSG_DEFAULT); + EXPECT_EQ( LPF_SUCCESS, rc ); + rc = lpf_sync(lpf, LPF_SYNC_DEFAULT); + EXPECT_EQ( LPF_SUCCESS, rc ); + + EXPECT_EQ(std::string(buf2), std::string(buf1)); + rc = lpf_noc_deregister(lpf, xslot); + EXPECT_EQ( LPF_SUCCESS, rc ); + rc = lpf_noc_deregister(lpf, yslot); + EXPECT_EQ( LPF_SUCCESS, rc ); + +} + +TEST( API, func_lpf_put_parallel_single ) +{ + lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); + EXPECT_EQ( LPF_SUCCESS, rc ); +} From 0ad1ec7d9ca08b76410880caa48146c45a5bac75 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Thu, 12 Dec 2024 23:35:28 +0100 Subject: [PATCH 18/28] A fully working example now. Resolved a very nasty bug: The information about the process ID owning the NOC slot was not set correctly (always the local PID), which is of course wrong for n > 1. It seems to work now. --- src/MPI/ibverbs.cpp | 17 +++-------- src/MPI/ibverbs.hpp | 11 ++++--- src/MPI/ibverbsNoc.cpp | 16 +++++----- src/MPI/ibverbsZero.cpp | 17 +++-------- src/MPI/mesgqueue.cpp | 8 ++--- .../functional/func_lpf_test_noc_register.cpp | 30 +++++++------------ 6 files changed, 36 insertions(+), 63 deletions(-) diff --git a/src/MPI/ibverbs.cpp b/src/MPI/ibverbs.cpp index 8d88cf04..77832aae 100644 --- a/src/MPI/ibverbs.cpp +++ b/src/MPI/ibverbs.cpp @@ -472,8 +472,8 @@ void IBVerbs :: resizeMemreg( size_t size ) throw std::bad_alloc() ; } - MemoryRegistration null = { 0, 0, 0, 0 }; - MemorySlot dflt; dflt.glob.resize( m_nprocs, null ); + MemoryRegistration newMR = { nullptr, 0, 0, 0, m_pid}; + MemorySlot dflt; dflt.glob.resize( m_nprocs, newMR ); m_memreg.reserve( size, dflt ); } @@ -516,11 +516,7 @@ IBVerbs :: SlotID IBVerbs :: regLocal( void * addr, size_t size ) throw Exception("Could not register memory area"); } } - MemoryRegistration local; - local._addr = (char *) addr; - local._size = size; - local._lkey = size?slot.mr->lkey:0; - local._rkey = size?slot.mr->rkey:0; + MemoryRegistration local((char *) addr, size, size?slot.mr->lkey:0, size?slot.mr->rkey:0, m_pid); SlotID id = m_memreg.addLocalReg( slot ); @@ -560,11 +556,7 @@ IBVerbs :: SlotID IBVerbs :: regGlobal( void * addr, size_t size ) // exchange memory registration info globally ref.glob.resize(m_nprocs); - MemoryRegistration local; - local._addr = (char *) addr; - local._size = size; - local._lkey = size?slot.mr->lkey:0; - local._rkey = size?slot.mr->rkey:0; + MemoryRegistration local((char *) addr, size, size?slot.mr->lkey:0, size?slot.mr->rkey:0, m_pid); LOG(4, "All-gathering memory register data" ); @@ -595,7 +587,6 @@ void IBVerbs :: put( SlotID srcSlot, size_t srcOffset, = static_cast(src.glob[m_pid]._addr) + srcOffset; const char * remoteAddr = static_cast(dst.glob[dstPid]._addr) + dstOffset; - printf("DEBUG: rank %d localAddr %p remoteAddr %p\n", m_pid, localAddr, remoteAddr); sge.addr = reinterpret_cast( localAddr ); sge.length = std::min(size, m_maxMsgSize ); diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index 3c53cbff..b9f7d6aa 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -64,11 +64,11 @@ class MemoryRegistration { size_t _size; uint32_t _lkey; uint32_t _rkey; - MemoryRegistration(char * addr, size_t size, uint32_t lkey, uint32_t rkey) : _addr(addr), - _size(size), _lkey(lkey), _rkey(rkey) - {} - MemoryRegistration() : _addr(nullptr), _size(0), _lkey(0), _rkey(0) - {} + int _pid; + MemoryRegistration(char * addr, size_t size, uint32_t lkey, uint32_t rkey, int pid) : _addr(addr), + _size(size), _lkey(lkey), _rkey(rkey), _pid(pid) + { } + MemoryRegistration() : _addr(nullptr), _size(0), _lkey(0), _rkey(0), _pid(-1) {} size_t serialize(char ** buf); static MemoryRegistration * deserialize(char * buf); @@ -152,7 +152,6 @@ class _LPFLIB_LOCAL IBVerbs int m_pid; // local process ID int m_nprocs; // number of processes std::atomic_size_t m_numMsgs; - //std::atomic_size_t m_sendTotalInitMsgCount; std::atomic_size_t m_recvTotalInitMsgCount; std::atomic_size_t m_sentMsgs; std::atomic_size_t m_recvdMsgs; diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index 6c0d7f1d..61a4a0c4 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -7,7 +7,7 @@ namespace mpi size_t MemoryRegistration :: serialize(char ** buf) { std::stringstream ss; - size_t bufSize = sizeof(uintptr_t) + sizeof(size_t) + 2*sizeof(uint32_t); + size_t bufSize = sizeof(uintptr_t) + sizeof(size_t) + 2*sizeof(uint32_t) + sizeof(int); *buf = new char[bufSize]; char *ptr = *buf; uintptr_t addrAsUintPtr = reinterpret_cast(_addr); @@ -18,6 +18,8 @@ namespace mpi memcpy(ptr, &_lkey, sizeof(uint32_t)); ptr += sizeof(uint32_t); memcpy(ptr, &_rkey, sizeof(uint32_t)); + ptr += sizeof(uint32_t); + memcpy(ptr, &_pid, sizeof(int)); return bufSize; } @@ -28,6 +30,7 @@ namespace mpi uint32_t lkey; uint32_t rkey; uintptr_t addrAsUintPtr; + int pid; char * ptr = buf; memcpy(&addrAsUintPtr, ptr, sizeof(uintptr_t)); addr = reinterpret_cast(addrAsUintPtr); @@ -37,7 +40,9 @@ namespace mpi memcpy(&lkey, ptr, sizeof(uint32_t)); ptr += sizeof(uint32_t); memcpy(&rkey, ptr, sizeof(uint32_t)); - return new MemoryRegistration(addr, size, lkey, rkey); + ptr += sizeof(uint32_t); + memcpy(&pid, ptr, sizeof(int)); + return new MemoryRegistration(addr, size, lkey, rkey, pid); } struct IBVerbsNoc::Exception : std::runtime_error { @@ -80,14 +85,9 @@ namespace mpi throw Exception("Could not register memory area"); } } - MemoryRegistration local; - local._addr = (char *) addr; - local._size = size; - local._lkey = size?slot.mr->lkey:0; - local._rkey = size?slot.mr->rkey:0; + MemoryRegistration local((char *) addr, size, size?slot.mr->lkey:0, size?slot.mr->rkey:0, m_pid); SlotID id = m_memreg.addNocReg( slot ); - m_memreg.update( id ).glob.resize( m_nprocs ); m_memreg.update( id ).glob[m_pid] = local; LOG(4, "Memory area " << addr << " of size " << size << " has been locally registered as NOC slot. Slot = " << id ); diff --git a/src/MPI/ibverbsZero.cpp b/src/MPI/ibverbsZero.cpp index 09287058..29ba3445 100644 --- a/src/MPI/ibverbsZero.cpp +++ b/src/MPI/ibverbsZero.cpp @@ -553,8 +553,8 @@ void IBVerbs :: resizeMemreg( size_t size ) throw std::bad_alloc() ; } - MemoryRegistration null = { 0, 0, 0, 0 }; - MemorySlot dflt; dflt.glob.resize( m_nprocs, null ); + MemoryRegistration newMR = { nullptr, 0, 0, 0, m_pid}; + MemorySlot dflt; dflt.glob.resize( m_nprocs, newMR); m_memreg.reserve( size, dflt ); } @@ -616,11 +616,7 @@ IBVerbs :: SlotID IBVerbs :: regLocal( void * addr, size_t size ) throw Exception("Could not register memory area"); } } - MemoryRegistration local; - local._addr = (char *) addr; - local._size = size; - local._lkey = size?slot.mr->lkey:0; - local._rkey = size?slot.mr->rkey:0; + MemoryRegistration local((char *) addr, size, size?slot.mr->lkey:0, size?slot.mr->rkey:0, m_pid); SlotID id = m_memreg.addLocalReg( slot ); tryIncrement(Op::SEND/* <- dummy for init */, Phase::INIT, id); @@ -662,12 +658,7 @@ IBVerbs :: SlotID IBVerbs :: regGlobal( void * addr, size_t size ) // exchange memory registration info globally ref.glob.resize(m_nprocs); - MemoryRegistration local; - local._addr = (char *) addr; - local._size = size; - local._lkey = size?slot.mr->lkey:0; - local._rkey = size?slot.mr->rkey:0; - + MemoryRegistration local((char *) addr, size, size?slot.mr->lkey:0, size?slot.mr->rkey:0, m_pid); LOG(4, "All-gathering memory register data" ); m_comm.allgather( local, ref.glob.data() ); diff --git a/src/MPI/mesgqueue.cpp b/src/MPI/mesgqueue.cpp index c653895c..c83344b0 100644 --- a/src/MPI/mesgqueue.cpp +++ b/src/MPI/mesgqueue.cpp @@ -254,13 +254,13 @@ memslot_t MessageQueue :: addNocReg( void * mem, std::size_t size) return slot; } -err_t MessageQueue :: serializeSlot(SlotID slot, char ** mem, std::size_t * size) +err_t MessageQueue :: serializeSlot(memslot_t slot, char ** mem, std::size_t * size) { ASSERT(slot != LPF_INVALID_MEMSLOT); ASSERT(mem != nullptr); ASSERT(size != nullptr); #ifdef LPF_CORE_MPI_USES_zero - auto mr = m_ibverbs.getMR(slot, m_pid); + auto mr = m_ibverbs.getMR(m_memreg.getVerbID(slot), m_pid); *size = mr.serialize(mem); return LPF_SUCCESS; #else @@ -270,13 +270,13 @@ err_t MessageQueue :: serializeSlot(SlotID slot, char ** mem, std::size_t * size } -err_t MessageQueue :: deserializeSlot(char * mem, SlotID slot) +err_t MessageQueue :: deserializeSlot(char * mem, memslot_t slot) { ASSERT(mem != nullptr); ASSERT(slot != LPF_INVALID_MEMSLOT); #ifdef LPF_CORE_MPI_USES_zero auto mr = mpi::MemoryRegistration::deserialize(mem); - m_ibverbs.setMR(slot, m_pid, *mr); + m_ibverbs.setMR(m_memreg.getVerbID(slot), mr->_pid, *mr); return LPF_SUCCESS; #else LOG( 3, "Error: deserialize slot is only implemented for zero engine at the moment."); diff --git a/tests/functional/func_lpf_test_noc_register.cpp b/tests/functional/func_lpf_test_noc_register.cpp index 28d357fb..567d1556 100644 --- a/tests/functional/func_lpf_test_noc_register.cpp +++ b/tests/functional/func_lpf_test_noc_register.cpp @@ -15,6 +15,7 @@ * limitations under the License. */ +#include "mpi.h" #include #include #include "gtest/gtest.h" @@ -29,8 +30,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) char buf2[30] = {'\0'}; strcpy(buf1, "HELLO"); - rc = lpf_resize_memory_register(lpf, 2); - //rc = lpf_noc_resize_memory_register(lpf, 1); + + rc = lpf_resize_memory_register(lpf, 2); // identical to lpf_noc_resize at the moment EXPECT_EQ( LPF_SUCCESS, rc ); EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_resize_message_queue( lpf, 2); @@ -39,13 +40,6 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_sync( lpf, LPF_SYNC_DEFAULT ); EXPECT_EQ( LPF_SUCCESS, rc ); -/** - * \test Testing NOC functionality - * \pre P >= 2 - * \pre P <= 2 - * \return Exit code: 0 - */ - lpf_memslot_t xslot = LPF_INVALID_MEMSLOT; lpf_memslot_t yslot = LPF_INVALID_MEMSLOT; rc = lpf_register_local( lpf, buf1, sizeof(buf1), &xslot ); @@ -56,24 +50,22 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) char * buffer; size_t bufferSize; - lpf_serialize_slot(lpf, xslot, &buffer, &bufferSize); + lpf_serialize_slot(lpf, yslot, &buffer, &bufferSize); - //int left = (nprocs + pid - 1) % nprocs; + int left = (nprocs + pid - 1) % nprocs; int right = ( pid + 1) % nprocs; - //char rmtBuff[bufSize]; - - //MPI_Sendrecv(buffer, bufSize, MPI_BYTE, left, 0, rmtBuff, bufSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + char rmtBuff[bufferSize]; + MPI_Sendrecv(buffer, bufferSize, MPI_BYTE, left, 0, rmtBuff, bufferSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - - lpf_deserialize_slot(lpf, buffer, yslot); - lpf_noc_put(lpf, xslot, 0, right, yslot, 0, sizeof(buf1), LPF_MSG_DEFAULT); + rc = lpf_deserialize_slot(lpf, rmtBuff, yslot); + EXPECT_EQ( LPF_SUCCESS, rc ); + rc = lpf_noc_put(lpf, xslot, 0, right, yslot, 0, sizeof(buf1), LPF_MSG_DEFAULT); EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_sync(lpf, LPF_SYNC_DEFAULT); EXPECT_EQ( LPF_SUCCESS, rc ); - EXPECT_EQ(std::string(buf2), std::string(buf1)); - rc = lpf_noc_deregister(lpf, xslot); + rc = lpf_deregister(lpf, xslot); EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_noc_deregister(lpf, yslot); EXPECT_EQ( LPF_SUCCESS, rc ); From bf68a0cac1e9f808aabf2b094faa9dd9c2696fd5 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Fri, 13 Dec 2024 17:46:41 +0100 Subject: [PATCH 19/28] Update test name, name it 'lpf_test_noc_ring' --- tests/functional/CMakeLists.txt | 4 ++-- ...est_noc_register.cpp => func_lpf_test_noc_ring.cpp} | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) rename tests/functional/{func_lpf_test_noc_register.cpp => func_lpf_test_noc_ring.cpp} (91%) diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 4eac9862..b4f41c5a 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -154,8 +154,8 @@ endforeach(LPF_IMPL_ID) # (part of HiCR project) set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) set(mode "") - set(exeName "func_lpf_test_noc_register_zero_${LPF_IMPL_CONFIG}${mode}") - add_gtest(${exeName} "zero" OFF "${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_test_noc_register.cpp") + set(exeName "func_lpf_test_noc_ring_zero_${LPF_IMPL_CONFIG}${mode}") + add_gtest(${exeName} "zero" OFF "${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_test_noc_ring.cpp") diff --git a/tests/functional/func_lpf_test_noc_register.cpp b/tests/functional/func_lpf_test_noc_ring.cpp similarity index 91% rename from tests/functional/func_lpf_test_noc_register.cpp rename to tests/functional/func_lpf_test_noc_ring.cpp index 567d1556..9d4ae925 100644 --- a/tests/functional/func_lpf_test_noc_register.cpp +++ b/tests/functional/func_lpf_test_noc_ring.cpp @@ -47,16 +47,16 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) rc = lpf_noc_register( lpf, buf2, sizeof(buf2), &yslot ); EXPECT_EQ( LPF_SUCCESS, rc ); + + //int left = (nprocs + pid - 1) % nprocs; + int right = ( pid + 1) % nprocs; char * buffer; size_t bufferSize; lpf_serialize_slot(lpf, yslot, &buffer, &bufferSize); - - int left = (nprocs + pid - 1) % nprocs; - int right = ( pid + 1) % nprocs; char rmtBuff[bufferSize]; - MPI_Sendrecv(buffer, bufferSize, MPI_BYTE, left, 0, rmtBuff, bufferSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + //MPI_Sendrecv(buffer, bufferSize, MPI_BYTE, left, 0, rmtBuff, bufferSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); rc = lpf_deserialize_slot(lpf, rmtBuff, yslot); EXPECT_EQ( LPF_SUCCESS, rc ); @@ -72,7 +72,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } -TEST( API, func_lpf_put_parallel_single ) +TEST( API, func_lpf_test_noc_ring ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); EXPECT_EQ( LPF_SUCCESS, rc ); From a9dadebfd09c5e954f4588cf261e0bcf6cf58985 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Sat, 14 Dec 2024 19:35:06 +0100 Subject: [PATCH 20/28] Refactoring towards registering NOC slots as NOC slots, and not as local slots. --- src/MPI/CMakeLists.txt | 3 +-- src/MPI/ibverbs.hpp | 1 + src/MPI/ibverbsNoc.cpp | 4 ++-- src/MPI/ibverbsNoc.hpp | 2 +- src/MPI/ibverbsZero.cpp | 2 +- src/MPI/memorytable.cpp | 14 +++++++++----- src/MPI/memorytable.hpp | 14 +++++++++++--- tests/functional/func_lpf_test_noc_ring.cpp | 4 ++-- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/MPI/CMakeLists.txt b/src/MPI/CMakeLists.txt index db95d256..c926c42b 100644 --- a/src/MPI/CMakeLists.txt +++ b/src/MPI/CMakeLists.txt @@ -194,8 +194,7 @@ if (MPI_FOUND) # Other unit tests if (ENABLE_IBVERBS AND LPF_ENABLE_TESTS) add_gtest( ibverbs_test "ibverbs" ON ${CMAKE_CURRENT_SOURCE_DIR}/ibverbs.t.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ibverbs.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/mpilib.cpp) + ibverbs.cpp mpilib.cpp) add_gtest( zero_test "zero" ON ${CMAKE_CURRENT_SOURCE_DIR}/ibverbs.t.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ibverbsZero.cpp diff --git a/src/MPI/ibverbs.hpp b/src/MPI/ibverbs.hpp index b9f7d6aa..b165f777 100644 --- a/src/MPI/ibverbs.hpp +++ b/src/MPI/ibverbs.hpp @@ -89,6 +89,7 @@ class _LPFLIB_LOCAL IBVerbs void resizeMesgq( size_t size ); SlotID regLocal( void * addr, size_t size ); + SlotID regNoc( void * addr, size_t size ); SlotID regGlobal( void * addr, size_t size ); void dereg( SlotID id ); diff --git a/src/MPI/ibverbsNoc.cpp b/src/MPI/ibverbsNoc.cpp index 61a4a0c4..7f185fc1 100644 --- a/src/MPI/ibverbsNoc.cpp +++ b/src/MPI/ibverbsNoc.cpp @@ -64,13 +64,13 @@ namespace mpi { } - IBVerbs::SlotID IBVerbsNoc :: regLocal( void * addr, size_t size ) + IBVerbs::SlotID IBVerbsNoc :: regNoc( void * addr, size_t size ) { ASSERT( size <= m_maxRegSize ); MemorySlot slot; if ( size > 0) { - LOG(4, "Registering locally memory area at " << addr << " of size " << size ); + LOG(4, "IBVerbsNoc::regLocal: Registering locally memory area at " << addr << " of size " << size ); struct ibv_mr * const ibv_mr_new_p = ibv_reg_mr( m_pd.get(), addr, size, IBV_ACCESS_REMOTE_READ | IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE diff --git a/src/MPI/ibverbsNoc.hpp b/src/MPI/ibverbsNoc.hpp index d66e8e29..d9ece946 100644 --- a/src/MPI/ibverbsNoc.hpp +++ b/src/MPI/ibverbsNoc.hpp @@ -10,7 +10,7 @@ namespace mpi class _LPFLIB_LOCAL IBVerbsNoc : public IBVerbs { public: IBVerbsNoc(Communication & comm); - IBVerbs::SlotID regLocal( void * addr, size_t size ); + IBVerbs::SlotID regNoc( void * addr, size_t size ); MemoryRegistration getMR(SlotID slotId, int pid); void setMR(SlotID slotId, int pid, MemoryRegistration & mr); diff --git a/src/MPI/ibverbsZero.cpp b/src/MPI/ibverbsZero.cpp index 29ba3445..53f5639b 100644 --- a/src/MPI/ibverbsZero.cpp +++ b/src/MPI/ibverbsZero.cpp @@ -619,7 +619,7 @@ IBVerbs :: SlotID IBVerbs :: regLocal( void * addr, size_t size ) MemoryRegistration local((char *) addr, size, size?slot.mr->lkey:0, size?slot.mr->rkey:0, m_pid); SlotID id = m_memreg.addLocalReg( slot ); - tryIncrement(Op::SEND/* <- dummy for init */, Phase::INIT, id); + tryIncrement(Op::SEND, Phase::INIT, id); m_memreg.update( id ).glob.resize( m_nprocs ); m_memreg.update( id ).glob[m_pid] = local; diff --git a/src/MPI/memorytable.cpp b/src/MPI/memorytable.cpp index 3c94d0fa..63841c60 100644 --- a/src/MPI/memorytable.cpp +++ b/src/MPI/memorytable.cpp @@ -23,8 +23,10 @@ namespace lpf { MemoryTable :: MemoryTable( Communication & comm -#if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero +#if defined LPF_CORE_MPI_USES_ibverbs , mpi::IBVerbs & ibverbs +#elif defined LPF_CORE_MPI_USES_zero + , mpi::IBVerbsNoc & ibverbs #endif ) : m_memreg() @@ -45,12 +47,14 @@ MemoryTable :: MemoryTable( Communication & comm MemoryTable :: Slot MemoryTable :: addNoc( void * mem, std::size_t size ) // nothrow { -#if defined LPF_CORE_MPI_USES_zero || defined LPF_CORE_MPI_USES_ibverbs - Memory rec( mem, size, m_ibverbs.regLocal(mem, size)); + ASSERT(mem != nullptr); + ASSERT(size != 0); +#if defined LPF_CORE_MPI_USES_zero + Memory rec( mem, size, m_ibverbs.regNoc(mem, size)); + return m_memreg.addNocReg( rec); #else - Memory rec(mem, size); + return m_memreg.invalidSlot(); #endif - return m_memreg.addNocReg( rec); } MemoryTable :: Slot diff --git a/src/MPI/memorytable.hpp b/src/MPI/memorytable.hpp index d00cc474..cb3b3d6d 100644 --- a/src/MPI/memorytable.hpp +++ b/src/MPI/memorytable.hpp @@ -23,8 +23,10 @@ #include "assert.hpp" #include "linkage.hpp" -#if defined (LPF_CORE_MPI_USES_ibverbs) || defined (LPF_CORE_MPI_USES_zero) +#if defined LPF_CORE_MPI_USES_ibverbs #include "ibverbs.hpp" +#elif defined LPF_CORE_MPI_USES_zero +#include "ibverbsNoc.hpp" #endif @@ -64,8 +66,10 @@ class _LPFLIB_LOCAL MemoryTable static Slot invalidSlot() { return Register::invalidSlot(); } -#if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero +#if defined LPF_CORE_MPI_USES_ibverbs explicit MemoryTable( Communication & comm, mpi::IBVerbs & verbs ); +#elif defined LPF_CORE_MPI_USES_zero + explicit MemoryTable( Communication & comm, mpi::IBVerbsNoc & verbs ); #else explicit MemoryTable( Communication & comm ); #endif @@ -119,10 +123,14 @@ class _LPFLIB_LOCAL MemoryTable Communication & m_comm; #endif -#if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero +#if defined LPF_CORE_MPI_USES_ibverbs DirtyList m_added; mpi::IBVerbs & m_ibverbs; Communication & m_comm; +#elif defined LPF_CORE_MPI_USES_zero + DirtyList m_added; + mpi::IBVerbsNoc & m_ibverbs; + Communication & m_comm; #endif }; diff --git a/tests/functional/func_lpf_test_noc_ring.cpp b/tests/functional/func_lpf_test_noc_ring.cpp index 9d4ae925..465b94e0 100644 --- a/tests/functional/func_lpf_test_noc_ring.cpp +++ b/tests/functional/func_lpf_test_noc_ring.cpp @@ -48,7 +48,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) EXPECT_EQ( LPF_SUCCESS, rc ); - //int left = (nprocs + pid - 1) % nprocs; + int left = (nprocs + pid - 1) % nprocs; int right = ( pid + 1) % nprocs; char * buffer; @@ -56,7 +56,7 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) lpf_serialize_slot(lpf, yslot, &buffer, &bufferSize); char rmtBuff[bufferSize]; - //MPI_Sendrecv(buffer, bufferSize, MPI_BYTE, left, 0, rmtBuff, bufferSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Sendrecv(buffer, bufferSize, MPI_BYTE, left, 0, rmtBuff, bufferSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); rc = lpf_deserialize_slot(lpf, rmtBuff, yslot); EXPECT_EQ( LPF_SUCCESS, rc ); From bb65de37738812551a08d8265d6682cc56ef4b41 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Sat, 14 Dec 2024 19:48:00 +0100 Subject: [PATCH 21/28] Slightly refactoring verbs API and lpf API test for NOC functionaliy of zero engine. Also, fix the lpf API test to 2 processes. --- src/MPI/func_verbs_test_noc_register.cpp | 28 ++------------------- tests/functional/func_lpf_test_noc_ring.cpp | 8 +++++- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/MPI/func_verbs_test_noc_register.cpp b/src/MPI/func_verbs_test_noc_register.cpp index 85c185ff..6e9ad17f 100644 --- a/src/MPI/func_verbs_test_noc_register.cpp +++ b/src/MPI/func_verbs_test_noc_register.cpp @@ -32,7 +32,7 @@ extern "C" const int LPF_MPI_AUTO_INITIALIZE=0; * \pre P <= 2 * \return Exit code: 0 */ -TEST( API, func_lpf_test_noc_register ) +TEST( API, func_verbsAPI_zero_test_noc_ring ) { char buf1[30] = {'\0'}; @@ -56,22 +56,8 @@ TEST( API, func_lpf_test_noc_register ) comm->barrier(); IBVerbs::SlotID b1 = verbs->regLocal( buf1, sizeof(buf1) ); - IBVerbs::SlotID b2 = verbs->regLocal( buf2, sizeof(buf2) ); + IBVerbs::SlotID b2 = verbs->regNoc( buf2, sizeof(buf2) ); - /* - * Every LPF MemorySlot struct consists of - * - shared_ptr - * - std::vector - * - * For global slots, the vector of registrations needs - * to be allgathered. - * In the case of NOC slots, this functionality needs to - * be performed out-of-band - * - * Specific for THIS example, we can use direct - * MPI communication to send to left-hand - * partner the MemoryRegistration information - */ auto mr = verbs->getMR(b1, rank); mr = verbs->getMR(b2, rank); assert(mr._addr != nullptr); @@ -86,21 +72,11 @@ TEST( API, func_lpf_test_noc_register ) MPI_Sendrecv(buffer, bufSize, MPI_BYTE, left, 0, rmtBuff, bufSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - // Populate the memory region - MemoryRegistration * newMr = MemoryRegistration::deserialize(rmtBuff); verbs->setMR(b2, right, *newMr); comm->barrier(); - - - /* Having exchanged out-of-band the slot information, - * each left-hand partner then puts data into the slot - * of its right-hand partner. - */ verbs->put( b1, 0, right, b2, 0, sizeof(buf1)); - verbs->sync(true); - // Every process should copy EXPECT_EQ(std::string(buf2), std::string(buf1)); verbs->dereg(b1); verbs->dereg(b2); diff --git a/tests/functional/func_lpf_test_noc_ring.cpp b/tests/functional/func_lpf_test_noc_ring.cpp index 465b94e0..d10463f9 100644 --- a/tests/functional/func_lpf_test_noc_ring.cpp +++ b/tests/functional/func_lpf_test_noc_ring.cpp @@ -72,7 +72,13 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) } -TEST( API, func_lpf_test_noc_ring ) +/** + * \test Testing NOC functionality + * \pre P >= 2 + * \pre P <= 2 + * \return Exit code: 0 + */ +TEST( API, func_lpfAPI_test_noc_ring ) { lpf_err_t rc = lpf_exec( LPF_ROOT, LPF_MAX_P, spmd, LPF_NO_ARGS); EXPECT_EQ( LPF_SUCCESS, rc ); From 52ea900d12dbea3a5e472cfd88eda46315475335 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Sun, 15 Dec 2024 09:22:29 +0100 Subject: [PATCH 22/28] rename serialize/deserialize to be named lpf_noc_* --- include/lpf/noc.h | 4 ++-- src/MPI/core.cpp | 4 ++-- tests/functional/func_lpf_test_noc_ring.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/lpf/noc.h b/include/lpf/noc.h index 0b878c3b..8949f6e7 100644 --- a/include/lpf/noc.h +++ b/include/lpf/noc.h @@ -439,7 +439,7 @@ lpf_err_t lpf_noc_get( ); extern _LPFLIB_API -lpf_err_t lpf_serialize_slot( +lpf_err_t lpf_noc_serialize_slot( lpf_t ctx, lpf_memslot_t slot, char ** buff, @@ -454,7 +454,7 @@ lpf_err_t lpf_serialize_slot( * @lpf_serialize_slot */ extern _LPFLIB_API - lpf_err_t lpf_deserialize_slot( + lpf_err_t lpf_noc_deserialize_slot( lpf_t ctx, char * buff, lpf_memslot_t slot diff --git a/src/MPI/core.cpp b/src/MPI/core.cpp index f8d2c9ad..2f819930 100644 --- a/src/MPI/core.cpp +++ b/src/MPI/core.cpp @@ -477,7 +477,7 @@ lpf_err_t lpf_noc_get( return LPF_SUCCESS; } -lpf_err_t lpf_serialize_slot( +lpf_err_t lpf_noc_serialize_slot( lpf_t ctx, lpf_memslot_t slot, char ** buff, @@ -491,7 +491,7 @@ lpf_err_t lpf_serialize_slot( return LPF_ERR_FATAL; } -lpf_err_t lpf_deserialize_slot( +lpf_err_t lpf_noc_deserialize_slot( lpf_t ctx, char * buff, lpf_memslot_t slot diff --git a/tests/functional/func_lpf_test_noc_ring.cpp b/tests/functional/func_lpf_test_noc_ring.cpp index d10463f9..1050b68e 100644 --- a/tests/functional/func_lpf_test_noc_ring.cpp +++ b/tests/functional/func_lpf_test_noc_ring.cpp @@ -53,12 +53,12 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) char * buffer; size_t bufferSize; - lpf_serialize_slot(lpf, yslot, &buffer, &bufferSize); + lpf_noc_serialize_slot(lpf, yslot, &buffer, &bufferSize); char rmtBuff[bufferSize]; MPI_Sendrecv(buffer, bufferSize, MPI_BYTE, left, 0, rmtBuff, bufferSize, MPI_BYTE, right, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - rc = lpf_deserialize_slot(lpf, rmtBuff, yslot); + rc = lpf_noc_deserialize_slot(lpf, rmtBuff, yslot); EXPECT_EQ( LPF_SUCCESS, rc ); rc = lpf_noc_put(lpf, xslot, 0, right, yslot, 0, sizeof(buf1), LPF_MSG_DEFAULT); EXPECT_EQ( LPF_SUCCESS, rc ); From 7078fe676275d385970c58c14c3961c14043832b Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Sun, 15 Dec 2024 14:54:46 +0100 Subject: [PATCH 23/28] Complete merging manually, LPF_HAS_ABORT was missing for some conflicting files --- include/lpf/core.h | 2 +- src/MPI/CMakeLists.txt | 4 ---- src/MPI/core.cpp | 5 +++++ src/hybrid/core.cpp | 4 ++++ src/imp/core.c | 2 ++ tests/functional/CMakeLists.txt | 15 ++++----------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/lpf/core.h b/include/lpf/core.h index a3aac6b5..0d4434e2 100644 --- a/include/lpf/core.h +++ b/include/lpf/core.h @@ -990,7 +990,7 @@ typedef struct lpf_machine { * both bounds are inclusive. * \param[in] min_msg_size A byte size value that is larger or equal to 0. * \param[in] attr A #lpf_sync_attr_t value. When in doubt, always - * use #LPF_SYNC_DEFAULT + * use #LPF_SYNC_DEFAULT. * * \returns The guaranteed value for the message gap given an LPF SPMD * section using \a p processes, for a superstep in which a user diff --git a/src/MPI/CMakeLists.txt b/src/MPI/CMakeLists.txt index 4b00b33d..636b243c 100644 --- a/src/MPI/CMakeLists.txt +++ b/src/MPI/CMakeLists.txt @@ -23,11 +23,7 @@ if (MPI_FOUND) endif() if (ENABLE_IBVERBS) -<<<<<<< HEAD list(APPEND MPI_ENGINES ibverbs zero) -======= - list(APPEND MPI_ENGINES ibverbs) ->>>>>>> master endif() if (MPI_IBARRIER) diff --git a/src/MPI/core.cpp b/src/MPI/core.cpp index 2f263eef..dc3f0a0f 100644 --- a/src/MPI/core.cpp +++ b/src/MPI/core.cpp @@ -38,6 +38,11 @@ #include + +// the value 2 in this implementation indicates support for lpf_abort in a way +// that may deviate from the stdlib abort() +const int LPF_HAS_ABORT = 2; + // Error codes. // Note: Some code (e.g. in process::broadcastSymbol) depends on the // fact that numbers are assigned in order of severity, where 0 means diff --git a/src/hybrid/core.cpp b/src/hybrid/core.cpp index cec834ea..16b738d6 100644 --- a/src/hybrid/core.cpp +++ b/src/hybrid/core.cpp @@ -37,6 +37,10 @@ extern "C" { +// the value 2 in this implementation indicates support for lpf_abort in a way +// that may deviate from the stdlib abort() +_LPFLIB_VAR const int LPF_HAS_ABORT = 2; + _LPFLIB_VAR const lpf_err_t LPF_SUCCESS = 0; _LPFLIB_VAR const lpf_err_t LPF_ERR_OUT_OF_MEMORY = 1; _LPFLIB_VAR const lpf_err_t LPF_ERR_FATAL = 2; diff --git a/src/imp/core.c b/src/imp/core.c index 4ad623c0..994a18fd 100644 --- a/src/imp/core.c +++ b/src/imp/core.c @@ -23,6 +23,8 @@ #include #include +const int LPF_HAS_ABORT = 0; + const lpf_err_t LPF_SUCCESS = 0; const lpf_err_t LPF_ERR_OUT_OF_MEMORY = 1; const lpf_err_t LPF_ERR_FATAL = 2; diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 6f843a33..04ebf85d 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -146,17 +146,10 @@ endforeach(LPF_IMPL_ID) # Individual test for NOC (Non-coherence) protocol, only for zero engine # (part of HiCR project) - set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) - set(mode "") - set(exeName "func_lpf_test_noc_ring_zero_${LPF_IMPL_CONFIG}${mode}") - add_gtest(${exeName} "zero" OFF "${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_test_noc_ring.cpp") - - - - add_gtest(${exeName} ${LPF_IMPL_ID} ${debug} "${CMAKE_CURRENT_SOURCE_DIR}/${testSource}") - - endforeach(testSource) -endforeach(LPF_IMPL_ID) +set(LPF_IMPL_CONFIG ${LPFLIB_CONFIG_NAME}) +set(mode "") +set(exeName "func_lpf_test_noc_ring_zero_${LPF_IMPL_CONFIG}${mode}") +add_gtest(${exeName} "zero" OFF "${CMAKE_CURRENT_SOURCE_DIR}/func_lpf_test_noc_ring.cpp") # start of engine-specific tests foreach (LPF_IMPL_ID ${ENGINES}) From 141e55b29f584df83f86b66e900dd0c28ddbe7df Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Mon, 16 Dec 2024 14:18:33 +0100 Subject: [PATCH 24/28] During the merge, forgot to re-introduce zero engine, back on --- CMakeLists.txt | 1 + tests/functional/func_lpf_probe_parallel_nested.cpp | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 844a4499..eb12c8bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,6 +176,7 @@ if ( LIB_MATH AND LIB_DL AND MPI_FOUND ) if (ENABLE_IBVERBS) list(APPEND ENGINES "ibverbs") + list(APPEND ENGINES "zero") endif() endif() diff --git a/tests/functional/func_lpf_probe_parallel_nested.cpp b/tests/functional/func_lpf_probe_parallel_nested.cpp index f594b7b8..5381bffe 100644 --- a/tests/functional/func_lpf_probe_parallel_nested.cpp +++ b/tests/functional/func_lpf_probe_parallel_nested.cpp @@ -117,8 +117,8 @@ void spmd1( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) EXPECT_LT( 0.0, (*(subMachine.g))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); EXPECT_LT( 0.0, (*(subMachine.l))(machine.p, (size_t)(-1), LPF_SYNC_DEFAULT) ); - const int pthread = 1, mpirma = 1, mpimsg = 1, hybrid = 0, ibverbs=1; - (void) pthread; (void) mpirma; (void) mpimsg; (void) hybrid; (void) ibverbs; + const int pthread = 1, mpirma = 1, mpimsg = 1, hybrid = 0, ibverbs=1, zero = 1; + (void) pthread; (void) mpirma; (void) mpimsg; (void) hybrid; (void) ibverbs; (void) zero; if (LPF_CORE_IMPL_ID) // this part is disabled for the hybrid implementation, because { // that one doesn't do generic nesting of lpf_exec's EXPECT_EQ( 1, subMachine.free_p == 2 || subMachine.free_p == 3 ); @@ -203,5 +203,4 @@ TEST( API, func_lpf_probe_parallel_nested ) rc = lpf_exec( LPF_ROOT, machine.p / 2, &spmd1, args ); EXPECT_EQ( LPF_SUCCESS, rc ); - } From 5074ff2288889aaf67811aec73f5ffc9d5b2a65e Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Thu, 23 Jan 2025 18:41:05 +0100 Subject: [PATCH 25/28] This commit fixes a bug in the zero-cost synchronization method countingSyncPerSlot, which fails correctly to account for all received messages. The key is that a message can be received either via a put from a remote active process, or via a get from the local active process. This was uncovered during tests in the HiCR project. Other minor improvements: 1) The MemoryRegistration is now a separate class outside of IBVerbs, which helps in future efforts if we serialize its information. 2) Improve logging inside IBVerbs communication. 3) Follow the pattern to pass on a memslot_t in all methods declared in mesgqueue.hpp, and then convert the slot ID via getVerbID. I suspect this is important to avoid issues. --- src/MPI/ibverbsZero.cpp | 76 +++++++++++++++++++++++------------------ src/MPI/memorytable.cpp | 9 +++++ src/MPI/memorytable.hpp | 3 +- src/MPI/mesgqueue.cpp | 17 +++++---- src/MPI/mesgqueue.hpp | 15 ++++---- 5 files changed, 68 insertions(+), 52 deletions(-) diff --git a/src/MPI/ibverbsZero.cpp b/src/MPI/ibverbsZero.cpp index 53f5639b..7cec923a 100644 --- a/src/MPI/ibverbsZero.cpp +++ b/src/MPI/ibverbsZero.cpp @@ -260,7 +260,7 @@ IBVerbs :: ~IBVerbs() inline void IBVerbs :: tryIncrement(Op op, Phase phase, SlotID slot) { - + switch (phase) { case Phase::INIT: rcvdMsgCount[slot] = 0; @@ -353,7 +353,7 @@ void IBVerbs :: doRemoteProgress() { pollResult = ibv_poll_cq(m_cqRemote.get(), POLL_BATCH, wcs); if (pollResult > 0) { LOG(3, "Process " << m_pid << " signals: I received " << pollResult << " remote messages in doRemoteProgress"); - } + } else if (pollResult < 0) { LOG( 1, "Failed to poll IB completion queue" ); @@ -368,10 +368,10 @@ void IBVerbs :: doRemoteProgress() { << wcs[i].vendor_err ); } else { - LOG(2, "Process " << m_pid << " Recv wcs[" << i << "].src_qp = "<< wcs[i].src_qp); - LOG(2, "Process " << m_pid << " Recv wcs[" << i << "].slid = "<< wcs[i].slid); - LOG(2, "Process " << m_pid << " Recv wcs[" << i << "].wr_id = "<< wcs[i].wr_id); - LOG(2, "Process " << m_pid << " Recv wcs[" << i << "].imm_data = "<< wcs[i].imm_data); + LOG(3, "Process " << m_pid << " Recv wcs[" << i << "].src_qp = "<< wcs[i].src_qp); + LOG(3, "Process " << m_pid << " Recv wcs[" << i << "].slid = "<< wcs[i].slid); + LOG(3, "Process " << m_pid << " Recv wcs[" << i << "].wr_id = "<< wcs[i].wr_id); + LOG(3, "Process " << m_pid << " Recv wcs[" << i << "].imm_data = "<< wcs[i].imm_data); /** * Here is a trick: @@ -719,7 +719,7 @@ void IBVerbs :: blockingCompareAndSwap(SlotID srcSlot, size_t srcOffset, int dst } /** - * Keep waiting on a completion of events until you + * Keep waiting on a completion of events until you * register a completed atomic compare-and-swap */ do { @@ -731,7 +731,7 @@ void IBVerbs :: blockingCompareAndSwap(SlotID srcSlot, size_t srcOffset, int dst } while (std::find(opcodes.begin(), opcodes.end(), IBV_WC_COMP_SWAP) == opcodes.end()); uint64_t * remoteValueFound = reinterpret_cast(localAddr); - /* + /* * if we fetched the value we expected, then * we are holding the lock now (that is, we swapped successfully!) * else, re-post your request for the lock @@ -753,7 +753,6 @@ void IBVerbs :: put( SlotID srcSlot, size_t srcOffset, const MemorySlot & dst = m_memreg.lookup( dstSlot ); ASSERT( src.mr ); - ASSERT( dst.mr ); int numMsgs = size/m_maxMsgSize + (size % m_maxMsgSize > 0); //+1 if last msg size < m_maxMsgSize if (size == 0) numMsgs = 1; @@ -782,9 +781,9 @@ void IBVerbs :: put( SlotID srcSlot, size_t srcOffset, sr->send_flags = lastMsg ? IBV_SEND_SIGNALED : 0; sr->opcode = lastMsg? IBV_WR_RDMA_WRITE_WITH_IMM : IBV_WR_RDMA_WRITE; /* use wr_id to later demultiplex srcSlot */ - sr->wr_id = srcSlot; + sr->wr_id = srcSlot; /* - * In HiCR, we need to know at receiver end which slot + * In HiCR, we need to know at receiver end which slot * has received the message. But here is a trick: */ sr->imm_data = dstSlot; @@ -887,23 +886,23 @@ void IBVerbs :: get_sent_msg_count(size_t * sent_msgs) { void IBVerbs :: get_rcvd_msg_count_per_slot(size_t * rcvd_msgs, SlotID slot) { - *rcvd_msgs = rcvdMsgCount[slot]; + *rcvd_msgs = rcvdMsgCount[slot] + getMsgCount[slot]; } void IBVerbs :: get_sent_msg_count_per_slot(size_t * sent_msgs, SlotID slot) { - *sent_msgs = sentMsgCount.at(slot); + *sent_msgs = sentMsgCount[slot]; } std::vector IBVerbs :: wait_completion(int& error) { error = 0; - LOG(5, "Polling for messages" ); + LOG(1, "Polling for messages" ); struct ibv_wc wcs[POLL_BATCH]; int pollResult = ibv_poll_cq(m_cqLocal.get(), POLL_BATCH, wcs); std::vector opcodes; if ( pollResult > 0) { - LOG(3, "Process " << m_pid << ": Received " << pollResult << " acknowledgements"); + LOG(4, "Process " << m_pid << ": Received " << pollResult << " acknowledgements"); for (int i = 0; i < pollResult ; ++i) { if (wcs[i].status != IBV_WC_SUCCESS) @@ -918,10 +917,10 @@ std::vector IBVerbs :: wait_completion(int& error) { error = 1; } else { - LOG(3, "Process " << m_pid << " Send wcs[" << i << "].src_qp = "<< wcs[i].src_qp); - LOG(3, "Process " << m_pid << " Send wcs[" << i << "].slid = "<< wcs[i].slid); - LOG(3, "Process " << m_pid << " Send wcs[" << i << "].wr_id = "<< wcs[i].wr_id); - LOG(3, "Process " << m_pid << " Send wcs[" << i << "].imm_data = "<< wcs[i].imm_data); + LOG(4, "Process " << m_pid << " Send wcs[" << i << "].src_qp = "<< wcs[i].src_qp); + LOG(4, "Process " << m_pid << " Send wcs[" << i << "].slid = "<< wcs[i].slid); + LOG(4, "Process " << m_pid << " Send wcs[" << i << "].wr_id = "<< wcs[i].wr_id); + LOG(4, "Process " << m_pid << " Send wcs[" << i << "].imm_data = "<< wcs[i].imm_data); } SlotID slot = wcs[i].wr_id; @@ -931,18 +930,20 @@ std::vector IBVerbs :: wait_completion(int& error) { // This is a get call completing if (wcs[i].opcode == IBV_WC_RDMA_READ) { tryIncrement(Op::GET, Phase::POST, slot); + LOG(4, "Rank " << m_pid << " with GET, increments getMsgCount to " << getMsgCount[slot] << " for LPF slot " << slot); } // This is a put call completing - if (wcs[i].opcode == IBV_WC_RDMA_WRITE) + if (wcs[i].opcode == IBV_WC_RDMA_WRITE) { tryIncrement(Op::SEND, Phase::POST, slot); + LOG(4, "Rank " << m_pid << " with SEND, increments getMsgCount to " << sentMsgCount[slot] << " for LPF slot " << slot); + } - LOG(3, "Rank " << m_pid << " increments sent message count to " << sentMsgCount[slot] << " for LPF slot " << slot); } } } else if (pollResult < 0) { - LOG( 5, "Failed to poll IB completion queue" ); + LOG( 1, "Failed to poll IB completion queue" ); throw Exception("Poll CQ failure"); } return opcodes; @@ -977,6 +978,10 @@ void IBVerbs :: flushSent() void IBVerbs :: countingSyncPerSlot(SlotID slot, size_t expectedSent, size_t expectedRecvd) { + bool sentOK = false; + bool recvdOK = false; + if (expectedSent == 0) sentOK = true; + if (expectedRecvd == 0) recvdOK = true; int error; if (slotActive[slot]) { do { @@ -988,16 +993,21 @@ void IBVerbs :: countingSyncPerSlot(SlotID slot, size_t expectedSent, size_t exp // this call triggers doRemoteProgress doRemoteProgress(); - } while (( - // do we have messages (sent or received) - // which are only initiated but incomplete? - (rcvdMsgCount[slot] < m_recvInitMsgCount[slot]) || - (sentMsgCount[slot] < m_sendInitMsgCount[slot]) - ) && - // do the sent and received messages - // match our expectations? - (rcvdMsgCount[slot] < expectedRecvd - || sentMsgCount[slot] < expectedSent)); + /* + * 1) Are we expecting nothing here (sentOK/recvdOK = true) + * 2) do the sent and received messages match our expectations? + */ + sentOK = (sentOK || sentMsgCount[slot] >= expectedSent); + // We can receive messages passively (from remote puts) and actively (from our gets) + recvdOK = (recvdOK || (rcvdMsgCount[slot] + getMsgCount[slot]) >= expectedRecvd); + LOG(4, "PID: " << m_pid << " rcvdMsgCount[" << slot << "] = " << rcvdMsgCount[slot] + << " expectedRecvd = " << expectedRecvd + << " sentMsgCount[" << slot << "] = " << sentMsgCount[slot] + << " expectedSent = " << expectedSent + << " m_recvInitMsgCount[" << slot << "] = " << m_recvInitMsgCount[slot] + << " m_sendInitMsgCount[" << slot << "] = " << m_sendInitMsgCount[slot]); + + } while (!(sentOK && recvdOK)); } } @@ -1040,7 +1050,7 @@ void IBVerbs :: sync(bool resized) // flush receive queues flushReceived(); - LOG(1, "Process " << m_pid << " will call barrier\n"); + LOG(4, "Process " << m_pid << " will call barrier at end of sync\n"); m_comm.barrier(); diff --git a/src/MPI/memorytable.cpp b/src/MPI/memorytable.cpp index 63841c60..506f2ae9 100644 --- a/src/MPI/memorytable.cpp +++ b/src/MPI/memorytable.cpp @@ -68,6 +68,15 @@ MemoryTable :: addLocal( void * mem, std::size_t size ) // nothrow return m_memreg.addLocalReg( rec); } +#if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero +mpi::IBVerbs::SlotID MemoryTable :: getVerbID(MemoryTable::Slot slot) const +{ + Memory sl = m_memreg.lookup(slot); + ASSERT(sl.slot != m_memreg.invalidSlot()); + return m_memreg.lookup( slot ).slot; +} +#endif + MemoryTable :: Slot MemoryTable :: addGlobal( void * mem, std::size_t size ) // nothrow { diff --git a/src/MPI/memorytable.hpp b/src/MPI/memorytable.hpp index cb3b3d6d..1308aa33 100644 --- a/src/MPI/memorytable.hpp +++ b/src/MPI/memorytable.hpp @@ -96,8 +96,7 @@ class _LPFLIB_LOCAL MemoryTable #endif #if defined LPF_CORE_MPI_USES_ibverbs || defined LPF_CORE_MPI_USES_zero - mpi::IBVerbs::SlotID getVerbID( Slot slot ) const - { return m_memreg.lookup( slot ).slot; } + mpi::IBVerbs::SlotID getVerbID( Slot slot ) const; #endif void reserve( size_t size ); // throws bad_alloc, strong safe diff --git a/src/MPI/mesgqueue.cpp b/src/MPI/mesgqueue.cpp index c83344b0..0c0f05f2 100644 --- a/src/MPI/mesgqueue.cpp +++ b/src/MPI/mesgqueue.cpp @@ -1074,7 +1074,7 @@ int MessageQueue :: sync( bool abort ) } -int MessageQueue :: countingSyncPerSlot(SlotID slot, size_t expected_sent, size_t expected_rcvd) +int MessageQueue :: countingSyncPerSlot(memslot_t slot, size_t expected_sent, size_t expected_rcvd) { ASSERT(slot != LPF_INVALID_MEMSLOT); @@ -1084,7 +1084,7 @@ int MessageQueue :: countingSyncPerSlot(SlotID slot, size_t expected_sent, size_ // if not, deal with normal sync m_memreg.sync(); - m_ibverbs.countingSyncPerSlot(slot, expected_sent, expected_rcvd); + m_ibverbs.countingSyncPerSlot(m_memreg.getVerbID(slot), expected_sent, expected_rcvd); m_resized = false; @@ -1092,7 +1092,7 @@ int MessageQueue :: countingSyncPerSlot(SlotID slot, size_t expected_sent, size_ return 0; } -int MessageQueue :: syncPerSlot(SlotID slot) +int MessageQueue :: syncPerSlot(memslot_t slot) { ASSERT(slot != LPF_INVALID_MEMSLOT); @@ -1100,7 +1100,7 @@ int MessageQueue :: syncPerSlot(SlotID slot) // if not, deal with normal sync m_memreg.sync(); - m_ibverbs.syncPerSlot(slot); + m_ibverbs.syncPerSlot(m_memreg.getVerbID(slot)); m_resized = false; #endif @@ -1108,14 +1108,14 @@ int MessageQueue :: syncPerSlot(SlotID slot) } -void MessageQueue :: getRcvdMsgCountPerSlot(size_t * msgs, SlotID slot) +void MessageQueue :: getRcvdMsgCountPerSlot(size_t * msgs, memslot_t slot) { ASSERT(msgs != nullptr); ASSERT(slot != LPF_INVALID_MEMSLOT); #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs.get_rcvd_msg_count_per_slot(msgs, slot); + m_ibverbs.get_rcvd_msg_count_per_slot(msgs, m_memreg.getVerbID(slot)); #endif } @@ -1136,14 +1136,13 @@ void MessageQueue :: getSentMsgCount(size_t * msgs) m_ibverbs.get_sent_msg_count(msgs); #endif } - -void MessageQueue :: getSentMsgCountPerSlot(size_t * msgs, SlotID slot) +void MessageQueue :: getSentMsgCountPerSlot(size_t * msgs, memslot_t slot) { ASSERT(msgs != nullptr); ASSERT(slot != LPF_INVALID_MEMSLOT); #ifdef LPF_CORE_MPI_USES_zero *msgs = 0; - m_ibverbs.get_sent_msg_count_per_slot(msgs, slot); + m_ibverbs.get_sent_msg_count_per_slot(msgs, m_memreg.getVerbID(slot)); #endif } diff --git a/src/MPI/mesgqueue.hpp b/src/MPI/mesgqueue.hpp index 0284ebcb..198afa04 100644 --- a/src/MPI/mesgqueue.hpp +++ b/src/MPI/mesgqueue.hpp @@ -37,7 +37,6 @@ #endif //only for HiCR -typedef size_t SlotID; namespace lpf { @@ -74,11 +73,11 @@ class _LPFLIB_LOCAL MessageQueue void unlockSlot( memslot_t srcSlot, size_t srcOffset, pid_t dstPid, memslot_t dstSlot, size_t dstOffset, size_t size ); - void getRcvdMsgCountPerSlot(size_t * msgs, SlotID slot); + void getRcvdMsgCountPerSlot(size_t * msgs, memslot_t slot); void getRcvdMsgCount(size_t * msgs); - void getSentMsgCountPerSlot(size_t * msgs, SlotID slot); + void getSentMsgCountPerSlot(size_t * msgs, memslot_t slot); void getSentMsgCount(size_t * msgs); @@ -86,9 +85,9 @@ class _LPFLIB_LOCAL MessageQueue void flushReceived(); - int countingSyncPerSlot(SlotID slot, size_t expected_sent, size_t expected_rcvd); + int countingSyncPerSlot(memslot_t slot, size_t expected_sent, size_t expected_rcvd); - int syncPerSlot(SlotID slot); + int syncPerSlot(memslot_t slot); // NOC extensions memslot_t addNocReg( void * mem, std::size_t size ); @@ -97,7 +96,7 @@ class _LPFLIB_LOCAL MessageQueue // end only for HiCR private: - enum Msgs { BufPut , + enum Msgs { BufPut , BufGet, BufGetReply, HpPut, HpGet , HpBodyReply , HpEdges, HpEdgesReply }; @@ -106,7 +105,7 @@ class _LPFLIB_LOCAL MessageQueue SrcPid, DstPid, SrcOffset, DstOffset, BufOffset, SrcSlot, DstSlot, Size, - RoundedDstOffset, RoundedSize, + RoundedDstOffset, RoundedSize, Payload, Head, Tail}; struct Edge { @@ -168,7 +167,7 @@ class _LPFLIB_LOCAL MessageQueue mpi::Comm m_comm; std::vector< char > m_tinyMsgBuf; protected: -#if defined LPF_CORE_MPI_USES_ibverbs +#if defined LPF_CORE_MPI_USES_ibverbs mpi::IBVerbs m_ibverbs; #elif defined LPF_CORE_MPI_USES_zero mpi::IBVerbsNoc m_ibverbs; From 26e405f7be13c80f33a6be0a30569bae04acb86e Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Thu, 23 Jan 2025 18:43:03 +0100 Subject: [PATCH 26/28] This commit fixes https://github.com/Algebraic-Programming/LPF/issues/53 . The issues are two: first, the test-lpf-nprocs.c test is wrong, it calls lpf_put / lpf_get after lpf_register_global, not complying to spec. For some reason, only the zero engine exposes this issue. Second, a BSP test is used, which is untested with zero engine, and we disable it for zero engine. --- post-install/post-install-test.cmake.in | 3 +++ post-install/test-lpf-nprocs.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/post-install/post-install-test.cmake.in b/post-install/post-install-test.cmake.in index edd06922..05786d26 100644 --- a/post-install/post-install-test.cmake.in +++ b/post-install/post-install-test.cmake.in @@ -353,6 +353,9 @@ endif() ###### CMake integration using generated CMake module file ############ foreach(engine @ENGINES@) + if ("${engine}" STREQUAL "zero") + continue() + endif() message("Testing generated CMake module files for engine ${engine}") set(test_dir @builddir@/cmake-module-test-${engine}) diff --git a/post-install/test-lpf-nprocs.c b/post-install/test-lpf-nprocs.c index cf274b3f..554b5775 100644 --- a/post-install/test-lpf-nprocs.c +++ b/post-install/test-lpf-nprocs.c @@ -53,6 +53,8 @@ void spmd( lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args ) lpf_memslot_t mem_slot = LPF_INVALID_MEMSLOT; lpf_register_global( lpf, mem, nprocs, &mem_slot ); + lpf_sync(lpf, LPF_SYNC_DEFAULT); + if (pid != 0) lpf_get( lpf, 0, params_slot, 0, params_slot, 0, sizeof(params), LPF_MSG_DEFAULT ); From 974f3dff15619ea9698f75e649831ef08b6186bb Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Thu, 23 Jan 2025 20:35:06 +0100 Subject: [PATCH 27/28] A file from tests is used to validate we can compile LPF MPI simple programs. However, we have ported all tests to use Gtest. In order to decouple the need for Gtest from this simple test, we separate it from the existing test in tests in a simpler form --- post-install/func_lpf_hook_subset.mpimsg.cpp | 67 ++++++++++++++++++++ post-install/post-install-test.cmake.in | 2 +- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 post-install/func_lpf_hook_subset.mpimsg.cpp diff --git a/post-install/func_lpf_hook_subset.mpimsg.cpp b/post-install/func_lpf_hook_subset.mpimsg.cpp new file mode 100644 index 00000000..6b7d3a5c --- /dev/null +++ b/post-install/func_lpf_hook_subset.mpimsg.cpp @@ -0,0 +1,67 @@ + +/* + * Copyright 2021 Huawei Technologies Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + + +const int LPF_MPI_AUTO_INITIALIZE=0; + +void test_spmd( lpf_t ctx, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args) +{ + (void) ctx; + (void) pid; + (void) nprocs; + (void) args; + return; +} + +void subset_func(MPI_Comm comm) +{ + MPI_Barrier(comm); + + lpf_init_t init; + lpf_err_t rc = lpf_mpi_initialize_with_mpicomm(comm, &init); + + rc = lpf_hook(init, test_spmd, LPF_NO_ARGS); +} + +int main(int argc, char **argv) +{ + MPI_Init(&argc, &argv); + + int s; + MPI_Comm_rank(MPI_COMM_WORLD, &s); + + int subset = s < 2; // Processes are divided into 2 subsets {0,1} and {2,...,p-1} + + MPI_Comm subset_comm; + MPI_Comm_split(MPI_COMM_WORLD, subset, s, &subset_comm); + +// only the first subset enters that function + if (subset) + { + subset_func(subset_comm); + } + + MPI_Barrier(MPI_COMM_WORLD); // Paranoid barrier + + MPI_Finalize(); + +} diff --git a/post-install/post-install-test.cmake.in b/post-install/post-install-test.cmake.in index 05786d26..75c5de13 100644 --- a/post-install/post-install-test.cmake.in +++ b/post-install/post-install-test.cmake.in @@ -272,7 +272,7 @@ if (MPI_FOUND) # Compile this to check whether mpi.h can be found execute_process( COMMAND @bindir@/lpfcxx -engine mpimsg -I@common@ - @testdir@/func_lpf_hook_subset.mpimsg.cpp -c + @srcdir@/func_lpf_hook_subset.mpimsg.cpp -c -o lpfhook_subset_mpimsg_cc.o WORKING_DIRECTORY @builddir@ RESULT_VARIABLE status From a455246a5b47a411f142697edea47c4ede05efa2 Mon Sep 17 00:00:00 2001 From: Kiril Dichev Date: Mon, 24 Feb 2025 17:27:17 +0100 Subject: [PATCH 28/28] I think the assertions that a mem slot is not a null poiner and not with size 0 are not needed. In particular, my template for addNoc is addLocal, which needs no such assertions. --- src/MPI/memorytable.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/MPI/memorytable.cpp b/src/MPI/memorytable.cpp index 506f2ae9..4ebb546d 100644 --- a/src/MPI/memorytable.cpp +++ b/src/MPI/memorytable.cpp @@ -47,8 +47,6 @@ MemoryTable :: MemoryTable( Communication & comm MemoryTable :: Slot MemoryTable :: addNoc( void * mem, std::size_t size ) // nothrow { - ASSERT(mem != nullptr); - ASSERT(size != 0); #if defined LPF_CORE_MPI_USES_zero Memory rec( mem, size, m_ibverbs.regNoc(mem, size)); return m_memreg.addNocReg( rec);