IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo function

shmem_finalize

shmem_finalize()

A collective operation that releases all resources used by SHMEM.

shmem_finalize ends the SHMEM portion of a program previously initialized by shmem_init or shmem_init_thread. This is a collective operation that requires all PEs to participate in the call.

A SHMEM program may perform a series of matching initialization and finalization calls. The last call to shmem_finalize in this series releases all resources used by the SHMEM library. This call destroys all teams created by the SHMEM program. As a result, all shareable contexts are destroyed.

The last call to shmem_finalize performs an implicit global barrier to ensure that pending communications are completed and that no resources are released until all PEs have entered shmem_finalize. All other calls to shmem_finalize perform an operation semantically equivalent to shmem_barrier_all and return without freeing any SHMEM resources.

The last call to shmem_finalize causes the SHMEM library to enter an uninitialized state. No further SHMEM calls may be made until an SHMEM initialization routine is called.

All processes that represent the PEs will still exist after the call to shmem_finalize returns, but they will no longer have access to SHMEM library resources that have been released.