-
Notifications
You must be signed in to change notification settings - Fork 27
docs: 更新infinirt文档虚存部分 #36
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
Open
Ceng23333
wants to merge
5
commits into
InfiniTensor:main
Choose a base branch
from
Ceng23333:vm_doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,9 +183,9 @@ infiniStatus_t infinirtMemcpy(void *dst, const void *src, size_t size, infinirtM | |
| - dst: 目标地址。 | ||
| - src: 源地址。 | ||
| - size: 拷贝的字节数。 | ||
| - kind: 枚举类型infinirtMemcpyKind_t | ||
| - kind: 枚举类型infinirtMemcpyKind_t | ||
| 其定义如下: | ||
| ``` c++ | ||
| ``` c++ | ||
| typedef enum { | ||
| INFINIRT_MEMCPY_H2H = 0, //Host to Host | ||
| INFINIRT_MEMCPY_H2D = 1, //Host to Device | ||
|
|
@@ -227,3 +227,76 @@ infiniStatus_t infinirtFreeAsync(void *ptr, infinirtStream_t stream); | |
|
|
||
| - ptr: 要释放的设备内存地址。 | ||
| - stream: 异步释放所用的流。 | ||
|
|
||
| ### 5. 虚拟内存和物理内存管理 | ||
|
|
||
| #### 类型定义 | ||
|
|
||
| ``` c++ | ||
| typedef void *infinirtDeviceptr_t; // 设备指针类型 | ||
| typedef void *infinirtAllocationHandle_t;// 内存分配句柄类型 | ||
| typedef void *infinirtPhyMem_t; // 物理内存对象类型 | ||
| typedef void *infinirtVirtualMem_t; // 虚拟内存对象类型 | ||
| ``` | ||
|
|
||
| #### 获取内存最小粒度 | ||
|
|
||
| ``` c++ | ||
| infiniStatus_t infinirtGetMemGranularityMinimum(size_t *granularity); | ||
| ``` | ||
|
|
||
| - granularity: 返回内存分配的最小粒度大小。 | ||
|
|
||
| #### 创建物理内存 | ||
|
|
||
| ``` c++ | ||
| infiniStatus_t infinirtCreatePhysicalMem(infinirtPhyMem_t *phy_mem, size_t len); | ||
| ``` | ||
|
|
||
| - phy_mem: 返回创建的物理内存对象。 | ||
| - len: 物理内存大小(单位:字节)。 | ||
|
|
||
| #### 释放物理内存 | ||
|
|
||
| ``` c++ | ||
| infiniStatus_t infinirtReleasePhysicalMem(infinirtPhyMem_t phy_mem); | ||
| ``` | ||
|
|
||
| - phy_mem: 需要释放的物理内存对象。 | ||
|
|
||
| #### 创建虚拟内存 | ||
|
|
||
| ``` c++ | ||
| infiniStatus_t infinirtCreateVirtualMem(infinirtVirtualMem_t *vm, size_t len); | ||
| ``` | ||
|
|
||
| - vm: 返回创建的虚拟内存对象。 | ||
| - len: 虚拟内存大小(单位:字节)。 | ||
|
|
||
| #### 映射虚拟内存 | ||
|
|
||
| ``` c++ | ||
| infiniStatus_t infinirtMapVirtualMem(void **mapped_ptr, infinirtVirtualMem_t vm, size_t offset, infinirtPhyMem_t phy_mem); | ||
|
||
| ``` | ||
|
|
||
| - mapped_ptr: 返回映射后的内存指针。 | ||
| - vm: 虚拟内存对象。 | ||
| - offset: 映射的偏移量。 | ||
| - phy_mem: 要映射的物理内存对象。 | ||
|
|
||
| #### 解除虚拟内存映射 | ||
|
|
||
| ``` c++ | ||
| infiniStatus_t infinirtUnmapVirtualMem(infinirtVirtualMem_t vm, size_t offset); | ||
|
||
| ``` | ||
|
|
||
| - vm: 要解除映射的虚拟内存对象。 | ||
| - offset: 解除映射的偏移量。 | ||
|
|
||
| #### 释放虚拟内存 | ||
|
|
||
| ``` c++ | ||
| infiniStatus_t infinirtReleaseVirtualMem(infinirtVirtualMem_t vm); | ||
| ``` | ||
|
|
||
| - vm: 需要释放的虚拟内存对象。 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
去掉infinirtDeviceptr_t infinirtVirtualMem_t,直接用void*