Skip to content

Instantly share code, notes, and snippets.

@davidozog
Last active April 30, 2021 20:45
Show Gist options
  • Save davidozog/9be1e52dd425567f86ccb1b050446baf to your computer and use it in GitHub Desktop.
Save davidozog/9be1e52dd425567f86ccb1b050446baf to your computer and use it in GitHub Desktop.
OpenSHMEM Bundles
/**********************************************************
Bundle API summary:
int shmem_bundle_start(IN shmem_bundle_config_t config,
IN long config_mask,
OUT shmem_bundle_t *bundle);
void shmem_bundle_stop(IN shmem_bundle_t bundle);
typedef struct shmem_bundle {
shmem_ctx_t ctx;
} shmem_bundle_config_t;
***********************************************************/
shmem_ctx_t my_ctx;
shmem_bundle_t my_bundle;
shmem_bundle_config_t my_bundle_config;
/* Starting a bundle is a hint...
all RMA/AMO semantics are preserved */
int ret = shmem_bundle_start(my_bundle_config, 0, &my_bundle);
if (ret < 0) {
/* User knows not to expect an optimization */
}
/* Any sequence of RMA/AMO operations on my_ctx could be bundled: */
for (int i = 0; i < num_ops; i++) {
/* blocking RMA would *not* be bundled by the implementation */
shmem_put(my_ctx, ...);
shmem_atomic_add(my_ctx, ...);
/* non-blocking routines could be chained
(and maybe aggregated/coalesced?) */
shmem_put_nbi(my_ctx, ...);
shmem_atomic_fetch_add_nbi(my_ctx, ...);
}
/* Stoping a bundle would not affect memory ordering,
just informs the runtime a bundle is done */
shmem_bundle_stop(my_bundle);
/* Can nbi source buffers be reused at this point?
Likely not if "stop" has no affect on memory model...
Maybe a shmem_local_complete() could be useful here? */
/* Quiet required on context for remote completion */
shmem_ctx_quiet(my_ctx);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment