static ncclResult_t ofi_test()

in src/nccl_ofi_net.c [1831:1874]


static ncclResult_t ofi_test(void* request, int* done, int* size)
{
	ncclResult_t ret = ncclSuccess;

	/* Check if request is valid */
	if (OFI_UNLIKELY(request == NULL)) {
		ret = ncclSystemError;
		goto exit;
	}

	nccl_ofi_req_t *req = (nccl_ofi_req_t *)request;
	nccl_ofi_t *nccl_ofi_comp = NULL;

	/* Progress NCCL OFI in order to process completions */
	nccl_ofi_comp = nccl_ofi_component[req->dev];
	if (OFI_UNLIKELY(nccl_ofi_comp == NULL)) {
		ret = ncclSystemError;
		NCCL_OFI_WARN("NCCL OFI component for dev %d is uninitialised",
			      req->dev);
		goto exit;
	}

	ret = nccl_ofi_progress(nccl_ofi_comp);
	if (OFI_UNLIKELY(ret != 0))
		goto exit;

	/* Determine whether the request has finished and free if done */
	if (OFI_LIKELY(req->state == NCCL_OFI_REQ_COMPLETED ||
		       req->state == NCCL_OFI_REQ_ERROR)) {
		if (size)
			*size = req->size;
		/* Mark as done */
		*done = 1;
		free_nccl_ofi_req(req, true);
	}
	else
		*done = 0;

	if (OFI_UNLIKELY(req->state == NCCL_OFI_REQ_ERROR))
		ret = ncclSystemError;

exit:
	return ret;
}