static ncclResult_t ofi_closeRecv()

in src/nccl_ofi_net.c [2053:2090]


static ncclResult_t ofi_closeRecv(void *recvComm)
{
	recvComm_t *rComm = (recvComm_t *)recvComm;
	int dev, rc;
	ncclResult_t ret = ncclSuccess;
	struct fid_mr *mr_handle = NULL;

	if (OFI_UNLIKELY(recvComm == NULL)) {
		ret = ncclSystemError;
		goto exit;
	}

	dev = rComm->dev;

	if (support_gdr) {
		/* Deregister Flush buffer memory region */
		mr_handle = (struct fid_mr *)rComm->flush_buff.mr_handle;
		if (mr_handle) {
			rc = fi_close((fid_t)mr_handle);
			if (OFI_UNLIKELY(rc != 0)) {
				ret = ncclSystemError;
				NCCL_OFI_WARN("Unable to de-register memory. RC: %d, Error: %s",
					      fi_strerror(-rc));
				goto exit;
			}
		}
	}

	free_ofi_fl(rComm->nccl_ofi_reqs_fl);
	free(recvComm);

	pthread_mutex_lock(&nccl_ofi_lock);
	put_nccl_ofi_comp(dev);
	pthread_mutex_unlock(&nccl_ofi_lock);

exit:
	return ret;
}