From 1982736a5dbd877175ef5995e2f3ffc31be56a67 Mon Sep 17 00:00:00 2001 From: Peter Andreas Entschev Date: Wed, 23 Oct 2024 11:01:24 -0700 Subject: [PATCH] Remove calls with high performance impact Remove some calls that have a high impact on performance and are good candidates for rewriting or removal. --- cpp/src/request.cpp | 6 +----- python/ucxx/ucxx/_lib/libucxx.pyx | 12 ++++-------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/cpp/src/request.cpp b/cpp/src/request.cpp index 22e135e0..0f901efe 100644 --- a/cpp/src/request.cpp +++ b/cpp/src/request.cpp @@ -117,11 +117,7 @@ void Request::checkError() utils::ucsErrorThrow(_status, _status == UCS_ERR_MESSAGE_TRUNCATED ? _status_msg : std::string()); } -bool Request::isCompleted() -{ - std::lock_guard lock(_mutex); - return _status != UCS_INPROGRESS; -} +bool Request::isCompleted() { return _status != UCS_INPROGRESS; } void Request::callback(void* request, ucs_status_t status) { diff --git a/python/ucxx/ucxx/_lib/libucxx.pyx b/python/ucxx/ucxx/_lib/libucxx.pyx index 2455a781..2c6d5145 100644 --- a/python/ucxx/ucxx/_lib/libucxx.pyx +++ b/python/ucxx/ucxx/_lib/libucxx.pyx @@ -771,9 +771,6 @@ cdef class UCXWorker(): cdef Tag cpp_tag = tag.value cdef TagMask cpp_tag_mask = tag_mask.value - if not self._context_feature_flags & Feature.TAG.value: - raise ValueError("UCXContext must be created with `Feature.TAG`") - with nogil: req = self._worker.get().tagRecv( buf, @@ -789,6 +786,7 @@ cdef class UCXWorker(): cdef class UCXRequest(): cdef: shared_ptr[Request] _request + Request* _request_ptr bint _enable_python_future bint _completed @@ -796,6 +794,8 @@ cdef class UCXRequest(): self._request = deref( shared_ptr_request) self._enable_python_future = enable_python_future self._completed = False + with nogil: + self._request_ptr = self._request.get() def __dealloc__(self) -> None: with nogil: @@ -810,7 +810,7 @@ cdef class UCXRequest(): return True with nogil: - completed = self._request.get().isCompleted() + completed = self._request_ptr.isCompleted() return completed @@ -1407,8 +1407,6 @@ cdef class UCXEndpoint(): cdef shared_ptr[Request] req cdef Tag cpp_tag = tag.value - if not self._context_feature_flags & Feature.TAG.value: - raise ValueError("UCXContext must be created with `Feature.TAG`") if arr.cuda and not self._cuda_support: raise ValueError( "UCX is not configured with CUDA support, please ensure that the " @@ -1439,8 +1437,6 @@ cdef class UCXEndpoint(): cdef Tag cpp_tag = tag.value cdef TagMask cpp_tag_mask = tag_mask.value - if not self._context_feature_flags & Feature.TAG.value: - raise ValueError("UCXContext must be created with `Feature.TAG`") if arr.cuda and not self._cuda_support: raise ValueError( "UCX is not configured with CUDA support, please ensure that the "