From 793c0382f5f17fd92f404747bcb7b64367f47953 Mon Sep 17 00:00:00 2001 From: Yiannis Papadopoulos <102817138+ypapadop-amd@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:03:51 -0400 Subject: [PATCH] Avoid incorrect casting (#24) --- .../core/runtime/amd_aie_aql_queue.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/amd_aie_aql_queue.cpp b/runtime/hsa-runtime/core/runtime/amd_aie_aql_queue.cpp index 50229daf4..6f796441a 100644 --- a/runtime/hsa-runtime/core/runtime/amd_aie_aql_queue.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_aie_aql_queue.cpp @@ -76,8 +76,8 @@ constexpr int DEV_ADDR_OFFSET_MASK = 0x02FFFFFF; // https://github.com/amd/xdna-driver/blob/main/src/driver/amdxdna/aie2_message.c#L637 constexpr int CMD_COUNT_SIZE_INCREASE = 3; -// Index of command payload where the instruction sequence -// address is located +// Index of command payload where the instruction sequence +// address is located constexpr int CMD_PKT_PAYLOAD_INSTRUCTION_SEQUENCE_IDX = 2; // Environment variable to define job submission timeout @@ -219,16 +219,15 @@ uint64_t AieAqlQueue::AddWriteIndexAcqRel(uint64_t value) { void AieAqlQueue::StoreRelaxed(hsa_signal_value_t value) { std::unordered_map vmem_handle_mappings; - if (reinterpret_cast( - core::Runtime::runtime_singleton_->AgentDriver(agent_.driver_type)) - .GetHandleMappings(vmem_handle_mappings) != HSA_STATUS_SUCCESS) { + + auto &driver = static_cast( + core::Runtime::runtime_singleton_->AgentDriver(agent_.driver_type)); + if (driver.GetHandleMappings(vmem_handle_mappings) != HSA_STATUS_SUCCESS) { return; } int fd = 0; - if (reinterpret_cast( - core::Runtime::runtime_singleton_->AgentDriver(agent_.driver_type)) - .GetFd(fd) != HSA_STATUS_SUCCESS) { + if (driver.GetFd(fd) != HSA_STATUS_SUCCESS) { return; } @@ -257,7 +256,7 @@ hsa_status_t AieAqlQueue::ExecCmdAndWait(amdxdna_drm_exec_cmd *exec_cmd, // Waiting for command to finish amdxdna_drm_wait_cmd wait_cmd = {}; wait_cmd.hwctx = hw_ctx_handle; - wait_cmd.timeout = timeout_val; + wait_cmd.timeout = timeout_val; wait_cmd.seq = exec_cmd->seq; if (ioctl(fd, DRM_IOCTL_AMDXDNA_WAIT_CMD, &wait_cmd)) @@ -278,7 +277,8 @@ void AieAqlQueue::RegisterCmdBOs( uint32_t num_operands = (count - NON_OPERAND_COUNT) / 2; // Keep track of the handles before we submit the packet - bo_args.push_back(cmd_pkt_payload->data[CMD_PKT_PAYLOAD_INSTRUCTION_SEQUENCE_IDX]); + bo_args.push_back( + cmd_pkt_payload->data[CMD_PKT_PAYLOAD_INSTRUCTION_SEQUENCE_IDX]); // Going through all of the operands in the command, keeping track of the // handles and turning the handles into addresses. The starting index of