-
Notifications
You must be signed in to change notification settings - Fork 25
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
General: C++ API updates #19
Changes from all commits
a9ce101
c91b91b
1e59e1a
e34a0be
7bc72bb
817f8d8
208ab4d
bf7e62a
8c4306f
747f93e
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 |
---|---|---|
|
@@ -35,95 +35,137 @@ class nixlAgent { | |
nixlAgent (const std::string &name, const nixlAgentConfig &cfg); | ||
~nixlAgent (); | ||
|
||
// Prints the supported configs with their default or initialized values | ||
nixl_b_params_t getBackendOptions (const nixl_backend_t &type); | ||
// Returns the available plugins found in the paths. | ||
nixl_status_t getAvailPlugins (std::vector<nixl_backend_t> &plugins); | ||
|
||
// Instantiate BackendEngine objects, based on corresponding params | ||
nixlBackendH* createBackend (const nixl_backend_t &type, | ||
const nixl_b_params_t ¶ms); | ||
// Returns the supported configs with their default values | ||
nixl_status_t getPluginOptions ( | ||
const nixl_backend_t &type, | ||
nixl_b_params_t ¶ms) const; | ||
|
||
// Register with the backend and populate memory_section | ||
nixl_status_t registerMem (const nixl_reg_dlist_t &descs, | ||
nixlBackendH* backend); | ||
// Deregister and remove from memory section | ||
nixl_status_t deregisterMem (const nixl_reg_dlist_t &descs, | ||
nixlBackendH* backend); | ||
// Instantiate BackendEngine objects, based on corresponding params | ||
nixl_status_t createBackend ( | ||
const nixl_backend_t &type, | ||
const nixl_b_params_t ¶ms, | ||
nixlBackendH* &backend); | ||
|
||
// Returns the backend parameters after instantiation | ||
nixl_status_t getBackendOptions ( | ||
const nixlBackendH* &backend, | ||
nixl_b_params_t ¶ms) const; | ||
|
||
// Register a memory with NIXL. User can provide a list of backends | ||
// to specify which backends are targeted for a memory, otherwise | ||
// NIXL will register with all backends that support the memory type. | ||
nixl_status_t registerMem ( | ||
const nixl_reg_dlist_t &descs, | ||
const nixl_xfer_params_t* extra_params = nullptr) const; | ||
|
||
// Deregister the memory from NIXL | ||
nixl_status_t deregisterMem ( | ||
const nixl_reg_dlist_t &descs, | ||
nixlBackendH* backend); | ||
|
||
// Make connection proactively, instead of at transfer time | ||
nixl_status_t makeConnection (const std::string &remote_agent); | ||
|
||
|
||
/*** Transfer Request Handling ***/ | ||
|
||
// Creates a transfer request, with automatic backend selection if null. | ||
nixl_status_t createXferReq (const nixl_xfer_dlist_t &local_descs, | ||
const nixl_xfer_dlist_t &remote_descs, | ||
const std::string &remote_agent, | ||
const std::string ¬if_msg, | ||
const nixl_xfer_op_t &operation, | ||
nixlXferReqH* &req_handle, | ||
const nixlBackendH* backend = nullptr) const; | ||
|
||
// Submit a transfer request, which populates the req async handler. | ||
nixl_xfer_state_t postXferReq (nixlXferReqH* req); | ||
/*** Transfer Request Prepration ***/ | ||
|
||
// Method 1, for when memory addresses of the transfer is not known | ||
// beforehand, and the transfer request is prepared with information | ||
// from both sides. The backend is selected automatically by NIXL, | ||
// while user can provide a list of backends as hints in extra_params. | ||
// The notification message can be given in optional extra_params too. | ||
nixl_status_t prepXferFull ( | ||
const nixl_xfer_op_t &operation, | ||
const nixl_xfer_dlist_t &local_descs, | ||
const nixl_xfer_dlist_t &remote_descs, | ||
const std::string &remote_agent, | ||
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. so the agent stays string? We had discussions it turns blob as well. 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. Kapil made this comment in the meeting that for logging, string makes more sense, and that's what users want. And if they pass something that has \0, anyways we process it properly. That's more intuitive too. |
||
nixlXferReqH* &req_handle, | ||
const nixl_xfer_params_t* extra_params = nullptr) const; | ||
|
||
// Method 2, for when memory blocks used in transfers are pre-known, but | ||
// selection of blocks for transfers are determined in run time. | ||
// There are two steps, initial preparations for each side, followed by a | ||
// selection by indices to prepare a full transfer request. | ||
|
||
// Prepares descriptors for one side of a transfer request. For local | ||
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. I'd suggest to add some text formatting here to improve readability. I.e.:
Also, I don't follow the description here. What is local target or initiator side? 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. Agreed about formatting, will do. |
||
// initiator side, remote_agent should be passed as NIXL_INIT_AGENT. | ||
// For local target side in local transfers agent's own name is passed as | ||
// remote_agent. User can provide a list of backends as hints in | ||
// extra_params to limit preparations to those backends. | ||
nixl_status_t prepXferSide ( | ||
const nixl_xfer_dlist_t &descs, | ||
const std::string &remote_agent, | ||
nixlXferSideH* &side_handle, | ||
const nixl_xfer_params_t* extra_params = nullptr) const; | ||
|
||
// Makes a full transfer request by selecting indices from already prepared sides. | ||
// NIXL automatically determines the backend that can perform the transfer. | ||
// The notification message can be given in optional extra_params. | ||
nixl_status_t selectXferSides ( | ||
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. I don't like select word - there are 2 sides passed into this function and they are already "selected" 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. Not sure about this myself either. Previously it was makeXferReq, very similar to buildXferReq. But the point being these are preprations, the post actually makes it. So not sure what else to call it. 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. Select sounded like there are some preps, we're selecting from them, it's still prep. But agreed there should be a better word. |
||
const nixl_xfer_op_t &operation, | ||
const nixlXferSideH* local_side, | ||
const std::vector<int> &local_indices, | ||
const nixlXferSideH* remote_side, | ||
const std::vector<int> &remote_indices, | ||
nixlXferReqH* &req_handle, | ||
const nixl_xfer_params_t* extra_params = nullptr) const; | ||
|
||
|
||
/*** Operations on prepared Transfer Request ***/ | ||
|
||
// Submit a transfer request, which enables async checks on the transfer. | ||
// Operation and notification message can be updated per post through | ||
// the extra_params. | ||
nixl_status_t postXferReq ( | ||
nixlXferReqH* req, | ||
const nixl_xfer_params_t* extra_params = nullptr) const; | ||
|
||
// Check the status of transfer requests | ||
nixl_xfer_state_t getXferStatus (nixlXferReqH* req); | ||
nixl_status_t getXferStatus (nixlXferReqH* req); | ||
|
||
// Invalidate transfer request if we no longer need it. | ||
// Will also abort a running transfer. | ||
void invalidateXferReq (nixlXferReqH* req); | ||
// User can ask for backend used in a nixlXferReqH. For example to use the | ||
// same backend for genNotif, or to know the decision after a prepXferFull. | ||
nixl_status_t getXferBackend ( | ||
const nixlXferReqH* req_handle, | ||
nixlBackendH* &backend) const; | ||
|
||
// Invalidate (free) transfer request if we no longer need it. | ||
// Tries to abort a running transfer, or return error if couldn't | ||
nixl_status_t invalidateXferReq (nixlXferReqH* req); | ||
|
||
/*** Alternative method to create transfer handle manually ***/ | ||
// Frees a side handle object | ||
nixl_status_t invalidateXferSide (nixlXferSideH* side_handle) const; | ||
|
||
// User can ask for backend chosen for a XferReq to use it for prepXferSide. | ||
nixlBackendH* getXferBackend(const nixlXferReqH* req_handle) const; | ||
|
||
// Prepares descriptors for one side of a transfer with given backend. | ||
// Empty string for remote_agent means it's local side. | ||
nixl_status_t prepXferSide (const nixl_xfer_dlist_t &descs, | ||
const std::string &remote_agent, | ||
const nixlBackendH* backend, | ||
nixlXferSideH* &side_handle) const; | ||
|
||
// Makes a transfer request from already prepared side transfer handles. | ||
nixl_status_t makeXferReq (const nixlXferSideH* local_side, | ||
const std::vector<int> &local_indices, | ||
const nixlXferSideH* remote_side, | ||
const std::vector<int> &remote_indices, | ||
const std::string ¬if_msg, | ||
const nixl_xfer_op_t &operation, | ||
nixlXferReqH* &req_handle) const; | ||
|
||
void invalidateXferSide (nixlXferSideH* side_handle) const; | ||
|
||
/*** Notification Handling ***/ | ||
|
||
// Add entries to the passed received notifications list (can be | ||
// non-empty), and return number of added entries, or -1 if there was | ||
// an error. Elements are released within the Agent after this call. | ||
int getNotifs (nixl_notifs_t ¬if_map); | ||
// Populates an empty notification map, and releases them within the agent. | ||
nixl_status_t getNotifs (nixl_notifs_t ¬if_map); | ||
|
||
// Generate a notification, not bound to a transfer, e.g., for control. | ||
// Can be used after the remote metadata is exchanged. Will be received | ||
// in notif list. Nixl will choose a backend if null is passed. | ||
nixl_status_t genNotif (const std::string &remote_agent, | ||
const std::string &msg, | ||
nixlBackendH* backend = nullptr); | ||
|
||
// in notif list. Providing a backend in extra_params is optional, as | ||
// nixl can automatically decide. | ||
nixl_status_t genNotif ( | ||
const std::string &remote_agent, | ||
const nixl_blob_t &msg, | ||
const nixl_xfer_params_t* extra_params = nullptr); | ||
|
||
/*** Metadata handling through side channel ***/ | ||
|
||
// Get nixl_metadata for this agent. Empty string means error. | ||
// The std::string used for serialized MD can have \0 values. | ||
std::string getLocalMD () const; | ||
// Get nixl metadata blob for this agent. | ||
nixl_status_t getLocalMD (nixl_blob_t &str) const; | ||
|
||
// Load other agent's metadata and unpack it internally. | ||
// Returns the found agent name in metadata, or "" in case of error. | ||
std::string loadRemoteMD (const std::string &remote_metadata); | ||
// Received agent name can be checked through agent_name. | ||
nixl_status_t loadRemoteMD ( | ||
const nixl_blobl_t &remote_metadata, | ||
std::string &agent_name); | ||
|
||
// Invalidate the remote section information cached locally | ||
// Invalidate the remote agent metadata cached locally, and disconnect from it. | ||
nixl_status_t invalidateRemoteMD (const std::string &remote_agent); | ||
}; | ||
|
||
|
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.
Why phrasing it this way?
Maybe its the opposite - all the addresses are known a prior, and you create this handle at app initialization and use it throughout. it's actually the best scenario that may happen!
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.
I see, it's both, should update the comment, known priori or the time of transfer. But that kind of sounds all the time. I'll think about it how to make it say there are no blocks.