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

API: add explicit memory mapping #1037

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
80 changes: 80 additions & 0 deletions src/ucc/api/ucc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2220,5 +2220,85 @@ ucc_status_t ucc_ee_wait(ucc_ee_h ee, ucc_ev_t *ev);
*/
ucc_status_t ucc_collective_triggered_post(ucc_ee_h ee, ucc_ev_t *ee_event);

typedef void * ucc_mem_map_mem_h;

/**
* @ingroup UCC_DATATYPE
*/
enum ucc_mem_map_flags {
UCC_MEM_MAP_EXPORT = 0, /*!< Indicate @ref ucc_mem_map() should export
memory handles from TLs used by context */
UCC_MEM_MAP_IMPORT = 1 /*!< Indicate @ref ucc_mem_map() should import
memory handles from user memory handle */
};

/**
* @ingroup UCC_CONTEXT
* @brief Routine registers or maps memory for use in future collectives.
*
* This routine maps memory a user-specified memory segment with a @ref
* ucc_context_t. The segment is considered "mapped" with the context until
* either the user calls @ref ucc_mem_unmap or @ref ucc_context_destroy(). A
* handle to the mapped memory is provided in memh. If the flag
* UCC_MEM_MAP_EXPORT is used, the memory will be mapped and memory
* handles from TLs will be generated and stored in the memh. If the flag
* UCC_MEM_MAP_IMPORT is used, the user must provide a valid memh, otherwise
* behavior is undefined.
*
* @params [in] context Context mapped memory is associated with
* @params [in] flags flags dictating the behavior of the routine
* @params [in] params parameters indicating the address and length of
* memory to map
* @params [inout] *memh Handle for the registered memory
*
* @return Error code as defined by @ref ucc_status_t.
*/

ucc_status_t ucc_mem_map(ucc_context_t context,
ucc_mem_map_flags flags,
ucc_mem_map_params params,
ucc_mem_map_mem_h *memh);

/**
* @ingroup UCC_CONTEXT
* @brief Routine exchanges mapped memory with peers to enable future
* collectives.
*
* This routine performs an nonblocking exchange of mapped memory with peers
* within the same context on which it is mapped. This is a collective routine
* and must be called by all members of the ucc_context on which the memory
* is mapped.
*
* @params [in] *memh Handle of the registered memory
*
* @return Error code as defined by @ref ucc_status_t.
*/
ucc_status_t ucc_mem_exchange_post(ucc_mem_map_mem_h *memh);
Copy link
Contributor

Choose a reason for hiding this comment

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

@wfaderhold21 Is there a need to have an explicit call for exchanging memory handles? Why can't one use allgather or other collectives?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@manjugv Fundamentally, this is an allgather collective. This explicitly has the UCC library perform the operation rather than the User. Is it better to have the User exchange the opaque structure?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the value add, and need for explicit collective call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@manjugv removed the explicit collective.


/**
* @ingroup UCC_CONTEXT
* @brief Routine tests for the completion of a memory exchange on a context.
*
* This routine tests for the completion of a memory exchange on a context.
*
* @params [in] *memh Handle of the registered memory
*
* @return Error code as defined by @ref ucc_status_t.
*/
ucc_status_t ucc_mem_exchange_test(ucc_mem_map_mem_h *memh);

/**
* @ingroup UCC_CONTEXT
* @brief Routine unmaps memory from a context
*
* This routine unmaps memory and all resources associated with the memory
* from a context. The memh object is freed and cannot be reused.
*
* @params [in] *memh Handle of the registered memory
*
* @return Error code as defined by @ref ucc_status_t.
*/
ucc_status_t ucc_mem_unmap(ucc_mem_map_mem_h *memh);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need some collective operation to unmap?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think this can be performed locally. is there a reason to make it collective?

Copy link
Contributor

Choose a reason for hiding this comment

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

for cuda ipc registration do we need to notify remote rank that memory is unmapped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's a good point. i think in order to be safe, we should make this a collective operation


END_C_DECLS
#endif
Loading