Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VITIS-11024 enable hw_context support for xrt::graph objects 3rd commit #8292

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 18 additions & 73 deletions src/runtime_src/core/common/ishim.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,31 +208,40 @@ struct ishim

#ifdef XRT_ENABLE_AIE
virtual void
open_aie_context(xrt::aie::access_mode) = 0;
open_aie_context(xrt::aie::access_mode)
{ throw not_supported_error{__func__}; }

virtual void
sync_aie_bo(xrt::bo& bo, const char *gmioName, xclBOSyncDirection dir, size_t size, size_t offset) = 0;
sync_aie_bo(xrt::bo& bo, const char *gmioName, xclBOSyncDirection dir, size_t size, size_t offset)
{ throw not_supported_error{__func__}; }

virtual void
reset_aie() = 0;
reset_aie()
{ throw not_supported_error{__func__}; }

virtual void
sync_aie_bo_nb(xrt::bo& bo, const char *gmioName, xclBOSyncDirection dir, size_t size, size_t offset) = 0;
sync_aie_bo_nb(xrt::bo& bo, const char *gmioName, xclBOSyncDirection dir, size_t size, size_t offset)
{ throw not_supported_error{__func__}; }

virtual void
wait_gmio(const char *gmioName) = 0;
wait_gmio(const char *gmioName)
{ throw not_supported_error{__func__}; }

virtual int
start_profiling(int option, const char* port1Name, const char* port2Name, uint32_t value) = 0;
start_profiling(int option, const char* port1Name, const char* port2Name, uint32_t value)
{ throw not_supported_error{__func__}; }

virtual uint64_t
read_profiling(int phdl) = 0;
read_profiling(int phdl)
{ throw not_supported_error{__func__}; }

virtual void
stop_profiling(int phdl) = 0;
stop_profiling(int phdl)
{ throw not_supported_error{__func__}; }

virtual void
load_axlf_meta(const axlf*) = 0;
load_axlf_meta(const axlf*)
{ throw not_supported_error{__func__}; }

virtual std::vector<char>
read_aie_mem(uint16_t /*col*/, uint16_t /*row*/, uint32_t /*offset*/, uint32_t /*size*/)
Expand Down Expand Up @@ -404,70 +413,6 @@ struct shim : public DeviceType
if (auto ret = xclInternalResetDevice(DeviceType::get_device_handle(), kind))
throw error(ret, "failed to reset device");
}

#ifdef XRT_ENABLE_AIE

void
open_aie_context(xrt::aie::access_mode am) override
{
if (auto ret = xclAIEOpenContext(DeviceType::get_device_handle(), am))
throw error(ret, "fail to open aie context");
}

void
sync_aie_bo(xrt::bo& bo, const char *gmioName, xclBOSyncDirection dir, size_t size, size_t offset) override
{
if (auto ret = xclSyncBOAIE(DeviceType::get_device_handle(), bo, gmioName, dir, size, offset))
throw system_error(ret, "fail to sync aie bo");
}

void
reset_aie() override
{
if (auto ret = xclResetAIEArray(DeviceType::get_device_handle()))
throw system_error(ret, "fail to reset aie");
}

void
sync_aie_bo_nb(xrt::bo& bo, const char *gmioName, xclBOSyncDirection dir, size_t size, size_t offset) override
{
if (auto ret = xclSyncBOAIENB(DeviceType::get_device_handle(), bo, gmioName, dir, size, offset))
throw system_error(ret, "fail to sync aie non-blocking bo");
}

void
wait_gmio(const char *gmioName) override
{
if (auto ret = xclGMIOWait(DeviceType::get_device_handle(), gmioName))
throw system_error(ret, "fail to wait gmio");
}

int
start_profiling(int option, const char* port1Name, const char* port2Name, uint32_t value) override
{
return xclStartProfiling(DeviceType::get_device_handle(), option, port1Name, port2Name, value);
}

uint64_t
read_profiling(int phdl) override
{
return xclReadProfiling(DeviceType::get_device_handle(), phdl);
}

void
stop_profiling(int phdl) override
{
if (auto ret = xclStopProfiling(DeviceType::get_device_handle(), phdl))
throw system_error(ret, "failed to stop profiling");
}

void
load_axlf_meta(const axlf* buffer) override
{
if (auto ret = xclLoadXclBinMeta(DeviceType::get_device_handle(), buffer))
throw system_error(ret, "failed to load xclbin");
}
#endif
};

// Stub out all xrt_core::ishim functions to throw not supported. A
Expand Down
3 changes: 3 additions & 0 deletions src/runtime_src/core/common/shim/graph_handle.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.

#ifndef XRT_CORE_GRAPH_HANDLE_H
#define XRT_CORE_GRAPH_HANDLE_H

Expand Down
4 changes: 2 additions & 2 deletions src/runtime_src/core/edge/user/aie/aied.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ aied::poll_aie(void* arg)
}

void
aied::register_graph(const graph_instance *graph)
aied::register_graph(const graph_object *graph)
{
m_graphs.push_back(graph);
}

void
aied::deregister_graph(const graph_instance *graph)
aied::deregister_graph(const graph_object *graph)
{
m_graphs.erase(std::remove(m_graphs.begin(), m_graphs.end(), graph), m_graphs.end());
}
Expand Down
8 changes: 4 additions & 4 deletions src/runtime_src/core/edge/user/aie/aied.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <thread>
#include <pthread.h>
#include "core/common/device.h"
#include "core/edge/user/aie/graph.h"
#include "graph_object.h"

/*
* It receives commands from zocl and dispatches back the output.
Expand All @@ -37,14 +37,14 @@ class aied
public:
aied(xrt_core::device* device);
~aied();
void register_graph(const graph_instance *graph);
void deregister_graph(const graph_instance *graph);
void register_graph(const graph_object *graph);
void deregister_graph(const graph_object *graph);

private:
bool done;
static void* poll_aie(void *arg);
xrt_core::device *m_device;
std::vector<const graph_instance*> m_graphs;
std::vector<const graph_object*> m_graphs;
pthread_t ptid;
};
} // end namespace
Expand Down
Loading
Loading