-
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.
Create common utilities folder for XDP plugins that use the AIE driver (
- Loading branch information
1 parent
2215092
commit 23d66ef
Showing
30 changed files
with
345 additions
and
670 deletions.
There are no files selected for viewing
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
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
43 changes: 43 additions & 0 deletions
43
src/runtime_src/xdp/profile/device/common/aie_driver_common_util.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,43 @@ | ||
/** | ||
* Copyright (C) 2022-2023 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 "aie_driver_common_util.h" | ||
#include "xdp/profile/database/static_info/aie_util.h" | ||
|
||
#include <boost/algorithm/string.hpp> | ||
#include <cmath> | ||
#include <cstring> | ||
#include <iostream> | ||
#include <memory> | ||
#include <regex> | ||
#include <set> | ||
|
||
extern "C" { | ||
#include <xaiengine.h> | ||
#include <xaiengine/xaiegbl_params.h> | ||
} | ||
|
||
#include "core/common/message.h" | ||
|
||
// *************************************************************** | ||
// Anonymous namespace for helper functions local to this file | ||
// *************************************************************** | ||
namespace xdp::aie { | ||
using severity_level = xrt_core::message::severity_level; | ||
|
||
} // namespace xdp::aie |
35 changes: 35 additions & 0 deletions
35
src/runtime_src/xdp/profile/device/common/aie_driver_common_util.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,35 @@ | ||
/** | ||
* Copyright (C) 2022-2023 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_DRIVER_COMMON_UTIL_DOT_H | ||
#define AIE_DRIVER_COMMON_UTIL_DOT_H | ||
|
||
#include <cstdint> | ||
#include "xdp/profile/database/static_info/aie_constructs.h" | ||
|
||
namespace xdp::aie { | ||
/** | ||
* @brief Get metric sets for core modules | ||
* @details Depending on hardware generation, these sets can be supplemented | ||
* with counter events as those are dependent on counter #. | ||
* @return Map of metric set names with vectors of event IDs | ||
*/ | ||
// std::map<std::string, std::vector<XAie_Events>> getCoreEventSets(); | ||
|
||
|
||
} // namespace xdp::aie | ||
|
||
#endif |
101 changes: 101 additions & 0 deletions
101
src/runtime_src/xdp/profile/device/common/client_transaction.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,101 @@ | ||
/** | ||
* Copyright (C) 2022-2023 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 <sstream> | ||
|
||
#include "client_transaction.h" | ||
#include "core/common/message.h" | ||
|
||
#include "transactions/op_types.h" | ||
#include "transactions/op_buf.hpp" | ||
#include "transactions/op_init.hpp" | ||
|
||
extern "C" { | ||
#include <xaiengine.h> | ||
#include <xaiengine/xaiegbl_params.h> | ||
} | ||
|
||
// *************************************************************** | ||
// Anonymous namespace for helper functions local to this file | ||
// *************************************************************** | ||
namespace xdp::aie { | ||
using severity_level = xrt_core::message::severity_level; | ||
static constexpr uint32_t size_4K = 0x1000; | ||
constexpr std::uint64_t CONFIGURE_OPCODE = std::uint64_t{2}; | ||
|
||
bool | ||
ClientTransaction::initializeKernel(std::string kernelName) | ||
{ | ||
try { | ||
kernel = xrt::kernel(context, kernelName); | ||
} catch (std::exception &e){ | ||
std::stringstream msg; | ||
msg << "Unable to find " << kernelName << " kernel from hardware context. Failed to configure " << transactionName << ". " << e.what(); | ||
xrt_core::message::send(severity_level::warning, "XRT", msg.str()); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool | ||
ClientTransaction::submitTransaction(uint8_t* txn_ptr) { | ||
op_buf instr_buf; | ||
instr_buf.addOP(transaction_op(txn_ptr)); | ||
xrt::bo instr_bo; | ||
|
||
// Configuration bo | ||
try { | ||
instr_bo = xrt::bo(context.get_device(), instr_buf.ibuf_.size(), XCL_BO_FLAGS_CACHEABLE, kernel.group_id(1)); | ||
} catch (std::exception &e){ | ||
std::stringstream msg; | ||
msg << "Unable to create instruction buffer for " << transactionName << " transaction. Unable to configure " << transactionName<< ". " << e.what() << std::endl; | ||
xrt_core::message::send(severity_level::warning, "XRT", msg.str()); | ||
return false; | ||
} | ||
|
||
instr_bo.write(instr_buf.ibuf_.data()); | ||
instr_bo.sync(XCL_BO_SYNC_BO_TO_DEVICE); | ||
auto run = kernel(CONFIGURE_OPCODE, instr_bo, instr_bo.size()/sizeof(int), 0, 0, 0, 0); | ||
run.wait2(); | ||
|
||
xrt_core::message::send(severity_level::info, "XRT","Successfully scheduled " + transactionName + " instruction buffer."); | ||
return true; | ||
} | ||
|
||
xrt::bo | ||
ClientTransaction::syncResults() { | ||
// results BO syncs profile result from device | ||
xrt::bo result_bo; | ||
try { | ||
result_bo = xrt::bo(context.get_device(), size_4K, XCL_BO_FLAGS_CACHEABLE, kernel.group_id(1)); | ||
} catch (std::exception &e) { | ||
std::stringstream msg; | ||
msg << "Unable to create result buffer for " << transactionName << ". Cannot get " << transactionName << " Results." << e.what() << std::endl; | ||
xrt_core::message::send(xrt_core::message::severity_level::warning, "XRT", msg.str()); | ||
return nullptr; | ||
} | ||
|
||
result_bo.sync(XCL_BO_SYNC_BO_FROM_DEVICE); | ||
|
||
return result_bo; | ||
} | ||
|
||
|
||
|
||
} // namespace xdp::aie |
43 changes: 43 additions & 0 deletions
43
src/runtime_src/xdp/profile/device/common/client_transaction.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,43 @@ | ||
/** | ||
* Copyright (C) 2022-2023 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 CLIENT_TRANSACTION_DOT_H | ||
#define CLIENT_TRANSACTION_DOT_H | ||
|
||
#include <cstdint> | ||
#include <string> | ||
|
||
#include "core/include/xrt/xrt_hw_context.h" | ||
#include "core/include/xrt/xrt_kernel.h" | ||
|
||
namespace xdp::aie { | ||
class ClientTransaction { | ||
public: | ||
ClientTransaction(xrt::hw_context c, std::string tName) : context(c), transactionName(tName) {} | ||
bool initializeKernel(std::string kernelName); | ||
bool submitTransaction(uint8_t* txn_ptr); | ||
xrt::bo syncResults(); | ||
void setTransactionName(std::string newTransactionName) {transactionName = newTransactionName;} | ||
int getGroupID(int id) {return kernel.group_id(id); } | ||
private: | ||
std::string transactionName; | ||
xrt::kernel kernel; | ||
xrt::hw_context context; | ||
}; | ||
|
||
} // namespace xdp::aie | ||
|
||
#endif |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.