-
Notifications
You must be signed in to change notification settings - Fork 873
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
pml_ucx: add ompi datatype attribute to release ucp_datatype #5878
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
#include "pml_ucx_datatype.h" | ||
|
||
#include "ompi/runtime/mpiruntime.h" | ||
#include "ompi/attribute/attribute.h" | ||
|
||
#include <inttypes.h> | ||
|
||
|
@@ -127,12 +128,25 @@ static ucp_generic_dt_ops_t pml_ucx_generic_datatype_ops = { | |
.finish = pml_ucx_generic_datatype_finish | ||
}; | ||
|
||
int mca_pml_ucx_datatype_attr_del_fn(ompi_datatype_t* datatype, int keyval, | ||
void *attr_val, void *extra) | ||
{ | ||
ucp_datatype_t ucp_datatype = (ucp_datatype_t)attr_val; | ||
|
||
PML_UCX_ASSERT((void*)ucp_datatype == datatype->pml_data); | ||
|
||
ucp_dt_destroy(ucp_datatype); | ||
datatype->pml_data = PML_UCX_DATATYPE_INVALID; | ||
return OMPI_SUCCESS; | ||
} | ||
|
||
ucp_datatype_t mca_pml_ucx_init_datatype(ompi_datatype_t *datatype) | ||
{ | ||
ucp_datatype_t ucp_datatype; | ||
ucs_status_t status; | ||
ptrdiff_t lb; | ||
size_t size; | ||
int ret; | ||
|
||
ompi_datatype_type_lb(datatype, &lb); | ||
|
||
|
@@ -147,16 +161,33 @@ ucp_datatype_t mca_pml_ucx_init_datatype(ompi_datatype_t *datatype) | |
} | ||
|
||
status = ucp_dt_create_generic(&pml_ucx_generic_datatype_ops, | ||
datatype, &ucp_datatype); | ||
datatype, &ucp_datatype); | ||
if (status != UCS_OK) { | ||
PML_UCX_ERROR("Failed to create UCX datatype for %s", datatype->name); | ||
ompi_mpi_abort(&ompi_mpi_comm_world.comm, 1); | ||
} | ||
|
||
datatype->pml_data = ucp_datatype; | ||
|
||
/* Add custom attribute, to clean up UCX resources when OMPI datatype is | ||
* released. | ||
*/ | ||
if (ompi_datatype_is_predefined(datatype)) { | ||
PML_UCX_ASSERT(datatype->id < OMPI_DATATYPE_MAX_PREDEFINED); | ||
ompi_pml_ucx.predefined_types[datatype->id] = ucp_datatype; | ||
} else { | ||
ret = ompi_attr_set_c(TYPE_ATTR, datatype, &datatype->d_keyhash, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do u need to set the ucp_datatype on the datatype->d_keyhash ? You have it stored in the pml_data anyways, right? The delete callback will be launched and you can get the ucp_type from pml_data. No, need to grow the hash, if i understand correctly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would the delete callback be called for an mpi datatype if i don't set my attribute? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, i see |
||
ompi_pml_ucx.datatype_attr_keyval, | ||
(void*)ucp_datatype, false); | ||
if (ret != OMPI_SUCCESS) { | ||
PML_UCX_ERROR("Failed to add UCX datatype attribute for %s: %d", | ||
datatype->name, ret); | ||
ompi_mpi_abort(&ompi_mpi_comm_world.comm, 1); | ||
} | ||
} | ||
|
||
PML_UCX_VERBOSE(7, "created generic UCX datatype 0x%"PRIx64, ucp_datatype) | ||
// TODO put this on a list to be destroyed later | ||
|
||
datatype->pml_data = ucp_datatype; | ||
return ucp_datatype; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return rc