Skip to content

Commit

Permalink
AIE Profiling Plugin Refactor (Xilinx#7197)
Browse files Browse the repository at this point in the history
  • Loading branch information
nishraptor authored Dec 2, 2022
1 parent 35202df commit e3c362d
Show file tree
Hide file tree
Showing 13 changed files with 1,964 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/runtime_src/xdp/profile/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (NOT WIN32)
# The plugins to be built on Linux only
# =========================================================
add_subdirectory(aie_debug)
add_subdirectory(aie_profile)
add_subdirectory(aie_profile_new)
add_subdirectory(aie_trace_new)
add_subdirectory(device_offload/hw_emu)
add_subdirectory(noc)
Expand Down
29 changes: 0 additions & 29 deletions src/runtime_src/xdp/profile/plugin/aie_profile/CMakeLists.txt

This file was deleted.

51 changes: 51 additions & 0 deletions src/runtime_src/xdp/profile/plugin/aie_profile_new/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
#

# ====================================================================
# This builds the AIE Profile plugin. It is currently built
# on both Edge and x86 platforms that support AIE.
# ====================================================================

if (${XRT_NATIVE_BUILD} STREQUAL "yes")
set(IMPL_DIR "${PROFILE_DIR}/plugin/aie_profile_new/x86")
elseif (DEFINED XRT_AIE_BUILD AND ${XRT_NATIVE_BUILD} STREQUAL "no")
set(IMPL_DIR "${PROFILE_DIR}/plugin/aie_profile_new/edge")
endif()

file(GLOB AIE_PROFILE_PLUGIN_FILES
"${PROFILE_DIR}/plugin/aie_profile_new/*.h"
"${PROFILE_DIR}/plugin/aie_profile_new/*.cpp"
"${PROFILE_DIR}/writer/aie_profile/*.h"
"${PROFILE_DIR}/writer/aie_profile/*.cpp"
"${IMPL_DIR}/*.h"
"${IMPL_DIR}/*.cpp"
)

if (${XRT_NATIVE_BUILD} STREQUAL "yes")

add_library(xdp_aie_profile_plugin MODULE ${AIE_PROFILE_PLUGIN_FILES})
add_dependencies(xdp_aie_profile_plugin xdp_core xrt_core)
target_link_libraries(xdp_aie_profile_plugin PRIVATE xdp_core xrt_core)
target_compile_definitions(xdp_aie_profile_plugin PRIVATE XRT_X86_BUILD=1)

set_target_properties(xdp_aie_profile_plugin PROPERTIES VERSION ${XRT_VERSION_STRING} SOVERSION ${XRT_SOVERSION})

install (TARGETS xdp_aie_profile_plugin
LIBRARY DESTINATION ${XDP_PLUGIN_INSTALL_DIR}
)

elseif (DEFINED XRT_AIE_BUILD AND ${XRT_NATIVE_BUILD} STREQUAL "no")
add_library(xdp_aie_profile_plugin MODULE ${AIE_PROFILE_PLUGIN_FILES})

add_dependencies(xdp_aie_profile_plugin xdp_core xrt_core)
target_link_libraries(xdp_aie_profile_plugin PRIVATE xdp_core xrt_core metal xaiengine)
set_target_properties(xdp_aie_profile_plugin PROPERTIES VERSION ${XRT_VERSION_STRING} SOVERSION ${XRT_SOVERSION})

install (TARGETS xdp_aie_profile_plugin
LIBRARY DESTINATION ${XDP_PLUGIN_INSTALL_DIR}
)

# Else, on edge-aarch64 don't build at all

endif()
47 changes: 47 additions & 0 deletions src/runtime_src/xdp/profile/plugin/aie_profile_new/aie_cb.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (C) 2022 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.
*/

#include "aie_profile_plugin.h"

namespace xdp {

static AieProfilePlugin aieProfilePluginInstance;

static void updateAIECtrDevice(void* handle)
{
if (AieProfilePlugin::alive())
aieProfilePluginInstance.updateAIEDevice(handle);
}

static void endAIECtrPoll(void* handle)
{
if (AieProfilePlugin::alive())
aieProfilePluginInstance.endPollforDevice(handle);
}

} // end namespace xdp

extern "C"
void updateAIECtrDevice(void* handle)
{
xdp::updateAIECtrDevice(handle);
}

extern "C"
void endAIECtrPoll(void* handle)
{
xdp::endAIECtrPoll(handle);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright (C) 2022 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 AIE_PROFILE_IMPL_H
#define AIE_PROFILE_IMPL_H

#include "xdp/profile/plugin/vp_base/vp_base_plugin.h"
#include "aie_profile_metadata.h"

namespace xdp {

// AIE profile configurations can be done in different ways depending
// on the platform. For example, platforms like the VCK5000 or
// discovery platform, where the host code runs on the x86 and the AIE
// is not directly accessible, will require configuration be done via
// PS kernel.
class AieProfileImpl
{

protected:
VPDatabase* db = nullptr;
std::shared_ptr<AieProfileMetadata> metadata;

public:
AieProfileImpl(VPDatabase* database, std::shared_ptr<AieProfileMetadata> metadata)
:db(database), metadata(metadata) {}

AieProfileImpl() = delete;
virtual ~AieProfileImpl() {};

virtual void updateDevice() = 0;
virtual void poll(uint32_t index, void* handle) = 0;
};

} // namespace xdp

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright (C) 2022 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.
*/

#include <boost/algorithm/string.hpp>

#include "core/common/config_reader.h"
#include "core/common/message.h"
#include "aie_profile_metadata.h"

namespace xdp {
using severity_level = xrt_core::message::severity_level;

AieProfileMetadata::AieProfileMetadata(uint64_t deviceID, void* handle)
: deviceID(deviceID)
, handle(handle)
{}

void AieProfileMetadata::parsePollingInterval()
{
// Get polling interval (in usec; minimum is 100)
mPollingInterval = xrt_core::config::get_aie_profile_settings_interval_us();
if (1000 == mPollingInterval) {
// If set to default value, then check for old style config
mPollingInterval = xrt_core::config::get_aie_profile_interval_us();
if (1000 != mPollingInterval) {
xrt_core::message::send(severity_level::warning, "XRT",
"The xrt.ini flag \"aie_profile_interval_us\" is deprecated and will be removed in future release. Please use \"interval_us\" under \"AIE_profile_settings\" section.");
}
}
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (C) 2022 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 AIE_PROFILE_METADATA_H
#define AIE_PROFILE_METADATA_H

namespace xdp {

class AieProfileMetadata{

public:
AieProfileMetadata(uint64_t deviceID, void* handle);
void parsePollingInterval();

uint64_t getDeviceID() {return deviceID;}
void* getHandle() {return handle;}
uint32_t getPollingIntervalVal(){return mPollingInterval;}

private:
uint32_t mIndex = 0;
uint32_t mPollingInterval;
uint64_t deviceID;
void* handle;
};
}

#endif
Loading

0 comments on commit e3c362d

Please sign in to comment.