-
Notifications
You must be signed in to change notification settings - Fork 77
issue/338: infinirt适配虚存接口 #341
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ceng <441651826@qq.com>
include/infinirt.h
Outdated
| }; | ||
|
|
||
| // Represents a vacant region, storing its length. | ||
| using infinirtVacantRegion = size_t; |
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.
using?这是纯C语言头文件,不能有std之类的C++语法
include/infinirt.h
Outdated
| typedef void *infinirtAllocationHandle_t; | ||
|
|
||
| // Represents a physical memory allocation, mirroring Rust's PhyMem. | ||
| struct infinirtPhyMem { |
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.
struct命名首字母大写
|
先把document写了提pr |
include/infinirt.h
Outdated
| // A region in virtual memory can be either mapped or vacant. | ||
| using infinirtPhyRegion = std::variant<infinirtMappedRegion, infinirtVacantRegion>; | ||
|
|
||
| struct infinirtVirtualMemManager { |
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.
这个库只提供接口就可以,不需要提供一个manager,用户自己负责管理虚存和物理内存的表
Signed-off-by: Ceng <441651826@qq.com>
Signed-off-by: Ceng <441651826@qq.com>
Signed-off-by: Ceng <441651826@qq.com>
| __C __export infiniStatus_t infinirtReleasePhysicalMem(infinirtPhysicalMemoryHandle_t pm_handle); | ||
|
|
||
| __C __export infiniStatus_t infinirtCreateVirtualMem(void **vm, size_t len); | ||
| __C __export infiniStatus_t infinirtMapVirtualMem(void *vm, size_t len, size_t offset, infinirtPhysicalMemoryHandle_t pm_handle); |
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.
权限控制要暴露吗?
| // Virtual memory & physical memory | ||
| typedef void *infinirtPhysicalMemoryHandle_t; | ||
|
|
||
| __C __export infiniStatus_t infinirtGetMemGranularityMinimum(size_t *granularity); |
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.
我觉得 CUDA 搞这个名字挺奇怪的,要是想跟 CUDA 对齐就保持,不然的话叫 page size 之类的更好些
| return freeDevice(ptr); | ||
| } | ||
|
|
||
| infiniStatus_t getMemGranularityMinimum(size_t *granularity) { |
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.
CPU 主存很容易实现虚拟化逻辑,没必要设置为不支持。可以手工做一套用户态虚拟化或者交由操作系统处理(主存正常分配自带操作系统提供的虚拟化)
| #include "infinirt_cuda.cuh" | ||
| #include <cuda.h> | ||
| #include <cuda_runtime.h> | ||
| #include <string.h> |
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.
.cu 里面理论上说不需要 cuda.h、cuda_runtime.h 对于 nvcc 来说是预置的。c/c++ 标准库头文件应该用 c++ 标准的
| CUmemAllocationProp *getMemProp() { | ||
| int device_id; | ||
| infinirtGetDevice(nullptr, &device_id); | ||
| CUmemAllocationProp *cuda_prop = new CUmemAllocationProp(); |
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.
这东西为啥在堆上分配啊?没必要啊
| } | ||
|
|
||
| infiniStatus_t getMemGranularityMinimum(size_t *granularity) { | ||
| CUmemAllocationProp *cuda_prop = getMemProp(); |
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.
这里用
CUmemAllocationProp cuda_prop;
getMemProp()可以传它的地址
#338