Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/sst/elements/iris/libfabric/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,21 @@ libfabric_la_SOURCES = \
$(libfabric_headers) \
$(rdmainclude_headers) \
$(nodist_rdmainclude_headers)

# Standalone libfabric install for mvapich2 (--with-ofi= prefix)
# Install standard libfabric headers to $(includedir)/rdma/ so that
# -I$(prefix)/include gives #include <rdma/fabric.h>
ofi_standalone_rdmadir = $(includedir)/rdma
ofi_standalone_rdma_HEADERS = \
include/rdma/fabric.h \
include/rdma/fi_atomic.h \
include/rdma/fi_cm.h \
include/rdma/fi_collective.h \
include/rdma/fi_domain.h \
include/rdma/fi_endpoint.h \
include/rdma/fi_eq.h \
include/rdma/fi_errno.h \
include/rdma/fi_rma.h \
include/rdma/fi_tagged.h \
include/rdma/fi_trigger.h

9 changes: 9 additions & 0 deletions src/sst/elements/mercury/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ libhg_la_SOURCES = \
common/timestamp.cc \
common/connection.cc \
common/skeleton.cc \
common/hgcc_wrappers.cc \
components/compute_library/node_cl.cc \
components/compute_library/operating_system_cl.cc \
components/compute_library/operating_system_cl_api.cc \
Expand All @@ -46,6 +47,8 @@ libhg_la_SOURCES = \
operating_system/launch/app_launcher.cc \
operating_system/libraries/library.cc \
operating_system/libraries/unblock_event.cc \
operating_system/libraries/pthread/hg_pthread.cc \
operating_system/libraries/pthread/hg_pthread_runner.cc \
operating_system/process/app.cc \
operating_system/process/global.cc \
operating_system/process/progress_queue.cc \
Expand Down Expand Up @@ -172,6 +175,12 @@ nobase_library_include_HEADERS = \
operating_system/libraries/library.h \
operating_system/libraries/library_fwd.h \
operating_system/libraries/unblock_event.h \
operating_system/libraries/pthread/hg_pthread.h \
operating_system/libraries/pthread/hg_pthread_impl.h \
operating_system/libraries/pthread/hg_pthread_macro.h \
operating_system/libraries/pthread/hg_pthread_clear_macros.h \
operating_system/libraries/pthread/hg_pthread_return.h \
operating_system/libraries/pthread/hg_pthread_runner.h \
operating_system/threading/context_util.h \
operating_system/threading/thread_lock.h \
operating_system/threading/stack_alloc.h \
Expand Down
89 changes: 89 additions & 0 deletions src/sst/elements/mercury/common/hgcc_wrappers.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright 2009-2025 NTESS. Under the terms
// of Contract DE-NA0003525 with NTESS, the U.S.
// Government retains certain rights in this software.
//
// Copyright (c) 2009-2025, NTESS
// All rights reserved.
//
// C-linkage wrappers for hgcc replacement headers (sleep, usleep, gettimeofday,
// clock_gettime, nanosleep, getenv). These bridge to mercury's simulated time
// and environment when running under SST.
// Do not include skeleton.h here (it redefines main and breaks SST core headers).

#include <mercury/common/timestamp.h>
#include <mercury/operating_system/process/thread.h>

#include <sys/time.h>
#include <time.h>
#include <cstdint>

namespace SST::Hg {
extern unsigned int ssthg_sleep(unsigned int secs);
extern unsigned int ssthg_usleep(unsigned int usecs);
extern unsigned int ssthg_nanosleep(unsigned int nsecs);
}

extern "C" char* ssthg_getenv(const char* name);

extern "C" {

unsigned int hgcc_sleep(unsigned int secs)
{
return SST::Hg::ssthg_sleep(secs);
}

int hgcc_usleep(unsigned int usecs)
{
SST::Hg::ssthg_usleep(usecs);
return 0;
}

char* hgcc_getenv(const char* name)
{
return ssthg_getenv(name);
}

int SSTMAC_gettimeofday(struct timeval* tv, struct timezone* tz)
{
if (!tv) return 0;
SST::Hg::Thread* t = SST::Hg::Thread::current();
if (!t) return -1;
SST::Hg::Timestamp now = t->now();
uint64_t usec = now.usecRounded();
tv->tv_sec = static_cast<time_t>(usec / 1000000ULL);
tv->tv_usec = static_cast<suseconds_t>(usec % 1000000ULL);
if (tz) {
tz->tz_minuteswest = 0;
tz->tz_dsttime = 0;
}
return 0;
}

int HGCC_clock_gettime(clockid_t /*id*/, struct timespec* ts)
{
if (!ts) return 0;
SST::Hg::Thread* t = SST::Hg::Thread::current();
if (!t) return -1;
SST::Hg::Timestamp now = t->now();
uint64_t nsec = now.nsecRounded();
ts->tv_sec = static_cast<time_t>(nsec / 1000000000ULL);
ts->tv_nsec = static_cast<long>(nsec % 1000000000ULL);
return 0;
}

int hgcc_ts_nanosleep(const struct timespec* req, struct timespec* rem)
{
if (!req) return -1;
uint64_t total_nsec = static_cast<uint64_t>(req->tv_sec) * 1000000000ULL
+ static_cast<uint64_t>(req->tv_nsec);
const unsigned int max_nsec = static_cast<unsigned int>(-1);
unsigned int nsecs = (total_nsec > max_nsec) ? max_nsec : static_cast<unsigned int>(total_nsec);
SST::Hg::ssthg_nanosleep(nsecs);
if (rem) {
rem->tv_sec = 0;
rem->tv_nsec = 0;
}
return 0;
}

} // extern "C"
28 changes: 25 additions & 3 deletions src/sst/elements/mercury/common/skeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@

#if SST_HG_EXTERNAL
#define SST_APP_NAME_QUOTED __FILE__ __DATE__
#ifdef __cplusplus
#define SST_DEFINE_EXE_NAME extern "C" const char exe_main_name[] = SST_APP_NAME_QUOTED;
#else
#define SST_DEFINE_EXE_NAME extern const char exe_main_name[] = SST_APP_NAME_QUOTED;
#endif
#else
#define SST_APP_NAME_QUOTED SSTPP_STR(ssthg_app_name)
#define SST_DEFINE_EXE_NAME
#endif
Expand All @@ -33,6 +37,9 @@
typedef int (*main_fxn)(int,char**);
typedef int (*empty_main_fxn)();

#ifndef __cplusplus
#include <stdbool.h>
#else
/* hate that I have to do this for cmake */
#if __cplusplus < 201103L
#define char16_t char16type
Expand All @@ -49,10 +56,14 @@ namespace SST {
class Params;
}
#endif
#endif /* __cplusplus */

#define define_var_name_pass_through(x) ssthg_dont_ignore_this##x
#define define_var_name(x) define_var_name_pass_through(x)

#ifdef __cplusplus
/* Main refactoring uses a static initializer with a function call, which is not
* valid in C (compile-time constant required). Only apply for C++. */
#ifndef SSTHG_NO_REFACTOR_MAIN
#undef main
#define main USER_MAIN
Expand All @@ -68,24 +79,35 @@ class Params;
#else
#define main ssthg_ignore_for_app_name(); int main
#endif
#endif /* __cplusplus */

#ifdef __cplusplus
extern "C" {
#endif
extern int ssthg_global_stacksize;
extern char* static_init_glbls_segment;
extern char* static_init_tls_segment;
void sst_hg_init_global_space(void* ptr, int size, int offset, bool tls);
void sst_hg_advance_time(const char* param_name);
void sst_hg_blocking_call(int condition, double timeout, const char* api);
/* Alias for hgcc-generated pragma: ssthg_blocking_call -> sst_hg_blocking_call */
#define ssthg_blocking_call sst_hg_blocking_call
#ifdef __cplusplus
}
#endif

namespace SST::Hg {
#ifdef __cplusplus
namespace SST {
namespace Hg {

unsigned int ssthg_sleep(unsigned int secs);
unsigned int ssthg_usleep(unsigned int usecs);
unsigned int ssthg_nanosleep(unsigned int nsecs);

} //end namespace SST::Hg
} // namespace Hg
} // namespace SST

#include <mercury/common/skeleton_tls.h>
#include <mercury/common/null_buffer.h>
#endif /* __cplusplus */

#include <mercury/common/null_buffer.h>
4 changes: 4 additions & 0 deletions src/sst/elements/mercury/common/skeleton_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@
#endif


#ifdef __cplusplus
extern "C" {
#endif
extern char* static_init_glbls_segment;
extern char* static_init_tls_segment;
void allocate_static_init_glbls_segment();
void allocate_static_init_tls_segment();
#ifdef __cplusplus
}
#endif

SST_HG_MAYBE_UNUSED
static SST_HG_INLINE char* get_sst_hg_global_data(){
Expand Down
20 changes: 6 additions & 14 deletions src/sst/elements/mercury/components/operating_system_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,13 @@ OperatingSystemImpl::startThread(Thread* t)
void
OperatingSystemImpl::joinThread(Thread* t)
{
sst_hg_abort_printf("OperatingSystem::joinThread not fully implemented");
if (t->getState() != Thread::DONE) {
// key* k = key::construct();
// os_debug("joining thread %ld - thread not done so blocking on
// thread %p",
// t->threadId(), active_thread_);
t->joiners_.push(active_thread_);
// int ncores = active_thread_->numActiveCcores();
// //when joining - release all cores
// compute_sched_->releaseCores(ncores, active_thread_);
// block();
// compute_sched_->reserveCores(ncores, active_thread_);
} else {
// os_debug("joining completed thread %ld", t->threadId());
if (t->getState() == Thread::DONE) {
running_threads_.erase(t->tid());
delete t;
return;
}
t->joiners_.push(active_thread_);
block();
running_threads_.erase(t->tid());
delete t;
}
Expand Down
Loading
Loading