Skip to content
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

ompi/info: introduce support for the mpi_memory_alloc_kinds info object #13054

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 10 additions & 2 deletions ompi/communicator/comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
* Copyright (c) 2018-2024 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -56,6 +56,7 @@
#include "ompi/communicator/communicator.h"
#include "ompi/mca/pml/pml.h"
#include "ompi/request/request.h"
#include "ompi/info/info_memkind.h"

#include "ompi/runtime/params.h"

Expand Down Expand Up @@ -444,6 +445,7 @@ int ompi_comm_create_w_info (ompi_communicator_t *comm, ompi_group_t *group, opa

/* Copy info if there is one. */
newcomp->super.s_info = OBJ_NEW(opal_info_t);
ompi_info_memkind_copy_or_set (&comm->super, &newcomp->super, info);
if (info) {
opal_info_dup(info, &(newcomp->super.s_info));
}
Expand Down Expand Up @@ -699,8 +701,9 @@ int ompi_comm_split_with_info( ompi_communicator_t* comm, int color, int key,
ompi_comm_print_cid (newcomp), ompi_comm_print_cid (comm));

/* Copy info if there is one */
newcomp->super.s_info = OBJ_NEW(opal_info_t);
ompi_info_memkind_copy_or_set (&comm->super, &newcomp->super, info);
if (info) {
newcomp->super.s_info = OBJ_NEW(opal_info_t);
opal_info_dup(info, &(newcomp->super.s_info));
}

Expand Down Expand Up @@ -991,6 +994,7 @@ static int ompi_comm_split_type_core(ompi_communicator_t *comm,

ompi_comm_assert_subscribe (newcomp, OMPI_COMM_ASSERT_LAZY_BARRIER);
ompi_comm_assert_subscribe (newcomp, OMPI_COMM_ASSERT_ACTIVE_POLL);
ompi_info_memkind_copy_or_set (&comm->super, &newcomp->super, info);
if (info) {
opal_infosubscribe_change_info(&newcomp->super, info);
}
Expand Down Expand Up @@ -1344,6 +1348,7 @@ int ompi_comm_dup_with_info ( ompi_communicator_t * comm, opal_info_t *info, omp
// Copy info if there is one.
ompi_comm_assert_subscribe (newcomp, OMPI_COMM_ASSERT_LAZY_BARRIER);
ompi_comm_assert_subscribe (newcomp, OMPI_COMM_ASSERT_ACTIVE_POLL);
ompi_info_memkind_copy_or_set (&comm->super, &newcomp->super, info);
if (info) {
opal_infosubscribe_change_info(&newcomp->super, info);
}
Expand Down Expand Up @@ -1434,6 +1439,7 @@ static int ompi_comm_idup_internal (ompi_communicator_t *comm, ompi_group_t *gro
{
ompi_communicator_t *newcomp = context->newcomp;
newcomp->super.s_info = OBJ_NEW(opal_info_t);
ompi_info_memkind_copy_or_set (&comm->super, &newcomp->super, info);
if (info) {
opal_info_dup(info, &(newcomp->super.s_info));
}
Expand Down Expand Up @@ -1588,6 +1594,7 @@ int ompi_comm_create_from_group (ompi_group_t *group, const char *tag, opal_info
if (NULL == newcomp->super.s_info) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
ompi_info_memkind_copy_or_set (&group->grp_instance->super, &newcomp->super, info);

/* activate communicator and init coll-module. use the group allreduce implementation as
* no collective module has yet been selected. the tag does not matter as any tag will
Expand Down Expand Up @@ -1885,6 +1892,7 @@ int ompi_intercomm_create_from_groups (ompi_group_t *local_group, int local_lead

// Copy info if there is one.
newcomp->super.s_info = OBJ_NEW(opal_info_t);
ompi_info_memkind_copy_or_set (&local_comm->super, &newcomp->super, info);
if (info) {
opal_info_dup(info, &(newcomp->super.s_info));
}
Expand Down
13 changes: 12 additions & 1 deletion ompi/communicator/comm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
* Copyright (c) 2018-2024 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2023 NVIDIA Corporation. All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -53,6 +53,7 @@
#include "ompi/dpm/dpm.h"
#include "ompi/memchecker.h"
#include "ompi/instance/instance.h"
#include "ompi/info/info_memkind.h"

/*
** Table for Fortran <-> C communicator handle conversion
Expand Down Expand Up @@ -266,6 +267,7 @@ int ompi_comm_init_mpi3 (void)
free(str);
}
}

/* Setup MPI_COMM_SELF */
OBJ_CONSTRUCT(&ompi_mpi_comm_self, ompi_communicator_t);
assert(ompi_mpi_comm_self.comm.c_f_to_c_index == 1);
Expand Down Expand Up @@ -300,6 +302,15 @@ int ompi_comm_init_mpi3 (void)
MPI_COMM_SELF, the keyhash will automatically be created. */
ompi_mpi_comm_self.comm.c_keyhash = NULL;

char *memkind_requested = getenv ("OMPI_MCA_mpi_memory_alloc_kinds");
if (NULL != memkind_requested) {
char *memkind_provided;

ompi_info_memkind_process (memkind_requested, &memkind_provided);
opal_infosubscribe_subscribe (&ompi_mpi_comm_world.comm.super, "mpi_memory_alloc_kinds", memkind_provided, ompi_info_memkind_cb);
opal_infosubscribe_subscribe (&ompi_mpi_comm_self.comm.super, "mpi_memory_alloc_kinds", memkind_provided, ompi_info_memkind_cb);
}

/*
* finally here we set the predefined attribute keyvals
*/
Expand Down
4 changes: 3 additions & 1 deletion ompi/file/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
* Copyright (c) 2024 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand All @@ -34,7 +35,7 @@
#include "ompi/runtime/params.h"
#include "ompi/mca/io/base/base.h"
#include "ompi/info/info.h"

#include "ompi/info/info_memkind.h"

opal_mutex_t ompi_mpi_file_bootstrap_mutex = OPAL_MUTEX_STATIC_INIT;

Expand Down Expand Up @@ -120,6 +121,7 @@ int ompi_file_open(struct ompi_communicator_t *comm, const char *filename,

/* Copy the info for the info layer */
file->super.s_info = OBJ_NEW(opal_info_t);
ompi_info_memkind_copy_or_set (&comm->super, &file->super, info);
if (info) {
opal_info_dup(info, &(file->super.s_info));
}
Expand Down
6 changes: 4 additions & 2 deletions ompi/info/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
# This makefile.am does not stand on its own - it is included from ompi/Makefile.am

headers += \
info/info.h
info/info.h \
info/info_memkind.h

lib@OMPI_LIBMPI_NAME@_la_SOURCES += \
info/info.c
info/info.c \
info/info_memkind.c
4 changes: 4 additions & 0 deletions ompi/info/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include "opal/util/info.h"

#include "ompi/info/info.h"
#include "ompi/info/info_memkind.h"
#include "ompi/runtime/mpiruntime.h"
#include "ompi/runtime/params.h"
#include "ompi/runtime/ompi_rte.h"
Expand Down Expand Up @@ -351,6 +352,9 @@ int ompi_mpiinfo_finalize(void)
}
}

/* Release the array of available memkind objects */
ompi_info_memkind_free_available();

/* All done -- destroy the table */

OBJ_DESTRUCT(&ompi_info_f_to_c_table);
Expand Down
Loading
Loading