From c343a9dc6069c217a81ed4e840c862dbcc870378 Mon Sep 17 00:00:00 2001 From: Yiannis Papadopoulos Date: Sat, 7 Dec 2024 00:04:54 +0000 Subject: [PATCH] rocr/aie: Add AIEAgent missing info Change-Id: I32e9acc7b8b7dee4e9ff5524fec5c440bb8ece0e --- .../core/runtime/amd_aie_agent.cpp | 87 +++++++++++++++++-- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/amd_aie_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_aie_agent.cpp index 5cd42be45a..7b11dc7cbd 100644 --- a/runtime/hsa-runtime/core/runtime/amd_aie_agent.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_aie_agent.cpp @@ -3,7 +3,7 @@ // The University of Illinois/NCSA // Open Source License (NCSA) // -// Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved. +// Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved. // // Developed by: // @@ -42,7 +42,9 @@ #include "core/inc/amd_aie_agent.h" +#include #include +#include #include "core/inc/amd_aie_aql_queue.h" #include "core/inc/amd_memory_region.h" @@ -108,13 +110,19 @@ hsa_status_t AieAgent::GetInfo(hsa_agent_info_t attribute, void *value) const { switch (attribute_) { case HSA_AGENT_INFO_NAME: { - std::string name_info_("aie2"); - std::strcpy(reinterpret_cast(value), name_info_.c_str()); + const std::string name_info_("aie2"); + assert(name_info_.size() < HSA_PUBLIC_NAME_SIZE); + std::memset(value, 0, HSA_PUBLIC_NAME_SIZE); + std::strncat(reinterpret_cast(value), name_info_.c_str(), + name_info_.size()); break; } case HSA_AGENT_INFO_VENDOR_NAME: { - std::string vendor_name_info_("AMD"); - std::strcpy(reinterpret_cast(value), vendor_name_info_.c_str()); + const std::string vendor_name_info_("AMD"); + assert(vendor_name_info_.size() < HSA_PUBLIC_NAME_SIZE); + std::memset(value, 0, HSA_PUBLIC_NAME_SIZE); + std::strncat(reinterpret_cast(value), vendor_name_info_.c_str(), + vendor_name_info_.size()); break; } case HSA_AGENT_INFO_FEATURE: @@ -123,14 +131,30 @@ hsa_status_t AieAgent::GetInfo(hsa_agent_info_t attribute, void *value) const { case HSA_AGENT_INFO_MACHINE_MODEL: *reinterpret_cast(value) = HSA_MACHINE_MODEL_LARGE; break; + case HSA_AGENT_INFO_BASE_PROFILE_DEFAULT_FLOAT_ROUNDING_MODES: + case HSA_AGENT_INFO_DEFAULT_FLOAT_ROUNDING_MODE: + // TODO: validate if this is true. + *reinterpret_cast(value) = + HSA_DEFAULT_FLOAT_ROUNDING_MODE_NEAR; + break; case HSA_AGENT_INFO_PROFILE: *reinterpret_cast(value) = profile_; break; case HSA_AGENT_INFO_WAVEFRONT_SIZE: + *reinterpret_cast(value) = 0; + break; case HSA_AGENT_INFO_WORKGROUP_MAX_DIM: + std::memset(value, 0, sizeof(uint16_t) * 3); + break; case HSA_AGENT_INFO_WORKGROUP_MAX_SIZE: + *reinterpret_cast(value) = 0; + break; case HSA_AGENT_INFO_GRID_MAX_DIM: + std::memset(value, 0, sizeof(uint16_t) * 3); + break; case HSA_AGENT_INFO_GRID_MAX_SIZE: + *reinterpret_cast(value) = 0; + break; case HSA_AGENT_INFO_FBARRIER_MAX_SIZE: *reinterpret_cast(value) = 0; break; @@ -161,6 +185,36 @@ hsa_status_t AieAgent::GetInfo(hsa_agent_info_t attribute, void *value) const { case HSA_AGENT_INFO_VERSION_MINOR: *reinterpret_cast(value) = 0; break; + case HSA_AMD_AGENT_INFO_CHIP_ID: + *reinterpret_cast(value) = 0; + break; + case HSA_AMD_AGENT_INFO_CACHELINE_SIZE: + *reinterpret_cast(value) = 0; + break; + case HSA_AMD_AGENT_INFO_COMPUTE_UNIT_COUNT: + *reinterpret_cast(value) = 0; + break; + case HSA_AMD_AGENT_INFO_MAX_CLOCK_FREQUENCY: + *reinterpret_cast(value) = 0; + break; + case HSA_AMD_AGENT_INFO_DRIVER_NODE_ID: + *reinterpret_cast(value) = node_id(); + break; + case HSA_AMD_AGENT_INFO_MAX_ADDRESS_WATCH_POINTS: + *reinterpret_cast(value) = 0; + break; + case HSA_AMD_AGENT_INFO_BDFID: + *reinterpret_cast(value) = 0; + break; + case HSA_AMD_AGENT_INFO_NUM_SIMDS_PER_CU: + *reinterpret_cast(value) = 0; + break; + case HSA_AMD_AGENT_INFO_NUM_SHADER_ENGINES: + *reinterpret_cast(value) = 0; + break; + case HSA_AMD_AGENT_INFO_NUM_SHADER_ARRAYS_PER_SE: + *reinterpret_cast(value) = 0; + break; case HSA_EXT_AGENT_INFO_IMAGE_1D_MAX_ELEMENTS: case HSA_EXT_AGENT_INFO_IMAGE_1DA_MAX_ELEMENTS: case HSA_EXT_AGENT_INFO_IMAGE_1DB_MAX_ELEMENTS: @@ -173,10 +227,29 @@ hsa_status_t AieAgent::GetInfo(hsa_agent_info_t attribute, void *value) const { *reinterpret_cast(value) = 0; break; case HSA_AMD_AGENT_INFO_PRODUCT_NAME: { - std::string product_name_info_("AIE-ML"); - std::strcpy(reinterpret_cast(value), product_name_info_.c_str()); + const std::string product_name_info_("AIE-ML"); + assert(product_name_info_.size() < HSA_PUBLIC_NAME_SIZE); + std::memset(value, 0, HSA_PUBLIC_NAME_SIZE); + std::strncat(reinterpret_cast(value), product_name_info_.c_str(), + product_name_info_.size()); break; } + case HSA_AMD_AGENT_INFO_UUID: { + // At this point AIE devices do not support UUID's. + char uuid_tmp[] = "AIE-XX"; + snprintf((char *)value, sizeof(uuid_tmp), "%s", uuid_tmp); + break; + } + case HSA_AMD_AGENT_INFO_ASIC_REVISION: + *reinterpret_cast(value) = 0; + break; + case HSA_AMD_AGENT_INFO_SVM_DIRECT_HOST_ACCESS: + assert(regions_.size() != 0 && "No device local memory found!"); + *reinterpret_cast(value) = true; + break; + case HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES: + std::memset(value, 0, sizeof(uint8_t) * 8); + break; default: *reinterpret_cast(value) = 0; return HSA_STATUS_ERROR_INVALID_ARGUMENT;