-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8840 from Akshay-Venkatesh/topic/revert-cuda-copy…
…-notification-v.14.x UCT/CUDA_COPY: use EVENT_FD instead of EVENT_ASYNC_CB - v1.14.x
- Loading branch information
Showing
11 changed files
with
264 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2023. ALL RIGHTS RESERVED. | ||
* | ||
* See file LICENSE for terms. | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
# include "config.h" | ||
#endif | ||
|
||
#include "eventfd.h" | ||
|
||
#include <ucs/debug/log.h> | ||
#include <ucs/sys/sys.h> | ||
|
||
|
||
typedef ssize_t (*ucs_async_eventfd_cb_t)(int fd, void *buf, size_t count); | ||
|
||
|
||
static inline ucs_status_t | ||
ucs_async_eventfd_common_io(int fd, int blocking, ucs_async_eventfd_cb_t cb) | ||
{ | ||
uint64_t dummy = 1; | ||
int ret; | ||
|
||
do { | ||
ret = cb(fd, &dummy, sizeof(dummy)); | ||
if (ret > 0) { | ||
return UCS_OK; | ||
} | ||
|
||
if ((ret < 0) && (errno != EAGAIN) && (errno != EINTR)) { | ||
ucs_error("eventfd error (fd %d blocking %d): %m", fd, blocking); | ||
return UCS_ERR_IO_ERROR; | ||
} | ||
} while (blocking); | ||
|
||
return UCS_ERR_NO_PROGRESS; | ||
} | ||
|
||
ucs_status_t ucs_async_eventfd_create(int *fd_p) | ||
{ | ||
int local_fd; | ||
|
||
local_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); | ||
if (local_fd == -1) { | ||
ucs_error("failed to create event fd: %m"); | ||
return UCS_ERR_IO_ERROR; | ||
} | ||
|
||
*fd_p = local_fd; | ||
return UCS_OK; | ||
} | ||
|
||
void ucs_async_eventfd_destroy(int fd) | ||
{ | ||
if (fd != UCS_ASYNC_EVENTFD_INVALID_FD) { | ||
close(fd); | ||
} | ||
} | ||
|
||
ucs_status_t ucs_async_eventfd_poll(int fd) | ||
{ | ||
return ucs_async_eventfd_common_io(fd, 0, (ucs_async_eventfd_cb_t)read); | ||
} | ||
|
||
ucs_status_t ucs_async_eventfd_signal(int fd) | ||
{ | ||
return ucs_async_eventfd_common_io(fd, 1, (ucs_async_eventfd_cb_t)write); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) NVIDIA CORPORATION & AFFILIATES, 2023. ALL RIGHTS RESERVED. | ||
* | ||
* See file LICENSE for terms. | ||
*/ | ||
|
||
#ifndef UCS_ASYNC_EVENTFD_H | ||
#define UCS_ASYNC_EVENTFD_H | ||
|
||
#include <ucs/type/status.h> | ||
#include <sys/eventfd.h> | ||
|
||
BEGIN_C_DECLS | ||
|
||
|
||
/** | ||
* Represent either an unitialized or a closed event file descriptor. | ||
*/ | ||
#define UCS_ASYNC_EVENTFD_INVALID_FD (-1) | ||
|
||
|
||
/** | ||
* @ingroup UCS_RESOURCE | ||
* | ||
* Create an event file descriptor. This file descriptor can later be passed as | ||
* arguments to poll/signal functions to wait for notifications or to notify | ||
* pollers. | ||
* | ||
* @param fd Pointer to integer which is populated with a file descriptor. | ||
*/ | ||
ucs_status_t ucs_async_eventfd_create(int *fd); | ||
|
||
|
||
/** | ||
* @ingroup UCS_RESOURCE | ||
* | ||
* Destroy an event file descriptor. | ||
* | ||
* @param fd File descriptor to be closed. | ||
*/ | ||
void ucs_async_eventfd_destroy(int fd); | ||
|
||
|
||
/** | ||
* @ingroup UCS_RESOURCE | ||
* | ||
* Notify a file descriptor when it is polled. An appropriate error is returned | ||
* upon failure. | ||
* | ||
* @param fd File descriptor which will be notified. | ||
*/ | ||
ucs_status_t ucs_async_eventfd_signal(int fd); | ||
|
||
|
||
/** | ||
* @ingroup UCS_RESOURCE | ||
* | ||
* Poll on a file descriptor for incoming notifications. If no notifications are | ||
* observed then UCS_ERR_NO_PROGRESS is returned. An appropriate error is | ||
* returned upon failure. | ||
* | ||
* @param fd File descriptor to be polled on. | ||
*/ | ||
ucs_status_t ucs_async_eventfd_poll(int fd); | ||
|
||
END_C_DECLS | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.