Skip to content

Topic/a2a inplace5.0 #9493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Expose opal_datatype_compute_remote_size.
This function can be used to compute the packed size of a datatype on a
target architecture.

Signed-off-by: George Bosilca <bosilca@icl.utk.edu>
(cherry picked from commit 74049fc)
  • Loading branch information
bosilca authored and jsquyres committed Oct 7, 2021
commit 570b5ae6d80c0a2113a674a70add12ef74448c75
29 changes: 3 additions & 26 deletions opal/datatype/opal_convertor.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,29 +455,6 @@ int32_t opal_convertor_set_position_nocheck(opal_convertor_t *convertor, size_t
return rc;
}

static size_t opal_datatype_compute_remote_size(const opal_datatype_t *pData, const size_t *sizes)
{
uint32_t typeMask = pData->bdt_used;
size_t length = 0;

if (opal_datatype_is_predefined(pData)) {
return sizes[pData->desc.desc->elem.common.type];
}

if (OPAL_UNLIKELY(NULL == pData->ptypes)) {
/* Allocate and fill the array of types used in the datatype description */
opal_datatype_compute_ptypes((opal_datatype_t *) pData);
}

for (int i = OPAL_DATATYPE_FIRST_TYPE; typeMask && (i < OPAL_DATATYPE_MAX_PREDEFINED); i++) {
if (typeMask & ((uint32_t) 1 << i)) {
length += (pData->ptypes[i] * sizes[i]);
typeMask ^= ((uint32_t) 1 << i);
}
}
return length;
}

/**
* Compute the remote size. If necessary remove the homogeneous flag
* and redirect the convertor description toward the non-optimized
Expand All @@ -496,9 +473,9 @@ size_t opal_convertor_compute_remote_size(opal_convertor_t *pConvertor)
}
if (0 == (pConvertor->flags & CONVERTOR_HAS_REMOTE_SIZE)) {
/* This is for a single datatype, we must update it with the count */
pConvertor->remote_size = opal_datatype_compute_remote_size(datatype,
pConvertor->master
->remote_sizes);
pConvertor->remote_size =
opal_datatype_compute_remote_size(datatype,
pConvertor->master->remote_sizes);
pConvertor->remote_size *= pConvertor->count;
}
}
Expand Down
9 changes: 9 additions & 0 deletions opal/datatype/opal_datatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@ OPAL_DECLSPEC int32_t opal_datatype_copy_content_same_ddt(const opal_datatype_t

OPAL_DECLSPEC int opal_datatype_compute_ptypes(opal_datatype_t *datatype);

/*
* Compute the size of the datatype using a specific set of predefined type sizes.
* This function allows to compute the size of a packed buffer without creating
* a fully fledged specialized convertor for the remote peer.
*/
OPAL_DECLSPEC size_t
opal_datatype_compute_remote_size(const opal_datatype_t *pData,
const size_t *sizes);

/* Compute the span in memory of count datatypes. This function help with temporary
* memory allocations for receiving already typed data (such as those used for reduce
* operations). This span is the distance between the minimum and the maximum byte
Expand Down
24 changes: 24 additions & 0 deletions opal/datatype/opal_datatype_get_count.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,27 @@ int opal_datatype_compute_ptypes(opal_datatype_t *datatype)
}
}
}

size_t opal_datatype_compute_remote_size(const opal_datatype_t *pData, const size_t *sizes)
{
uint32_t typeMask = pData->bdt_used;
size_t length = 0;

if (opal_datatype_is_predefined(pData)) {
return sizes[pData->desc.desc->elem.common.type];
}

if (OPAL_UNLIKELY(NULL == pData->ptypes)) {
/* Allocate and fill the array of types used in the datatype description */
opal_datatype_compute_ptypes((opal_datatype_t *) pData);
}

for (int i = OPAL_DATATYPE_FIRST_TYPE; typeMask && (i < OPAL_DATATYPE_MAX_PREDEFINED); i++) {
if (typeMask & ((uint32_t) 1 << i)) {
length += (pData->ptypes[i] * sizes[i]);
typeMask ^= ((uint32_t) 1 << i);
}
}
return length;
}