Allocate CPU memory for the Rdma buffer Args: size: to-be-allocated memory size lock: whether or not mutex_lock the process to protect concurrency. Returns: None
| 778 | // Returns: |
| 779 | // None |
| 780 | void RdmaMessageBuffer::CreateCPUBuffer(size_t size, bool lock) { |
| 781 | CHECK(size > 0); |
| 782 | if (lock) { |
| 783 | mu_.lock(); |
| 784 | } |
| 785 | if (local_status_ != none) { |
| 786 | // delete existing buffer |
| 787 | CHECK(!ibv_dereg_mr(self_)) << "ibv_dereg_mr failed"; |
| 788 | FreeBuffer(); |
| 789 | } |
| 790 | size_ = size; |
| 791 | buffer_ = malloc(size_); |
| 792 | self_ = ibv_reg_mr(channel_->adapter_->pd_, buffer_, size_, |
| 793 | IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE); |
| 794 | CHECK(self_) << "Failed to register memory region"; |
| 795 | buffer_on_host_ = true; |
| 796 | local_status_ = idle; |
| 797 | if (lock) { |
| 798 | mu_.unlock(); |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | // Set address of remote memory region |
| 803 | // Args: |
no test coverage detected