RegisterMem
Applicability
|
Product |
Supported (√/x) |
|---|---|
|
Atlas 350 Accelerator Card |
x |
|
|
√ |
|
|
√ |
|
|
x |
|
|
x |
|
|
x |
Note: For
Function Description
Registers a memory address for use by TransferSync in subsequent calls. The local and remote memory addresses specified in TransferSync can be a subset of the registered addresses. Local memory addresses must be registered with the local HIXL instance, and remote memory addresses must be registered with the remote HIXL instance.
Prototype
1
|
Status RegisterMem(const MemDesc &mem, MemType type, MemHandle &mem_handle) |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
mem |
Input |
Description of the memory to be registered. The type is MemDesc. |
|
type |
Input |
Type of the memory to be registered. The type is MemType. |
|
mem_handle |
Output |
Memory handle returned after successful registration, which can be used for memory deregistration. The type is MemHandle. |
Example
Click GitCode, select the matching version, and obtain the sample from the examples/cpp directory.
Returns
- SUCCESS: Success.
- PARAM_INVALID: Incorrect parameter.
- Other values: Failure.
Exception Handling
None
Restrictions
- Before calling Connect to establish a link with the peer end, register all local memories.
- A single process supports a maximum of 256 registered memories. This restriction applies to the following products:
Atlas A2 training product /Atlas A2 inference product Atlas A3 training product /Atlas A3 inference product
- If the HDK version is earlier than 25.5.0, a maximum of 20 GB host memory can be registered. If the HDK version is 25.5.0 or later, a maximum of 1 TB host memory can be registered. Larger registered memory results in higher OS memory usage. This restriction applies to the following products:
Atlas A2 training product /Atlas A2 inference product Atlas A3 training product /Atlas A3 inference product
- To register the host memory, call aclrtMallocHost in Application Development (C&C++). The memory address allocated by this API is automatically aligned. This restriction applies to the following products:
Atlas A2 training product /Atlas A2 inference product Atlas A3 training product /Atlas A3 inference product
- To register the device memory, call aclrtMalloc in Application Development (C&C++). If HCCS is used for transmission, set the memory allocation rule to ACL_MEM_MALLOC_HUGE_ONLY.
- This API and Initialize must run in the same thread. If you need to switch threads to call this API, first call aclrtGetCurrentContext in Application Development (C&C++) in the thread where Initialize is running to obtain the context. Then, in the new thread, call aclrtSetCurrentContext in Application Development (C&C++) to set the context.