Skip to content

Conversation

@tvegas1
Copy link
Contributor

@tvegas1 tvegas1 commented Sep 4, 2023

At very high scale, having each rank storing each other rank's remote keys for each segment can lead to high memory consumption. We activate symmetric remote key option to generate remote keys that will be deduplicated and then used interchangeably.

This adds:

  • symmetric remote key parameter to activativate symmetric registration option (best-effort)
  • deduplication code, avoiding to track local keys from node-local pe's.

@github-actions
Copy link

github-actions bot commented Sep 4, 2023

Hello! The Git Commit Checker CI bot found a few problems with this PR:

051134c: oshmem: Don't deduplicate rkeys of local node

  • check_signed_off: does not contain a valid Signed-off-by line

3a1284a: oshmem: Add actual deduplication calls

  • check_signed_off: does not contain a valid Signed-off-by line

f287afb: oshmem: Add storage structure

  • check_signed_off: does not contain a valid Signed-off-by line

3d3faba: oshmem: Add symmetric key environment variable

  • check_signed_off: does not contain a valid Signed-off-by line

Please fix these problems and, if necessary, force-push new commits back up to the PR branch. Thanks!

@tvegas1
Copy link
Contributor Author

tvegas1 commented Sep 4, 2023

@yosefe, @brminich please check

mem_map_params.flags = flags;

if (spml->symmetric_rkey) {
mem_map_params.flags |= UCP_MEM_MAP_SYMMETRIC_RKEY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add configure check - it's a new flag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added configure and wrapper function to have flag in one place.

ucs_status_t status;

for (i = 0, end = store->count; i < end;) {
m = (i + end) / 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use "bsearch" from glibc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bsearch returns NULL when not found, but here instead we return the position where the item can be inserted (OSHMEM_ERR_NOT_FOUND), so i think is simpler as it is, wdyt?

Comment on lines 1704 to 1706
store->size = size;
store->count = 0;
store->ucp_context = ucp_context;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: can align by =, since the first 2 rows are already aligned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 300 to 299
extern ucp_rkey_h mca_spml_ucx_rkey_store_get(mca_spml_ucx_rkey_store_t *store, const ucp_rkey_h target);
extern void mca_spml_ucx_rkey_store_put(mca_spml_ucx_rkey_store_t *store, const ucp_rkey_h target);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd remove it and make these funcs static, as they are only used in a single file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kept only first two which are needed for init


if (mca_spml_ucx.symmetric_rkey) {
ret = mca_spml_ucx_rkey_store_create(&mca_spml_ucx.rkey_store,
mca_spml_ucx.ucp_context, 1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make the size configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, passing the added parameter symmetric_rkey_size

@jsquyres
Copy link
Member

After review, please squash the "Address review commits" appropriately into the other commits on this PR; thanks.

@tvegas1
Copy link
Contributor Author

tvegas1 commented Sep 19, 2023

After review, please squash the "Address review commits" appropriately into the other commits on this PR; thanks.

Dispatched various changes appropriately in existing commits and force-pushed branch.

mca_spml_ucx_rkey_t *entry;
int ret, i;

if (store->size == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not we check count here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed for clarity as the check is mainly expected to handle when feature is not enabled.

@janjust
Copy link
Contributor

janjust commented Sep 19, 2023

@yosefe @brminich is this ready to be merged? I think you need v4.1.x?

Comment on lines 143 to 145
mca_spml_ucx_rkey_store_t rkey_store;
bool symmetric_rkey;
int symmetric_rkey_size;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to maintain it per mca_spml_ucx_ctx_t (i.e. per worker)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming we only care about first context (in practice only one shmem_ctx_create() call), and we do not want to create symmetric store for aux_ctx or other instances.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, we want to create symmetric store for all contexts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@tvegas1 tvegas1 requested review from brminich and yosefe October 5, 2023 13:52
Comment on lines 506 to 509
mca_spml_ucx_rkey_store_destroy(&ctx->rkey_store);
ucp_worker_destroy(ctx->ucp_worker[0]);
free(ctx->ucp_worker);
free(ctx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add common function for this? also use it for line 531-533,540

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@tvegas1 tvegas1 force-pushed the smkey_store branch 2 times, most recently from c32cd16 to 3b46e7a Compare October 9, 2023 10:50
Copy link
Contributor

@yosefe yosefe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At very high scale, having each rank storing each other rank's remote keys for
each segment can lead to high memory consumption.

We activate symmetric remote key option to generate remote keys that will be
deduplicated and then used interchangeably.

Signed-off-by: Thomas Vegas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants