Skip to content

Commit 919760f

Browse files
committed
Merge branch 'github_devel_staging' into 'github_devel_branch_tracking'
[LibFabric] Include stdio.h with libfabric and edit unit tests See merge request nvshmem/nvshmem!1520
2 parents a2b558c + 17765a7 commit 919760f

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ endif()
4848
project(
4949
NVSHMEM
5050
LANGUAGES CUDA CXX C
51-
VERSION 3.5.20.0
51+
VERSION 3.5.19.1
5252
)
5353

5454
if(NOT (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") OR

src/host/mem/mem_transport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ nvshmemi_mem_p2p_transport::nvshmemi_mem_p2p_transport(int mype, int npes) {
257257
This is to avoid a case where some PEs on some node are P2P reachable and some PEs on some
258258
node are not, causing asymmetry
259259
*/
260-
peer_error_status = (bool *)std::calloc(sizeof(bool), npes);
260+
peer_error_status = (bool *)std::calloc(npes, sizeof(*peer_error_status));
261261
nvshmemi_boot_handle.allgather((void *)(&errored_on_initialization_), peer_error_status,
262262
sizeof(bool), &nvshmemi_boot_handle);
263263
NVSHMEMU_FOR_EACH(i, npes) {

src/modules/transport/libfabric/libfabric.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <assert.h>
88
#include <stdint.h> // IWYU pragma: keep
9+
#include <stdio.h>
910
#include <stddef.h>
1011
#include <string.h>
1112
#include <deque>

test/host/interop/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ target_link_libraries(simplelib2 PRIVATE nvshmem_test_helper)
3939
target_link_libraries(app PRIVATE simplelib1 simplelib2 nvshmem_test_helper)
4040
target_link_libraries(app_multi_init PRIVATE simplelib1 simplelib2 nvshmem_test_helper)
4141

42+
#
43+
# Some toolchains/distros enable PIE by default for executables. NVCC-produced objects for these
44+
# CUDA test apps may not be compiled with -fPIE, which then fails to link with:
45+
# relocation R_X86_64_32 ... can not be used when making a PIE object
46+
# Disable PIE for these interop test executables to keep the build portable.
47+
#
48+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
49+
target_link_options(app PRIVATE -no-pie)
50+
target_link_options(app_multi_init PRIVATE -no-pie)
51+
endif()
52+
4253
install(TARGETS simplelib1 LIBRARY DESTINATION "${NVSHMEM_TEST_INSTALL_PREFIX}/host/interop")
4354
install(TARGETS simplelib2 LIBRARY DESTINATION "${NVSHMEM_TEST_INSTALL_PREFIX}/host/interop")
4455
install(TARGETS app RUNTIME DESTINATION "${NVSHMEM_TEST_INSTALL_PREFIX}/host/interop")

test/unit/mem/heap/internal/host/nvshmemi_mem_transport.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,27 @@ class nvshmemi_mem_p2p_transport {
5959

6060
void set_heap_size_(nvshmemi_symmetric_heap &heap, size_t size) { heap.heap_size_ = size; }
6161
void set_heap_base_(nvshmemi_symmetric_heap &heap) {
62-
int heap_base = 1;
63-
void *heap_base_ptr = &heap_base;
64-
heap.heap_base_ = heap_base_ptr;
62+
auto &storage = heap_base_storage_[&heap];
63+
if (!storage) storage = std::make_unique<int>(1);
64+
heap.heap_base_ = storage.get();
6565
}
6666

6767
void set_peer_heap_base_p2p_(nvshmemi_symmetric_heap &heap) {
68-
int value = 1;
69-
void *ptr = &value;
70-
heap.peer_heap_base_p2p_ = (void **)std::calloc(1, sizeof(void *));
68+
auto &storage = peer_heap_base_p2p_storage_[&heap];
69+
if (!storage) storage = std::make_unique<int>(1);
70+
void *ptr = storage.get();
71+
72+
if (heap.peer_heap_base_p2p_ == nullptr) {
73+
heap.peer_heap_base_p2p_ = (void **)std::calloc(1, sizeof(void *));
74+
}
7175
heap.peer_heap_base_p2p_[0] = ptr;
7276
}
7377

7478
private:
7579
static nvml_function_table nvml_ftable_;
7680
static void *nvml_handle_;
81+
std::map<nvshmemi_symmetric_heap *, std::unique_ptr<int>> heap_base_storage_;
82+
std::map<nvshmemi_symmetric_heap *, std::unique_ptr<int>> peer_heap_base_p2p_storage_;
7783
explicit nvshmemi_mem_p2p_transport(int mype, int npes){};
7884
static nvshmemi_mem_p2p_transport *p2p_objref_; // singleton instance
7985
};

0 commit comments

Comments
 (0)