diff --git a/README.md b/README.md index 90929110acbd205c358946955b5ff17054c7594b..b4753fd4cf88621ed69195bb3eacaa97380be36e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,41 @@ make install #### Instructions -1. xxxx +libgmem currently has three external interfaces: +1. +gmemFreeEager: For address segments within a given range of [addr, addr + size], gmemFreeEager will release the entire page with the range aligned inward (default page size 2M). + A stream that is NULL represents synchronous calls, while a non-NULL represents asynchronous calls. Asynchronous calls will be registered on the corresponding device's work stream. + If there is no complete page within the scope, success will be returned directly. + + The interface successfully returns 0, while failure returns an error code. + + ```c + Prototype: int gmemFreeEager (unsigned long addr, size_t size, void * stream); + Usage: ret = gmemFreeEager (addr, size, stream); + ``` + +2. +gmemPrefetch: For address segments within a given range of [addr, addr + size], Prefetch will prefetch the entire page (covering the entire address segment) that aligns the page size outward from the range. + Ensure that the specified computing unit device hnid does not trigger a page fault in subsequent access to the vma. + A stream that is NULL represents synchronous calls, while a non-NULL represents asynchronous calls. Asynchronous calls will be registered on the corresponding device's work stream. + If the data is already on the specified device, gmemPrefetch will mark the data as hot data. + + The interface successfully returns 0, while failure returns an error code. + + ```c + Prototype: int gmemPrefetch (unsigned long addr, size_t size, int hnid, void * stream); + Usage: ret = gmemPrefetch (addr, size, hnid, stream); + ``` + +3. +gmemGetNumaId: Gets the NumaId of the current device. + + The interface successfully returns the heterogeneous numaid of devices, while failure returns an error code. + + ```c + Prototype: int gmemGetNumaId (void); + Usage: numaid = gmemGetNumaId(); + ``` #### Contribution diff --git a/README_CN.md b/README_CN.md index 44a74a83e5e33c2f4ce1bb7e64fcb153c9c675ad..46b2acc6fd4ed34ed6f8ffb48545f1e61ea67d28 100644 --- a/README_CN.md +++ b/README_CN.md @@ -19,7 +19,41 @@ make install #### 使用说明 -1. xxxx +libgmem当前有三个对外接口: +1. +gmemFreeEager:对于给定范围[addr, addr + size]的地址段,gmemFreeEager会对范围向内对齐页面大小的完整页面进行释放(默认页面大小2M)。 + stream为空表示同步调用,非空表示异步调用,异步调用时会注册在对应设备的工作流上。 + 如果范围内不存在完整页面,将直接返回成功。 + + 接口成功返回0,失败返回错误码。 + + ```c + 接口原型: int gmemFreeEager(unsigned long addr, size_t size, void *stream); + 接口用法: ret = gmemFreeEager(addr, size, stream); + ``` + +2. +gmemPrefetch:对于给定范围[addr, addr + size]的地址段,Prefetch会对范围向外对齐页面大小的完整页面(覆盖整个地址段)进行预取。 + 确保指定的计算单元设备hnid在接下来对vma发起的访问不会触发page fault。 + stream为空表示同步调用,非空表示异步调用,异步调用时会注册在对应设备的工作流上。 + 如果数据已经在指定设备上,gmemPrefetch会标记数据为热数据。 + + 接口成功返回0,失败返回错误码。 + + ```c + 接口原型: int gmemPrefetch(unsigned long addr, size_t size, int hnid, void *stream); + 接口用法: ret = gmemPrefetch(addr, size, hnid, stream); + ``` + +3. +gmemGetNumaId:获取当前设备的NumaId。 + + 接口成功返回设备的异构NumaId,失败返回错误码。 + + ```c + 接口原型: int gmemGetNumaId(void); + 接口用法: numaid = gmemGetNumaId(); + ``` #### 参与贡献