Repository navigation
support gpu direct rdma #3144
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
randomkang
wants to merge
1
commit into
apache:master
Choose a base branch
from
randomkang:gdr
base: master
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
support gpu direct rdma #3144
Changes from all commits
Commits
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
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # 编译 | ||
|
|
||
| GDR: GPU Direct Rdma, gdr 是rdma的一种特殊模式,其通过rdma将数据直接收到了gpu的显存上。 | ||
|
|
||
| 由于GDR对驱动与硬件有要求,目前仅支持在Linux系统编译并运行GDR功能。 | ||
|
|
||
| 目前GDR只支持baidu std protocol。 | ||
|
|
||
| 使用config_brpc: | ||
| ```bash | ||
| sh config_brpc.sh --with-rdma --with-gdr --headers="/usr/include" --libs="/usr/lib64 /usr/bin" | ||
| make | ||
|
|
||
| cd example/rdma_performance # 示例程序 | ||
| make | ||
| ``` | ||
|
|
||
| 使用bazel: | ||
| ```bash | ||
| # Server | ||
| bazel build --define=BRPC_WITH_RDMA=true --define=BRPC_WITH_GDR=true example:rdma_performance_server | ||
| # Client | ||
| bazel build --define=BRPC_WITH_RDMA=true --define=BRPC_WITH_GDR=true example:rdma_performance_client | ||
| ``` | ||
|
|
||
| # 基本实现 | ||
|
|
||
| GDR是RDMA的一种特殊形式,在使用GDR之前,必须对RDMA和GDR都进行Global Init。 | ||
| GDR新增了一个显存池,类似于RDMA内存池,显存池的数据也是按照block进行组织的。 | ||
| 当打开GDR功能后,框架通过DoPostRecvGDR来发起显存上的WQE。 | ||
| 在接收到数据后,我们将header、meta、body(不包括attachment)copy回内存进行处理。 | ||
| Attachment位于显存上,用户可以调用IOBuf::copy_from_gpu接口将attachment从brpc框架层copy到应用层进行处理。 | ||
|
|
||
|
|
||
| 注意: | ||
| 1. 在使用gdr功能时,需要将环境变量MLX5_SCATTER_TO_CQE设置为0. 这是因为gdr要求所有接收到的数据都写入post recv 时指定的 GPU 显存 buffer 中, | ||
| 而MLX5_SCATTER_TO_CQE打开时,小消息直接内联写入了内存,破坏了这个要求,从而会引发操作失败。 | ||
|
|
||
|
|
||
| # 参数 | ||
|
|
||
| 可配置参数说明: | ||
| * gdr_block_size_kb: 使用gdr传送数据时,block的大小(单位为KB),默认为512; | ||
| * max_gdr_regions: gdr显存池所使用Region的最大个数,每个Region大小为1GB; |
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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| Compile GDR: | ||
|
|
||
| GPU Direct RDMA. GDR is a special mode of RDMA that allows data to be received directly into the GPU’s memory through RDMA. | ||
| Because GDR requires specific drivers and hardware support, it is currently only available for compilation and execution on Linux systems. | ||
| At present, GDR only supports the Baidu STD protocol. | ||
|
|
||
| To use config_brpc: | ||
|
|
||
| sh config_brpc.sh --with-rdma --with-gdr --headers="/usr/include" --libs="/usr/lib64 /usr/bin" | ||
| make | ||
| cd example/rdma_performance # Example program | ||
| make | ||
|
|
||
| To use Bazel: | ||
|
|
||
| # Server | ||
| bazel build --define=BRPC_WITH_RDMA=true --define=BRPC_WITH_GDR=true example:rdma_performance_server | ||
|
|
||
| # Client | ||
| bazel build --define=BRPC_WITH_RDMA=true --define=BRPC_WITH_GDR=true example:rdma_performance_client | ||
|
|
||
|
|
||
| Basic Implementation: | ||
|
|
||
| GDR is a special form of RDMA. Before using GDR, both RDMA and GDR must be globally initialized. | ||
|
|
||
| GDR introduces a GPU memory pool, similar to the RDMA memory pool. Data in the GPU memory pool is also organized in blocks. | ||
|
|
||
| When GDR is enabled, the framework initiates WQEs on GPU memory through DoPostRecvGDR. | ||
|
|
||
| After receiving data, the header, meta, and body (excluding attachments) are copied back to host memory for processing. | ||
| Attachments remain in GPU memory, and users can call IOBuf::copy_from_gpu to copy attachments from the brpc framework layer to the application layer. | ||
|
|
||
| Note: | ||
|
|
||
| When using GDR, the environment variable MLX5_SCATTER_TO_CQE must be set to 0. This is because GPUDirect RDMA requires that all received data be written to the GPU memory buffer specified in the post‑receive operation. However, when MLX5_SCATTER_TO_CQE is enabled, small messages are directly inlined into host memory, which violates this requirement and consequently causes operation failures. | ||
|
|
||
| Parameters | ||
|
|
||
| Configurable parameters: | ||
|
|
||
| gdr_block_size_kb: The block size (in KB) used when transferring data via GDR. Default is 512. | ||
|
|
||
| max_gdr_regions: The maximum number of regions used by the GDR GPU memory pool. Each region is 1 GB. |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
We do not use any cuda kernel in this pr, so CUDA_HOME is not necessary. The cuda headers and libs can be found by C_INCLUDE_PATH and LD_LIBRARY_PATH.