/* $Source: runtime/gasnet/shmem-conduit/gasnet_core.h $ * $Date: Tue, 09 Aug 2005 22:38:09 -0700 $ * $Revision: 1.7 $ * Description: GASNet header for shmem conduit core * Copyright 2002, Dan Bonachea * Terms of use are as specified in license.txt */ #ifndef _IN_GASNET_H #error This file is not meant to be included directly- clients should include gasnet.h #endif #ifndef _GASNET_CORE_H #define _GASNET_CORE_H #include BEGIN_EXTERNC /* ------------------------------------------------------------------------------------ */ /* Initialization ============== */ /* gasnet_init not inlined or renamed because we use redef-name trick on it to ensure proper version linkage */ extern int gasnet_init(int *argc, char ***argv); extern int gasnetc_attach(gasnet_handlerentry_t *table, int numentries, uintptr_t segsize, uintptr_t minheapoffset); #define gasnet_attach gasnetc_attach extern void gasnetc_exit(int exitcode) GASNETI_NORETURN; #define gasnet_exit gasnetc_exit /* ------------------------------------------------------------------------------------ */ /* No-interrupt sections ===================== */ /* conduit may or may not need this based on whether interrupts are used for running handlers */ #if GASNETC_USE_INTERRUPTS extern void gasnetc_hold_interrupts(); extern void gasnetc_resume_interrupts(); #define gasnet_hold_interrupts gasnetc_hold_interrupts #define gasnet_resume_interrupts gasnetc_resume_interrupts #else #define gasnet_hold_interrupts() #define gasnet_resume_interrupts() #endif /* ------------------------------------------------------------------------------------ */ /* Handler-safe locks ================== */ typedef struct _gasnet_hsl_t { gasneti_mutex_t lock; #if GASNETI_STATS_OR_TRACE gasneti_stattime_t acquiretime; #endif #if GASNETC_USE_INTERRUPTS /* more state may be required for conduits using interrupts */ #error interrupts not implemented #endif } gasnet_hsl_t; #if GASNETI_STATS_OR_TRACE #define GASNETC_LOCK_STAT_INIT ,0 #else #define GASNETC_LOCK_STAT_INIT #endif #if GASNETC_USE_INTERRUPTS #error interrupts not implemented #define GASNETC_LOCK_INTERRUPT_INIT #else #define GASNETC_LOCK_INTERRUPT_INIT #endif #define GASNET_HSL_INITIALIZER { \ GASNETI_MUTEX_INITIALIZER \ GASNETC_LOCK_STAT_INIT \ GASNETC_LOCK_INTERRUPT_INIT \ } /* decide whether we have "real" HSL's */ #if GASNETI_THREADS || GASNETC_USE_INTERRUPTS || /* need for safety */ \ GASNET_DEBUG || GASNETI_STATS_OR_TRACE /* or debug/tracing */ #ifdef GASNETC_NULL_HSL #error bad defn of GASNETC_NULL_HSL #endif #else #define GASNETC_NULL_HSL 1 #endif #if GASNETC_NULL_HSL /* HSL's unnecessary - compile away to nothing */ #define gasnet_hsl_init(hsl) #define gasnet_hsl_destroy(hsl) #define gasnet_hsl_lock(hsl) #define gasnet_hsl_unlock(hsl) #define gasnet_hsl_trylock(hsl) GASNET_OK #else extern void gasnetc_hsl_init (gasnet_hsl_t *hsl); extern void gasnetc_hsl_destroy(gasnet_hsl_t *hsl); extern void gasnetc_hsl_lock (gasnet_hsl_t *hsl); extern void gasnetc_hsl_unlock (gasnet_hsl_t *hsl); extern int gasnetc_hsl_trylock(gasnet_hsl_t *hsl); #define gasnet_hsl_init gasnetc_hsl_init #define gasnet_hsl_destroy gasnetc_hsl_destroy #define gasnet_hsl_lock gasnetc_hsl_lock #define gasnet_hsl_unlock gasnetc_hsl_unlock #define gasnet_hsl_trylock gasnetc_hsl_trylock #endif /* ------------------------------------------------------------------------------------ */ /* Active Message Size Limits ========================== */ #define GASNETC_SHORT_HEADERSZ 4 #define GASNETC_MED_HEADERSZ 8 #define GASNETC_LONG_HEADERSZ (8+8) #define GASNETC_MAX_ARGS 16 #define GASNETC_MAX_MEDIUM 512 #define GASNETC_MAX_MEDIUM_TOTAL (GASNETC_MAX_MEDIUM + GASNETC_MED_HEADERSZ \ + 4*(GASNETC_MAX_ARGS)) #define GASNETC_MAX_LONG ((size_t)0x7fffffff) /* unlimited */ #define gasnet_AMMaxArgs() ((size_t)GASNETC_MAX_ARGS) #define gasnet_AMMaxMedium() ((size_t)GASNETC_MAX_MEDIUM) #define gasnet_AMMaxLongRequest() ((size_t)GASNETC_MAX_LONG) #define gasnet_AMMaxLongReply() ((size_t)GASNETC_MAX_LONG) /* ------------------------------------------------------------------------------------ */ /* Misc. Active Message Functions ============================== */ extern int gasnetc_AMGetMsgSource(gasnet_token_t token, gasnet_node_t *srcindex); #define gasnet_AMGetMsgSource gasnetc_AMGetMsgSource #define GASNET_BLOCKUNTIL(cond) gasneti_polluntil(cond) /* ------------------------------------------------------------------------------------ */ /* Active Message Request/Reply Functions ====================================== */ /* The rest of this header uses macros to coalesce all the possible AM request/reply functions into the following short list of variable-argument functions. This is not the only implementation option, but seems to work rather cleanly. */ extern int gasnetc_AMRequestShortM( gasnet_node_t dest, /* destination node */ gasnet_handler_t handler, /* index into destination endpoint's handler table */ int numargs, ...); extern int gasnetc_AMRequestMediumM( gasnet_node_t dest, /* destination node */ gasnet_handler_t handler, /* index into destination endpoint's handler table */ void *source_addr, size_t nbytes, /* data payload */ int numargs, ...); extern int gasnetc_AMRequestLongM( gasnet_node_t dest, /* destination node */ gasnet_handler_t handler, /* index into destination endpoint's handler table */ void *source_addr, size_t nbytes, /* data payload */ void *dest_addr, /* data destination on destination node */ int numargs, ...); /* No difference between Async and non async */ #define gasnetc_AMRequestLongAsyncM gasnetc_AMRequestLongM extern int gasnetc_AMReplyShortM( gasnet_token_t token, /* token provided on handler entry */ gasnet_handler_t handler, /* index into destination endpoint's handler table */ int numargs, ...); extern int gasnetc_AMReplyMediumM( gasnet_token_t token, /* token provided on handler entry */ gasnet_handler_t handler, /* index into destination endpoint's handler table */ void *source_addr, size_t nbytes, /* data payload */ int numargs, ...); extern int gasnetc_AMReplyLongM( gasnet_token_t token, /* token provided on handler entry */ gasnet_handler_t handler, /* index into destination endpoint's handler table */ void *source_addr, size_t nbytes, /* data payload */ void *dest_addr, /* data destination on destination node */ int numargs, ...); /* ------------------------------------------------------------------------------------ */ END_EXTERNC #endif #include