-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AIE Halt Plugin to set Debug Halt on AIE Cores used by current Hw Con…
…text, using transaction Signed-off-by: Ishita Ghosh <[email protected]>
- Loading branch information
Ishita Ghosh
committed
Aug 11, 2024
1 parent
7cb9d6a
commit 1d72c83
Showing
8 changed files
with
527 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/runtime_src/xdp/profile/plugin/aie_halt/CMakeLists.txt
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,41 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. | ||
# | ||
|
||
# ======================================================================= | ||
# This builds the AIE Halt Plugin to add Debug Halts for all AIE Cores at | ||
# the start. It is currently built on Client Windows Only. | ||
# ========================================================================= | ||
|
||
if (XDP_CLIENT_BUILD_CMAKE STREQUAL "yes") | ||
set(IMPL_DIR "${PROFILE_DIR}/plugin/aie_halt/clientDev") | ||
endif() | ||
|
||
|
||
file(GLOB XDP_AIE_HALT_PLUGIN_FILES | ||
"${PROFILE_DIR}/plugin/aie_halt/*.h" | ||
"${PROFILE_DIR}/plugin/aie_halt/*.cpp" | ||
"${IMPL_DIR}/*.h" | ||
"${IMPL_DIR}/*.cpp" | ||
) | ||
|
||
file(GLOB XDP_DEVICE_COMMON_FILES | ||
"${PROFILE_DIR}/device/common/*.h" | ||
"${PROFILE_DIR}/device/common/*.cpp" | ||
) | ||
|
||
if (XDP_CLIENT_BUILD_CMAKE STREQUAL "yes") | ||
add_library(xdp_aie_halt_plugin MODULE ${XDP_AIE_HALT_PLUGIN_FILES} ${XDP_DEVICE_COMMON_FILES}) | ||
add_dependencies(xdp_aie_halt_plugin xdp_core xrt_coreutil) | ||
target_link_libraries(xdp_aie_halt_plugin PRIVATE xdp_core xrt_coreutil xaiengine) | ||
target_compile_definitions(xdp_aie_halt_plugin PRIVATE XDP_CLIENT_BUILD=1 -DXAIE_FEATURE_MSVC) | ||
target_include_directories(xdp_aie_halt_plugin PRIVATE ${AIERT_DIR}/include) | ||
set_target_properties(xdp_aie_halt_plugin PROPERTIES VERSION ${XRT_VERSION_STRING} SOVERSION ${XRT_SOVERSION}) | ||
|
||
install (TARGETS xdp_aie_halt_plugin | ||
LIBRARY DESTINATION ${XDP_PLUGIN_INSTALL_DIR} | ||
) | ||
|
||
# Else, on edge-aarch64 don't build at all | ||
|
||
endif() |
52 changes: 52 additions & 0 deletions
52
src/runtime_src/xdp/profile/plugin/aie_halt/aie_halt_cb.cpp
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,52 @@ | ||
/** | ||
* Copyright (C) 2024 Advanced Micro Devices, Inc. - All rights reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
* not use this file except in compliance with the License. A copy of the | ||
* License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#define XDP_PLUGIN_SOURCE | ||
|
||
#include "xdp/profile/plugin/aie_halt/aie_halt_cb.h" | ||
#include "xdp/profile/plugin/aie_halt/aie_halt_plugin.h" | ||
|
||
namespace xdp { | ||
|
||
static AIEHaltPlugin aieHaltPluginInstance; | ||
|
||
static void updateDeviceAIEHalt(void* hwCtxImpl) | ||
{ | ||
if (AIEHaltPlugin::alive()) { | ||
aieHaltPluginInstance.updateDevice(hwCtxImpl); | ||
} | ||
} | ||
|
||
static void finishflushDeviceAIEHalt(void* hwCtxImpl) | ||
{ | ||
if (AIEHaltPlugin::alive()) { | ||
aieHaltPluginInstance.finishflushDevice(hwCtxImpl); | ||
} | ||
} | ||
|
||
} // end namespace xdp | ||
|
||
extern "C" | ||
void updateDeviceAIEHalt(void* hwCtxImpl) | ||
{ | ||
xdp::updateDeviceAIEHalt(hwCtxImpl); | ||
} | ||
|
||
extern "C" | ||
void finishflushDeviceAIEHalt(void* hwCtxImpl) | ||
{ | ||
xdp::finishflushDeviceAIEHalt(hwCtxImpl); | ||
} |
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,28 @@ | ||
/** | ||
* Copyright (C) 2024 Advanced Micro Devices, Inc. - All rights reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
* not use this file except in compliance with the License. A copy of the | ||
* License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef XDP_PLUGIN_AIE_HALT_CB_H | ||
#define XDP_PLUGIN_AIE_HALT_CB_H | ||
|
||
#include "xdp/config.h" | ||
|
||
extern "C" { | ||
|
||
XDP_PLUGIN_EXPORT void updateDeviceAIEHalt(void* hwCtxImpl); | ||
XDP_PLUGIN_EXPORT void finishflushDeviceAIEHalt(void* hwCtxImpl); | ||
|
||
} | ||
#endif |
51 changes: 51 additions & 0 deletions
51
src/runtime_src/xdp/profile/plugin/aie_halt/aie_halt_impl.h
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,51 @@ | ||
/** | ||
* Copyright (C) 2024 Advanced Micro Devices, Inc. - All rights reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
* not use this file except in compliance with the License. A copy of the | ||
* License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef XDP_PLUGIN_AIE_HALT_IMPL_H | ||
#define XDP_PLUGIN_AIE_HALT_IMPL_H | ||
|
||
#include "core/include/xrt/xrt_hw_context.h" | ||
|
||
namespace xdp { | ||
|
||
class VPDatabase; | ||
|
||
class AIEHaltImpl | ||
{ | ||
protected : | ||
VPDatabase* db = nullptr; | ||
xrt::hw_context mHwContext; | ||
|
||
public: | ||
AIEHaltImpl(VPDatabase* dB) | ||
: db(dB) | ||
{} | ||
|
||
AIEHaltImpl() = delete; | ||
|
||
virtual ~AIEHaltImpl() {} | ||
|
||
virtual void updateDevice(void*) = 0; | ||
virtual void finishflushDevice(void*) = 0; | ||
|
||
void setHwContext(xrt::hw_context ctx) | ||
{ | ||
mHwContext = std::move(ctx); | ||
} | ||
}; | ||
|
||
} | ||
#endif |
122 changes: 122 additions & 0 deletions
122
src/runtime_src/xdp/profile/plugin/aie_halt/aie_halt_plugin.cpp
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,122 @@ | ||
/** | ||
* Copyright (C) 2024 Advanced Micro Devices, Inc. - All rights reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
* not use this file except in compliance with the License. A copy of the | ||
* License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#define XDP_PLUGIN_SOURCE | ||
|
||
#include<regex> | ||
#include<string> | ||
|
||
#include "core/common/device.h" | ||
#include "core/common/message.h" | ||
#include "core/common/api/hw_context_int.h" | ||
|
||
#include "xdp/profile/plugin/aie_halt/aie_halt_plugin.h" | ||
#include "xdp/profile/plugin/vp_base/info.h" | ||
#include "xdp/profile/plugin/vp_base/utility.h" | ||
|
||
#ifdef XDP_CLIENT_BUILD | ||
#include "xdp/profile/plugin/aie_halt/clientDev/aie_halt.h" | ||
#endif | ||
|
||
namespace xdp { | ||
|
||
bool AIEHaltPlugin::live = false; | ||
|
||
AIEHaltPlugin::AIEHaltPlugin() | ||
: XDPPlugin() | ||
{ | ||
AIEHaltPlugin::live = true; | ||
|
||
db->registerPlugin(this); | ||
db->registerInfo(info::aie_halt); | ||
} | ||
|
||
AIEHaltPlugin::~AIEHaltPlugin() | ||
{ | ||
if (VPDatabase::alive()) { | ||
try { | ||
writeAll(false); | ||
} | ||
catch (...) { | ||
} | ||
db->unregisterPlugin(this); | ||
} | ||
|
||
AIEHaltPlugin::live = false; | ||
} | ||
|
||
bool AIEHaltPlugin::alive() | ||
{ | ||
return AIEHaltPlugin::live; | ||
} | ||
|
||
void AIEHaltPlugin::updateDevice(void* hwCtxImpl) | ||
{ | ||
#ifdef XDP_CLIENT_BUILD | ||
if (mHwCtxImpl) { | ||
// For client device flow, only 1 device and xclbin is supported now. | ||
return; | ||
} | ||
mHwCtxImpl = hwCtxImpl; | ||
|
||
xrt::hw_context hwContext = xrt_core::hw_context_int::create_hw_context_from_implementation(mHwCtxImpl); | ||
std::shared_ptr<xrt_core::device> coreDevice = xrt_core::hw_context_int::get_core_device(hwContext); | ||
|
||
// Only one device for Client Device flow | ||
uint64_t deviceId = db->addDevice("win_device"); | ||
(db->getStaticInfo()).updateDeviceClient(deviceId, coreDevice); | ||
(db->getStaticInfo()).setDeviceName(deviceId, "win_device"); | ||
|
||
DeviceDataEntry.valid = true; | ||
DeviceDataEntry.implementation = std::make_unique<AIEHaltClientDevImpl>(db); | ||
DeviceDataEntry.implementation->setHwContext(hwContext); | ||
DeviceDataEntry.implementation->updateDevice(mHwCtxImpl); | ||
#endif | ||
} | ||
|
||
void AIEHaltPlugin::finishflushDevice(void* hwCtxImpl) | ||
{ | ||
#ifdef XDP_CLIENT_BUILD | ||
if (!mHwCtxImpl || !DeviceDataEntry.valid) { | ||
return; | ||
} | ||
|
||
if (hwCtxImpl != mHwCtxImpl) { | ||
xrt_core::message::send(xrt_core::message::severity_level::debug, "XRT", | ||
"New Hw Context Impl passed in AIE Halt Plugin."); | ||
return; | ||
} | ||
|
||
DeviceDataEntry.valid = false; | ||
DeviceDataEntry.implementation->finishflushDevice(mHwCtxImpl); | ||
#endif | ||
} | ||
|
||
void AIEHaltPlugin::writeAll(bool /*openNewFiles*/) | ||
{ | ||
#ifdef XDP_CLIENT_BUILD | ||
|
||
if (!mHwCtxImpl || !DeviceDataEntry.valid) { | ||
return; | ||
} | ||
|
||
// For client device flow, only 1 device and xclbin is supported now. | ||
DeviceDataEntry.valid = false; | ||
DeviceDataEntry.implementation->finishflushDevice(mHwCtxImpl); | ||
#endif | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/runtime_src/xdp/profile/plugin/aie_halt/aie_halt_plugin.h
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,54 @@ | ||
/** | ||
* Copyright (C) 2024 Advanced Micro Devices, Inc. - All rights reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
* not use this file except in compliance with the License. A copy of the | ||
* License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#ifndef XDP_AIE_HALT_PLUGIN_H | ||
#define XDP_AIE_HALT_PLUGIN_H | ||
|
||
#include "xdp/profile/plugin/aie_halt/aie_halt_impl.h" | ||
#include "xdp/profile/plugin/vp_base/vp_base_plugin.h" | ||
|
||
|
||
namespace xdp { | ||
|
||
class AIEHaltPlugin : public XDPPlugin | ||
{ | ||
public: | ||
|
||
AIEHaltPlugin(); | ||
~AIEHaltPlugin(); | ||
|
||
void updateDevice(void* hwCtxImpl); | ||
void finishflushDevice(void* hwCtxImpl); | ||
|
||
void writeAll(bool); | ||
|
||
static bool alive(); | ||
|
||
private: | ||
static bool live; | ||
|
||
struct DeviceData { | ||
bool valid; | ||
std::unique_ptr<AIEHaltImpl> implementation; | ||
} DeviceDataEntry; | ||
|
||
void* mHwCtxImpl = nullptr; | ||
|
||
}; | ||
|
||
} // end namespace xdp | ||
|
||
#endif |
Oops, something went wrong.