Skip to content

Commit

Permalink
Added wait_ip_interrupt(timeout) functionality on edge side (#8611)
Browse files Browse the repository at this point in the history
Signed-off-by: Manoj Takasi <[email protected]>
Co-authored-by: Manoj Takasi <[email protected]>
  • Loading branch information
ManojTakasi and Manoj Takasi authored Nov 24, 2024
1 parent 4ca0a2b commit db95e70
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/runtime_src/core/edge/user/device_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "core/edge/user/aie/profile_object.h"
#include <map>
#include <memory>
#include <poll.h>
#include <string>

#include <fcntl.h>
Expand Down Expand Up @@ -1293,4 +1294,26 @@ wait_ip_interrupt(xclInterruptNotifyHandle handle)
throw error(errno, "wait_ip_interrupt failed POSIX read");
}

std::cv_status
device_linux::
wait_ip_interrupt(xclInterruptNotifyHandle handle, int32_t timeout)
{
struct pollfd pfd = {.fd=handle, .events=POLLIN};
int32_t ret = 0;

//Checking for only one fd; Only of one CU
//Timeout value in milli seconds
ret = ::poll(&pfd, 1, timeout);
if (ret < 0)
throw error(errno, "wait_timeout: failed POSIX poll");

if (ret == 0) //Timeout occured
return std::cv_status::timeout;

if (pfd.revents & POLLIN) //Interrupt received
return std::cv_status::no_timeout;

throw error(-EINVAL, boost::str(boost::format("wait_timeout: POSIX poll unexpected event: %d") % pfd.revents));
}

} // xrt_core
3 changes: 3 additions & 0 deletions src/runtime_src/core/edge/user/device_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class device_linux : public shim<device_edge>
virtual void
wait_ip_interrupt(xclInterruptNotifyHandle);

virtual std::cv_status
wait_ip_interrupt(xclInterruptNotifyHandle, int32_t timeout);

virtual std::unique_ptr<hwctx_handle>
create_hw_context(const xrt::uuid& xclbin_uuid,
const xrt::hw_context::cfg_param_type& cfg_param,
Expand Down

0 comments on commit db95e70

Please sign in to comment.