|
15 | 15 | \end{apiarguments} |
16 | 16 |
|
17 | 17 | \apidescription{ |
18 | | - \FUNC{shmem\_finalize} is a collective operation that ends the \openshmem |
19 | | - portion of a program previously initialized by \FUNC{shmem\_init} or \FUNC{shmem\_init\_thread} and |
20 | | - releases all resources used by the \openshmem library. This collective |
21 | | - operation requires all \acp{PE} to participate in the call. There is an |
22 | | - implicit global barrier in \FUNC{shmem\_finalize} to ensure that pending |
23 | | - communications are completed and that no resources are released until all |
24 | | - \acp{PE} have entered \FUNC{shmem\_finalize}. |
25 | | - This routine destroys all teams created by the \openshmem program. |
| 18 | + \FUNC{shmem\_finalize} ends the \openshmem |
| 19 | + portion of a program previously initialized by \FUNC{shmem\_init} or \FUNC{shmem\_init\_thread}. |
| 20 | + This is a collective |
| 21 | + operation that requires all \acp{PE} to participate in the call. |
| 22 | + |
| 23 | + An \openshmem program may perform a series of matching |
| 24 | + initialization and finalization calls. |
| 25 | + The last call to \FUNC{shmem\_finalize} in this series |
| 26 | + releases all resources used by the \openshmem library. |
| 27 | + This call destroys all teams created by the \openshmem program. |
26 | 28 | As a result, all shareable contexts are destroyed. |
27 | 29 | The user is |
28 | 30 | responsible for destroying all contexts with the |
29 | | - \CONST{SHMEM\_CTX\_PRIVATE} option enabled prior to calling this routine; |
| 31 | + \CONST{SHMEM\_CTX\_PRIVATE} option enabled prior to this call; |
30 | 32 | otherwise, the behavior is undefined. |
31 | | - \FUNC{shmem\_finalize} must be |
32 | | - the last \openshmem library call encountered in the \openshmem portion of a |
33 | | - program. A call to \FUNC{shmem\_finalize} will release all resources |
34 | | - initialized by a corresponding call to \FUNC{shmem\_init} or \FUNC{shmem\_init\_thread}. All processes |
| 33 | + |
| 34 | + The last call to \FUNC{shmem\_finalize} performs an implicit global barrier |
| 35 | + to ensure that pending communications are completed and that no resources |
| 36 | + are released until all \acp{PE} have entered \FUNC{shmem\_finalize}. All |
| 37 | + other calls to \FUNC{shmem\_finalize} perform an operation semantically |
| 38 | + equivalent to \FUNC{shmem\_barrier\_all} and return without freeing any |
| 39 | + \openshmem resources. |
| 40 | + |
| 41 | + The last call to \FUNC{shmem\_finalize} causes the \openshmem library |
| 42 | + to enter an uninitialized state. No further \openshmem calls may be |
| 43 | + made until an \openshmem initialization routine is called. |
| 44 | + All processes |
35 | 45 | that represent the \acp{PE} will still exist after the |
36 | 46 | call to \FUNC{shmem\_finalize} returns, but they will no longer have access |
37 | 47 | to resources that have been released. |
|
42 | 52 | } |
43 | 53 |
|
44 | 54 | \apinotes{ |
45 | | - \FUNC{shmem\_finalize} releases all resources used by the \openshmem library |
| 55 | + The last call to \FUNC{shmem\_finalize} releases all resources used by the \openshmem library |
46 | 56 | including the symmetric memory heap and pointers initiated by |
47 | 57 | \FUNC{shmem\_ptr}. This collective operation requires all \acp{PE} to |
48 | 58 | participate in the call, not just a subset of the \acp{PE}. The |
49 | 59 | non-\openshmem portion of a program may continue after a call to |
50 | 60 | \FUNC{shmem\_finalize} by all \acp{PE}. |
| 61 | + |
| 62 | + Calls to \FUNC{shmem\_finalize} that are not the last in a series of |
| 63 | + initialization and finalization calls do not free any \openshmem resources. |
| 64 | + Thus, teams, contexts, or symmetric memory allocations may be leaked until |
| 65 | + the final call to \FUNC{shmem\_finalize}. Applications that perform |
| 66 | + multiple initialization and finalization calls should free resources prior |
| 67 | + to calling \FUNC{shmem\_finalize} to avoid such leaks. |
51 | 68 | } |
52 | 69 |
|
53 | 70 | \begin{apiexamples} |
|
0 commit comments