Skip to content

Commit 30a662c

Browse files
authored
Merge pull request #259 from manjugv/topic/shmem_malloc_hints
Adding shmem_malloc_with_hints interface
2 parents 77bdac1 + fc143db commit 30a662c

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

content/shmem_malloc_hints.tex

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
\apisummary{
3+
Collective memory allocation routine with support for providing hints.
4+
}
5+
6+
\begin{apidefinition}
7+
8+
\begin{Csynopsis}
9+
void *@\FuncDecl{shmem\_malloc\_with\_hints}@(size_t size, long hints);
10+
\end{Csynopsis}
11+
12+
\begin{apiarguments}
13+
\apiargument{IN}{size}{The size, in bytes, of a block to be
14+
allocated from the symmetric heap. This argument is of type \CTYPE{size\_t}}
15+
\apiargument{IN}{hints}{A bit array of hints provided by the user to the implementation}
16+
\end{apiarguments}
17+
18+
19+
\apidescription{
20+
21+
The \FUNC{shmem\_malloc\_with\_hints} routine, like \FUNC{shmem\_malloc}, returns a pointer to a block of at least
22+
\VAR{size} bytes, which shall be suitably aligned so that it may be
23+
assigned to a pointer to any type of object. This space is allocated from
24+
the symmetric heap (similar to \FUNC{shmem\_malloc}). When the \VAR{size} is zero,
25+
the \FUNC{shmem\_malloc\_with\_hints} routine performs no action and returns a null pointer.
26+
27+
In addition to the \VAR{size} argument, the \VAR{hints} argument is provided by the user.
28+
The \VAR{hints} describes the expected manner in which the \openshmem program may use the allocated memory.
29+
The valid usage hints are described in Table~\ref{usagehints}. Multiple hints may be requested by combining them with a bitwise \CONST{OR} operation.
30+
A zero option can be given if no options are requested.
31+
32+
The information provided by the \VAR{hints} is used to optimize for performance by the implementation.
33+
If the implementation cannot optimize, the behavior is same as \FUNC{shmem\_malloc}.
34+
If more than one hint is provided, the implementation will make the best effort to use one or more hints
35+
to optimize performance.
36+
37+
The \FUNC{shmem\_malloc\_with\_hints} routine is provided so that multiple \acp{PE} in a program can allocate symmetric,
38+
remotely accessible memory blocks. When no action is performed, these
39+
routines return without performing a barrier. Otherwise, the routine will call a barrier on exit.
40+
This ensures that all \acp{PE} participate in the memory allocation, and that the memory on other
41+
\acp{PE} can be used as soon as the local \ac{PE} returns. The implicit barrier performed by this routine will quiet the
42+
default context. It is the user's responsibility to ensure that no communication operations involving the given memory block are pending on
43+
other contexts prior to calling the \FUNC{shmem\_free} and \FUNC{shmem\_realloc} routines.
44+
The user is also responsible for calling these routines with identical argument(s) on all
45+
\acp{PE}; if differing \VAR{size}, or \VAR{hints} arguments are used, the behavior of the call
46+
and any subsequent \openshmem calls is undefined.
47+
}
48+
49+
\apireturnvalues{
50+
The \FUNC{shmem\_malloc\_with\_hints} routine returns a pointer to the allocated space;
51+
otherwise, it returns a null pointer.
52+
}
53+
54+
\begin{longtable}{|p{0.45\textwidth}|p{0.5\textwidth}|}
55+
\hline
56+
\textbf{Hints} & \textbf{Usage hint}
57+
\tabularnewline \hline
58+
\endhead
59+
%%
60+
\newline
61+
\CONST{0} &
62+
\newline
63+
Behavior same as \FUNC{shmem\_malloc}
64+
\tabularnewline \hline
65+
66+
67+
\LibConstDecl{SHMEM\_HINT\_ATOMICS\_REMOTE} &
68+
\newline
69+
Memory used for \VAR{atomic} operations
70+
\tabularnewline \hline
71+
72+
\LibConstDecl{SHMEM\_HINT\_SIGNAL} &
73+
\newline
74+
Memory used for \VAR{signal} operations
75+
\tabularnewline \hline
76+
77+
\TableCaptionRef{Memory usage hints}
78+
\label{usagehints}
79+
\end{longtable}
80+
81+
\apinotes{
82+
The \openshmem programs should allocate memory with
83+
\CONST{SHMEM\_HINT\_ATOMICS\_REMOTE}, when the majority of
84+
operations performed on this memory are atomic operations, and origin
85+
and target \ac{PE} of the atomic operations do not share a memory domain
86+
.i.e., symmetric objects on the target \ac{PE} is not accessible using
87+
load/store operations from the origin \ac{PE} or vice versa.
88+
}
89+
\end{apidefinition}
90+
\newpage

main_spec.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ \subsection{Memory Management Routines}
100100
\subsubsection{\textbf{SHMEM\_MALLOC, SHMEM\_FREE, SHMEM\_REALLOC, SHMEM\_ALIGN}}\label{subsec:shfree}
101101
\input{content/shmem_malloc.tex}
102102

103+
\newpage
104+
\subsubsection{\textbf{SHMEM\_MALLOC\_WITH\_HINTS}}\label{subsec:shmmallochint}
105+
\input{content/shmem_malloc_hints.tex}
106+
103107
\subsubsection{\textbf{SHMEM\_CALLOC}}\label{subsec:shmem_calloc}
104108
\input{content/shmem_calloc.tex}
105109

0 commit comments

Comments
 (0)