Realm
A distributed, event-based tasking library
Loading...
Searching...
No Matches
gasnetex_wrapper_internal.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 Stanford University, NVIDIA Corporation
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef GASNETEX_WRAPPER_INTERNAL_H
19#define GASNETEX_WRAPPER_INTERNAL_H
20
21#ifndef GASNET_PAR
22#if defined(GASNET_SEQ) || defined(GASNET_PARSYNC)
23#error Realm requires GASNet-EX be used in parallel threading mode!
24#else
25#define GASNET_PAR
26#endif
27#endif
28#include <gasnetex.h>
29
30// there are two independent "version" that we may need to consider for
31// conditional compilation:
32//
33// 1) REALM_GEX_RELEASE refers to specific releases - GASNet-EX uses year.month
34// for major.minor, and we'll assume no more than 100 patch levels to
35// avoid conflicts, but there is no guarantee of chronological
36// monotonicity of behavior, so tests should be either equality against
37// a specific release or a bounded comparison when two or more consecutive
38// releases are of interest. However, there should never be anything of
39// form: if REALM_GEX_RELEASE >= xyz
40#define REALM_GEX_RELEASE \
41 ((10000 * GASNET_RELEASE_VERSION_MAJOR) + (100 * GASNET_RELEASE_VERSION_MINOR) + \
42 GASNET_RELEASE_VERSION_PATCH)
43
44// 2) REALM_GEX_API refers to versioning of the GASNet-EX specification -
45// currently this is defined in terms of major.minor, but we'll include
46// space for a patch level if that ever becomes important. In contrast to
47// the release numbering, we will assume that the specification is
48// roughly monotonic in that a change is expected to remain in future
49// specs except for hopefully-uncommon cases where it changes again
50#define REALM_GEX_API ((10000 * GEX_SPEC_VERSION_MAJOR) + (100 * GEX_SPEC_VERSION_MINOR))
51
52#if REALM_GEX_API < 1200
53#error Realm depends on GASNet-EX features that first appeared in the 0.12 spec, first available in the 2020.11.0 release. For earlier versions of GASNet-EX, use the legacy API via the gasnet1 network layer.
54#include <stop_compilation_due_to_gasnetex_version_mismatch>
55#endif
56
57// post 2020.11.0, GASNet has defines that say which operations are native
58// rather than emulated by their reference implementation - those defines
59// aren't there for 2020.11.0, but the only one that version has that we
60// care about is NPAM medium
61#if REALM_GEX_RELEASE == 20201100
62// NOTE: technically it's only native for the IBV/ARIES/SMP conduits,
63// but enable it as well on the MPI conduit so that we get more test
64// coverage of the code paths (and it's probably not making the MPI
65// conduit performance any worse)
66#if defined(GASNET_CONDUIT_IBV) || defined(GASNET_CONDUIT_ARIES) || \
67 defined(GASNET_CONDUIT_SMP) || defined(GASNET_CONDUIT_MPI)
68#define GASNET_NATIVE_NP_ALLOC_REQ_MEDIUM
69#endif
70#endif
71
72// the GASNet-EX API defines the GEX_FLAG_IMMEDIATE flag to be a best-effort
73// thing, with calls that accept the flag still being allowed to block -
74// as of 2022.3.0, for any conduit other than aries "best effort" is actually
75// "no effort" for RMA operations and we want to avoid using them in
76// immediate-mode situations
77// NOTE: as with the NPAM stuff above, we'll pretend that MPI honors it as
78// well so that we get code coverage in CI tests
79#if defined(GASNET_CONDUIT_ARIES) || defined(GASNET_CONDUIT_MPI)
80#define REALM_GEX_RMA_HONORS_IMMEDIATE_FLAG
81#endif
82
83// eliminate GASNet warnings for unused static functions
84// REALM_ATTR_UNUSED(thing) - indicate that `thing` is unused
85#define REALM_ATTR_UNUSED(thing) thing __attribute__((unused))
86
87#include <gasnet_tools.h>
88REALM_ATTR_UNUSED(static const void *ignore_gasnet_warning1) = (void *)
89 _gasneti_threadkey_init;
90REALM_ATTR_UNUSED(static const void *ignore_gasnet_warning2) = (void *)
91 _gasnett_trace_printf_noop;
92
93#define CHECK_GEX(cmd) \
94 do { \
95 int ret = (cmd); \
96 if(ret != GASNET_OK) { \
97 fprintf(stderr, "GEX: %s = %d (%s, %s)\n", #cmd, ret, gasnet_ErrorName(ret), \
98 gasnet_ErrorDesc(ret)); \
99 exit(1); \
100 } \
101 } while(0)
102
104
105namespace Realm {
106 namespace GASNetEXHandlers {
107
108 extern gex_AM_Entry_t handler_table[];
109 extern size_t handler_table_size;
110
112 }; // namespace GASNetEXHandlers
113}; // namespace Realm
114
115#endif
bootstrap_handle_t * handle
Definition bootstrap.h:61
#define REALM_ATTR_UNUSED(thing)
Definition gasnetex_wrapper_internal.h:85
gex_AM_Entry_t handler_table[]
void init_gex_handler_fnptr(struct gex_wrapper_handle_s *handle)
Definition activemsg.h:38
Handle structure that contains the full API for the wrapper.
Definition gasnetex_wrapper.h:77