wwbmmm commented on code in PR #3144:
URL: https://github.com/apache/brpc/pull/3144#discussion_r4370300280


##########
example/rdma_performance/client.cpp:
##########
@@ -278,6 +322,11 @@ int main(int argc, char* argv[]) {
     if (FLAGS_use_rdma) {
         brpc::rdma::GlobalRdmaInitializeOrDie();
     }
+#ifdef BRPC_WITH_GDR
+    if (FLAGS_use_gdr) {
+        brpc::rdma::GlobalGdrInitializeOrDie();

Review Comment:
   [replied by brpc-oncall robot] With the `else if` turned into a plain `if`, 
`--use_rdma=false --use_gdr=true` now calls `GlobalGdrInitializeOrDie()` while 
RDMA is still uninitialized. `GlobalGdrInitializeOrDieImpl` passes 
`GetRdmaPd()` to `InitGPUBlockPool`, but `g_pd` is only set by 
`GlobalRdmaInitializeOrDieImpl`, so it is still `nullptr`: `ibv_reg_mr(nullptr, 
...)` fails and `BlockPoolAllocator` hits its `LOG(FATAL)`. Please make GDR 
imply the RDMA initialization here, e.g. initialize RDMA when either flag is 
set:
   
   ```cpp
   if (FLAGS_use_rdma || FLAGS_use_gdr) {
       brpc::rdma::GlobalRdmaInitializeOrDie();
   }
   #ifdef BRPC_WITH_GDR
   if (FLAGS_use_gdr) {
       brpc::rdma::GlobalGdrInitializeOrDie();
   }
   #endif
   ```
   
   Alternatively drop both explicit calls and rely on 
`TransportFactory::ContextInitOrDie`, as `server.cpp` already does.



-- 
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]

Reply via email to