randomkang commented on code in PR #3144:
URL: https://github.com/apache/brpc/pull/3144#discussion_r4546875743
##########
src/brpc/policy/crc32c_checksum.cpp:
##########
@@ -29,10 +29,45 @@ namespace policy {
namespace {
+#if BRPC_WITH_GDR
+// CRC32C is computed on the CPU, so GPU memory cannot be read through CPU
+// pointers. Copy the block to a host buffer first and extend the crc over the
+// copy; the data itself stays in GPU memory (the GPU -> GPU data path of GDR
+// is untouched).
+static uint32_t ExtendCrc32cFromGpu(uint32_t crc, const butil::IOBuf& buf) {
+ const size_t size = buf.size();
+ if (size == 0) {
+ return crc;
+ }
+ char* host = new (std::nothrow) char[size];
+ if (host == nullptr) {
+ LOG(ERROR) << "Fail to alloc host buffer to checksum gpu memory";
+ // Fail closed: return a value that cannot match the expected crc.
+ return crc ^ 0xdeadbeefu;
Review Comment:
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]