-
Notifications
You must be signed in to change notification settings - Fork 182
feat: add --rdma=cpu|gpu flag, bump minio-go to v7.2.0 #491
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
Draft
harshavardhana
wants to merge
1
commit into
minio:master
Choose a base branch
from
harshavardhana:add-rdma-flag
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.
Draft
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
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,98 @@ | ||
| /* | ||
| * Warp (C) 2019-2026 MinIO, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| package bench | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "io" | ||
| "unsafe" | ||
| ) | ||
|
|
||
| // RDMAMode constants accepted by --rdma. | ||
| const ( | ||
| RDMAModeOff = "" | ||
| RDMAModeCPU = "cpu" | ||
| RDMAModeGPU = "gpu" | ||
| ) | ||
|
|
||
| // rdmaBuf is a per-op buffer registered with the NIC for S3-over-RDMA. | ||
| // For CPU mode, ptr points into pinned host memory (a Go []byte that we | ||
| // keep alive via the holder field). For GPU mode, ptr is a CUDA device | ||
| // pointer returned by cudaMalloc — see rdmabuf_rdma.go. | ||
| type rdmaBuf struct { | ||
| ptr unsafe.Pointer | ||
| size int | ||
| mode string | ||
| holder []byte // CPU mode: keeps the backing slice alive | ||
| } | ||
|
|
||
| // allocRDMABuf returns a per-op buffer suitable for opts.RDMABuffer. | ||
| // `src`, when non-nil, is drained into the buffer (used by PUT to stage | ||
| // the generator output). For GPU mode the source data is uploaded via | ||
| // cudaMemcpy in stageToRDMABuf; for CPU mode it is a plain io.ReadFull. | ||
| func allocRDMABuf(mode string, size int) (*rdmaBuf, error) { | ||
| switch mode { | ||
| case RDMAModeCPU: | ||
| b := make([]byte, size) | ||
| if size == 0 { | ||
| return &rdmaBuf{mode: mode, size: 0, holder: b}, nil | ||
| } | ||
| return &rdmaBuf{ | ||
| ptr: unsafe.Pointer(&b[0]), | ||
| size: size, | ||
| mode: mode, | ||
| holder: b, | ||
| }, nil | ||
| case RDMAModeGPU: | ||
| return allocRDMAGPU(size) | ||
| default: | ||
| return nil, fmt.Errorf("rdma: unknown mode %q (want %q or %q)", | ||
| mode, RDMAModeCPU, RDMAModeGPU) | ||
| } | ||
| } | ||
|
|
||
| // stageToRDMABuf drains src into the buffer. For CPU buffers this is a | ||
| // straight ReadFull into the backing slice. For GPU buffers the bytes | ||
| // are first read into a small CPU bounce buffer and then uploaded via | ||
| // cudaMemcpy host-to-device (see rdmabuf_rdma.go). | ||
| func stageToRDMABuf(b *rdmaBuf, src io.Reader) error { | ||
| if b == nil || b.size == 0 || src == nil { | ||
| return nil | ||
| } | ||
| switch b.mode { | ||
| case RDMAModeCPU: | ||
| _, err := io.ReadFull(src, b.holder) | ||
| return err | ||
| case RDMAModeGPU: | ||
| return stageToGPU(b, src) | ||
| default: | ||
| return fmt.Errorf("rdma: unknown mode %q", b.mode) | ||
| } | ||
| } | ||
|
|
||
| // freeRDMABuf releases CUDA device memory; for CPU buffers it lets the | ||
| // Go runtime reclaim the backing slice once the rdmaBuf goes out of | ||
| // scope. | ||
| func freeRDMABuf(b *rdmaBuf) { | ||
| if b == nil { | ||
| return | ||
| } | ||
| if b.mode == RDMAModeGPU { | ||
| freeRDMAGPU(b) | ||
| } | ||
| } | ||
|
|
||
| // errRDMAGPUUnsupported is returned by the stub GPU allocator built | ||
| // without -tags=rdma. | ||
| var errRDMAGPUUnsupported = errors.New( | ||
| "rdma=gpu requires building warp with -tags=rdma (libcudart + libminiocpp)") |
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,64 @@ | ||
| //go:build rdma | ||
|
|
||
| /* | ||
| * Warp (C) 2019-2026 MinIO, Inc. | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| package bench | ||
|
|
||
| // #cgo LDFLAGS: -lcudart | ||
| // #include <cuda_runtime.h> | ||
| // #include <stdlib.h> | ||
| import "C" | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "io" | ||
| "unsafe" | ||
| ) | ||
|
|
||
| // allocRDMAGPU allocates a CUDA device buffer of size bytes. The | ||
| // returned rdmaBuf carries the device pointer in ptr; the NIC GPU- | ||
| // Direct RDMA-writes / reads into it via minio-go's RDMA dispatch. | ||
| func allocRDMAGPU(size int) (*rdmaBuf, error) { | ||
| if size <= 0 { | ||
| return &rdmaBuf{mode: RDMAModeGPU}, nil | ||
| } | ||
| var devPtr unsafe.Pointer | ||
| if rc := C.cudaMalloc(&devPtr, C.size_t(size)); rc != 0 { | ||
| return nil, fmt.Errorf("cudaMalloc(%d): cudaError=%d", size, int(rc)) | ||
| } | ||
| return &rdmaBuf{ptr: devPtr, size: size, mode: RDMAModeGPU}, nil | ||
| } | ||
|
|
||
| // stageToGPU reads `size` bytes from src into a CPU bounce buffer, then | ||
| // cudaMemcpys host-to-device into the registered GPU buffer. The bounce | ||
| // buffer is reused per chunk to keep the per-op allocation budget low. | ||
| func stageToGPU(b *rdmaBuf, src io.Reader) error { | ||
| if b == nil || b.size == 0 || src == nil { | ||
| return nil | ||
| } | ||
| host := make([]byte, b.size) | ||
| if _, err := io.ReadFull(src, host); err != nil { | ||
| return err | ||
| } | ||
| rc := C.cudaMemcpy(b.ptr, | ||
| unsafe.Pointer(&host[0]), | ||
| C.size_t(b.size), | ||
| C.cudaMemcpyHostToDevice) | ||
| if rc != 0 { | ||
| return fmt.Errorf("cudaMemcpy H2D: cudaError=%d", int(rc)) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // freeRDMAGPU releases the CUDA device buffer. | ||
| func freeRDMAGPU(b *rdmaBuf) { | ||
| if b == nil || b.ptr == nil { | ||
| return | ||
| } | ||
| C.cudaFree(b.ptr) | ||
| b.ptr = nil | ||
| } | ||
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.
const HasRDMA = true- so you can easily gate it for non-builds.I assume we'll need a special release for this version once ready.