Skip to content

Commit

Permalink
Sw Emulation fix for Graph test case (#8291)
Browse files Browse the repository at this point in the history
Signed-off-by: Sravankumar allu <[email protected]>
Co-authored-by: Sravankumar allu <[email protected]>
  • Loading branch information
SravanKumarAllu-xilinx and Sravankumar allu authored Jul 13, 2024
1 parent 8dfeb66 commit e2f4116
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,12 @@ get_device_info(xclDeviceInfo2 *info)
throw system_error(ret, "failed to get device info");
}

std::unique_ptr<xrt_core::graph_handle>
device::
open_graph_handle(const xrt::uuid& xclbin_id, const char* name, xrt::graph::access_mode am)
{
return std::make_unique<xclswemuhal2::SwEmuShim::graph_object>(
static_cast<xclswemuhal2::SwEmuShim*>(get_device_handle()), xclbin_id, name, am);
}

}} // swemu,xrt_core
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "core/common/shim/buffer_handle.h"
#include "core/common/shim/hwctx_handle.h"
#include "core/common/shim/shared_handle.h"
#include "core/common/shim/graph_handle.h"

#include "core/pcie/common/device_pcie.h"

Expand Down Expand Up @@ -47,6 +48,9 @@ class device : public shim<device_pcie>
void
get_device_info(xclDeviceInfo2 *info) override;

std::unique_ptr<xrt_core::graph_handle>
open_graph_handle(const xrt::uuid& xclbin_id, const char* name, xrt::graph::access_mode am) override;

private:
// Private look up function for concrete query::request
virtual const query::request&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "core/common/xrt_profiling.h"
#include "core/common/shim/buffer_handle.h"
#include "core/common/shim/hwctx_handle.h"
#include "core/common/shim/graph_handle.h"
#include "core/include/experimental/xrt_xclbin.h"

#include <fcntl.h>
Expand Down Expand Up @@ -254,6 +255,91 @@ namespace xclswemuhal2
}
}; // class hwcontext

// Shim handle for graph object
class graph_object : public xrt_core::graph_handle
{
SwEmuShim* m_shim;
xclGraphHandle m_xclGraphHandle;

public:
graph_object(SwEmuShim* shim, const xrt::uuid& uuid , const char* name, xrt::graph::access_mode am)
: m_shim{shim},
m_xclGraphHandle{xclGraphOpen(m_shim, uuid.get(), name, am)}
{}

~graph_object()
{
xclGraphClose(m_xclGraphHandle);
}

void
reset_graph() override
{
if (auto ret = xclGraphReset(m_xclGraphHandle))
throw xrt_core::system_error(ret, "fail to reset graph");
}

uint64_t
get_timestamp() override
{
return xclGraphTimeStamp(m_xclGraphHandle);
}

void
run_graph(int iterations) override
{
if (auto ret = xclGraphRun(m_xclGraphHandle, iterations))
throw xrt_core::system_error(ret, "fail to run graph");
}

int
wait_graph_done(int timeout) override
{
return xclGraphWaitDone(m_xclGraphHandle, timeout);
}

void
wait_graph(uint64_t cycle) override
{
if (auto ret = xclGraphWait(m_xclGraphHandle, cycle))
throw xrt_core::system_error(ret, "fail to wait graph");
}

void
suspend_graph() override
{
if (auto ret = xclGraphSuspend(m_xclGraphHandle))
throw xrt_core::system_error(ret, "fail to suspend graph");
}

void
resume_graph() override
{
if (auto ret = xclGraphResume(m_xclGraphHandle))
throw xrt_core::system_error(ret, "fail to resume graph");
}

void
end_graph(uint64_t cycle) override
{
if (auto ret = xclGraphEnd(m_xclGraphHandle, cycle))
throw xrt_core::system_error(ret, "fail to end graph");
}

void
update_graph_rtp(const char* port, const char* buffer, size_t size) override
{
if (auto ret = xclGraphUpdateRTP(m_xclGraphHandle, port, buffer, size))
throw xrt_core::system_error(ret, "fail to update graph rtp");
}

void
read_graph_rtp(const char* port, char* buffer, size_t size) override
{
if (auto ret = xclGraphReadRTP(m_xclGraphHandle, port, buffer, size))
throw xrt_core::system_error(ret, "fail to read graph rtp");
}
}; // graph_object
public:
static const unsigned TAG;
static const unsigned CONTROL_AP_START;
Expand Down

0 comments on commit e2f4116

Please sign in to comment.