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 (II) #13055

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

edgargabriel
Copy link
Member

This PR introduces support for the mpi_memory_alloc_kinds and mpi_assert_memory_alloc_kinds info objects as defined in the MPI 4.1 document and in the side document specifying the values for the three supported accelerator kinds.
The logic is surprisingly twisted and I would not be surprised if some of the code here would have to be revised over time.

There are two ways on how the user can specify the mpi_memory_alloc_kinds info object: either as a runtime argument to mpiexec, namely -memory-alloc-kinds, or as part of the info-object passed to MPI_Session_init. There are two predefined memor-alloc-kinds, namely system and mpi, the latter having three potential restrictors. When user retrieves the info object e.g. using MPI_Comm_get_info on MPI_COMM_WORLD, the MPI library is allowed to return more memory-kinds than requested by the user.

This freedom has been applied in the following manner here:

  • if the user does not request the system and/or mpi memory-alloc-kinds, we add them to the list of provided memkinds, in the case the mpi memory-alloc-kind fully spelled out with all three restrictors.
  • if the user does not request one of the GPU memory kinds (cuda,ze,rocm), we do not add them to the list of supported memkinds, even if the library has been compiled with GPU support and it would be available. The goal is in a second commit to allow to use this mechanism to turn off GPU support in the library if support for GPU memory has not been requested by the user. This commit doesn't do that yet however.
  • All unknown/unsupported memkinds are removed and not returned when retrieving the info object

This default memkind support is applied to all new {Comm/File/Window} objects, unless the user sets mpi_assert_memory_alloc_kinds during object creation (e.g. MPI_Comm_dup_with_info or MPI_File_open). The user can restrict the memory kinds supported by the object with mpi_assert_memory_alloc_kinds, i.e. setting this info object will influence mpi_memory_alloc_kinds on that object. I am not sure whether there is another example in the MPI spec where providing one info object influences the value of another info object, but the MPI 4.1 specification is pretty clear in my understanding that this is what is expected to happen.

Another difference in the handling of mpi_assert_memory_alloc_kinds is that if a provided value is not recognized, the entire mpi_assert_memory_alloc_kinds is dropped/ignored, not just the unrecognized memkind itself. (This is my reading of the specification on what is expected to happen).


Lastly, there could probably be some discussion whether the location chosen for the majority of the code is appropriate (i.e. ompi/info), a directory which so-far has contained the code to manage the MPI_Info object in general. After some discussion I thought this is the most appropriate locations, since

  • this is MPI related know-how, i.e. it cannot go into opal
  • the code is general and has to be used by Communicators, Windows, Files, and Sessions/Instances

@edgargabriel
Copy link
Member Author

edgargabriel commented Jan 27, 2025

As a side note, I do have a bunch of tests that I developed as part of the project, and we might need to find a good spot for where to put them. The tests do require some human interaction and the output is platform dependent, but its a good starting point in my opinion.

For the World model:

egabriel@amdhome:~/memkind-tests$ mpirun --mca coll ^hcoll --memory-alloc-kinds system,x:1,y:1,y:2,rocm:device,x:asd  -np 2 ./memkind_test
Comm: MPI_COMM_SELF rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device
Comm: MPI_COMM_WORLD rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device
Comm: MPI_COMM_SELF rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device
Comm: MPI_Comm_dup rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device
Comm: MPI_Comm_dup after Comm_set_info rank: 0 Value of memory_alloc_kind info object is rocm,system,mpi
Comm: MPI_Comm_dup_with_info & INFO_NULL rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device
Comm: MPI_Comm_dup_with_info & info_assert rank: 0 Value of memory_alloc_kind info object is mpi
Comm: MPI_Comm_dup_with_info & info_assert rank: 0 Value of assert_memory_alloc_kind info object is mpi
Comm: MPI_Comm_dup of comm_dup'ed with info_assert rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device
Comm: MPI_Comm_dup_with_info & info_invalid rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device

Comm: MPI_Comm_create rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device

Comm: MPI_Intercomm_create rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device
Comm: MPI_Intercomm_create rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device
Comm: MPI_Intercomm_merge rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device

File: MPI_File_open with INFO_NULL rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device
File: MPI_File_open with info_assert rank: 0 Value of memory_alloc_kind info object is mpi
File: MPI_File_open with info_invalid rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device

Win: MPI_Win_create rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm:device

and for Sessions:

egabriel@amdhome:~/memkind-tests$ mpirun --mca coll ^hcoll  -np 2 ./memkind_test_sessions
Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm
Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm
Comm: Comm_create_from_group with INFO_NULL rank: 0 Value of memory_alloc_kind info object is system,mpi:alloc_mem,mpi:win_allocate,mpi:win_allocate_shared,rocm
Comm: Comm_create_from_group with info_assert rank: 0 Value of memory_alloc_kind info object is mpi

@hppritcha
Copy link
Member

Why does HCOLL need to be excluded?

@edgargabriel
Copy link
Member Author

Why does HCOLL need to be excluded?

hcoll needs to be excluded if you compile with ROCm support, they don't seem to like each other

return num_unique;
}

#if 0
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 want to leave this debug code in the PR?

add code to handle the memkind info objects defined in MPI 4.1

Signed-off-by: Edgar Gabriel <Edgar.Gabriel@amd.com>
add an API to the accelerator component to retrieve the
memory_alloc_kind information that is supported by the component.
The values stored/returned are based on the side document that is
about to be ratified, see

https://github.com/mpi-forum/mem-alloc/blob/main/mem_alloc.tex

Signed-off-by: Edgar Gabriel <Edgar.Gabriel@amd.com>
@edgargabriel edgargabriel force-pushed the topic/memkind-support branch from 9fe1afe to a63155b Compare February 4, 2025 15:30
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.

2 participants