Skip to content

Commit

Permalink
Correct Freq store & fetch (#8434)
Browse files Browse the repository at this point in the history
  • Loading branch information
vipangul authored Sep 19, 2024
1 parent 53775ee commit d3427d5
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 9 deletions.
12 changes: 12 additions & 0 deletions src/runtime_src/xdp/profile/database/static_info/aie_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ namespace xdp::aie {
return *hwGen;
}

// On Edge devices, AIE clock frequency shouldn't change once execution has started.
// On Client devices, this static information from metadata may not be correct.
double getAIEClockFreqMHz(const boost::property_tree::ptree& aie_meta,
const std::string& root)
{
static std::optional<double> clockFreqMHz;
if (!clockFreqMHz.has_value()) {
clockFreqMHz = aie_meta.get_child(root).get_value<double>();
}
return *clockFreqMHz;
}

/****************************************************************************
* Get metadata required to configure driver
***************************************************************************/
Expand Down
12 changes: 8 additions & 4 deletions src/runtime_src/xdp/profile/database/static_info/aie_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,26 @@ namespace xdp::aie {

XDP_CORE_EXPORT
int getHardwareGeneration(const boost::property_tree::ptree& aie_meta,
const std::string& root);
const std::string& root);

XDP_CORE_EXPORT
double getAIEClockFreqMHz(const boost::property_tree::ptree& aie_meta,
const std::string& root);

XDP_CORE_EXPORT
xdp::aie::driver_config
getDriverConfig(const boost::property_tree::ptree& aie_meta,
const std::string& root);
const std::string& root);

XDP_CORE_EXPORT
uint8_t
getAIETileRowOffset(const boost::property_tree::ptree& aie_meta,
const std::string& location);
const std::string& location);

XDP_CORE_EXPORT
std::vector<std::string>
getValidGraphs(const boost::property_tree::ptree& aie_meta,
const std::string& root);
const std::string& root);

XDP_CORE_EXPORT
bool isInfoVerbosity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ AIEControlConfigFiletype::getHardwareGeneration() const
return xdp::aie::getHardwareGeneration(aie_meta, "aie_metadata.driver_config.hw_gen");
}

double
AIEControlConfigFiletype::getAIEClockFreqMHz() const
{
return xdp::aie::getAIEClockFreqMHz(aie_meta, "aie_metadata.DeviceData.AIEFrequency");
}

aiecompiler_options
AIEControlConfigFiletype::getAIECompilerOptions() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class AIEControlConfigFiletype : public xdp::aie::BaseFiletypeImpl {

int getHardwareGeneration() const override;

double getAIEClockFreqMHz() const override;

aiecompiler_options
getAIECompilerOptions() const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class BaseFiletypeImpl {
getDriverConfig() const = 0;

virtual int getHardwareGeneration() const = 0;
virtual double getAIEClockFreqMHz() const = 0;

virtual aiecompiler_options
getAIECompilerOptions() const = 0;
Expand Down
21 changes: 16 additions & 5 deletions src/runtime_src/xdp/profile/database/static_info_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,16 @@ namespace xdp {
if (nullptr == device)
return;

auto xclbin_slot_info = xrt_core::device_query<xrt_core::query::xclbin_slots>(device.get());
std::vector<xrt_core::query::xclbin_slots::slot_info> xclbin_slot_info;
try {
xclbin_slot_info = xrt_core::device_query<xrt_core::query::xclbin_slots>(device.get());
}
catch (const std::exception& e) {
std::stringstream msg;
msg << "Exception occured while retrieving loaded xclbin info: " << e.what();
xrt_core::message::send(xrt_core::message::severity_level::debug, "XRT", msg.str());
}

if (xclbin_slot_info.empty())
return;
xrt::uuid new_xclbin_uuid = xrt::uuid(xclbin_slot_info.back().uuid);
Expand Down Expand Up @@ -2330,7 +2339,6 @@ namespace xdp {
if (readAIEdata) {
readAIEMetadata(xrtXclbin, clientBuild);
setAIEGeneration(deviceId, xrtXclbin);
setAIEClockRateMHz(deviceId, xrtXclbin);
}

/* Configure AMs if context monitoring is supported
Expand All @@ -2346,6 +2354,10 @@ namespace xdp {
}

devInfo->createConfig(currentXclbin);

// Following functions require configInfo to be created first.
if (readAIEdata)
setAIEClockRateMHz(deviceId, xrtXclbin);
initializeProfileMonitors(devInfo, xrtXclbin);

devInfo->isReady = true;
Expand Down Expand Up @@ -2436,7 +2448,7 @@ namespace xdp {
return;

try {
auto hwGen = aieMetadata.get_child("aie_metadata.driver_config.hw_gen").get_value<uint8_t>();
auto hwGen = metadataReader->getHardwareGeneration();
deviceInfo[deviceId]->setAIEGeneration(hwGen);
} catch(...) {
return;
Expand All @@ -2460,8 +2472,7 @@ namespace xdp {
return;

try {
auto dev_node = aieMetadata.get_child("aie_metadata.DeviceData");
xclbin->aie.clockRateAIEMHz = dev_node.get<double>("AIEFrequency");
xclbin->aie.clockRateAIEMHz = metadataReader->getAIEClockFreqMHz();
xrt_core::message::send(xrt_core::message::severity_level::info, "XRT", "read clockRateAIEMHz: "
+ std::to_string(xclbin->aie.clockRateAIEMHz));
} catch(...) {
Expand Down

0 comments on commit d3427d5

Please sign in to comment.