From 471896ac9fa4d878b02b936721058ad23db09d41 Mon Sep 17 00:00:00 2001 From: Sonal Santan Date: Sat, 20 Apr 2024 15:11:24 -0700 Subject: [PATCH] Silence C++ [[nodiscard]] warning (#8090) * Silence C++ [[nodiscard]] warning Add a note about new air-pdi-transform component Signed-off-by: Sonal Santan * Resolve a few additional clang-tidy warnings Signed-off-by: Sonal Santan * Let compiler manage the type of auto Signed-off-by: Sonal Santan --------- Signed-off-by: Sonal Santan --- src/.clang-tidy | 1 + src/runtime_src/hip/api/hip_context.cpp | 3 +-- src/runtime_src/hip/api/hip_device.cpp | 3 +-- src/runtime_src/hip/core/memory.cpp | 18 +++++++++--------- .../xclbinutil/aie-pdi-transform/README.rst | 11 +++++++++++ 5 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 src/runtime_src/tools/xclbinutil/aie-pdi-transform/README.rst diff --git a/src/.clang-tidy b/src/.clang-tidy index d755ab97eee..4db9e0a70f4 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -17,6 +17,7 @@ hicpp-*, -hicpp-signed-bitwise, modernize-*, -modernize-use-trailing-return-type, +-modernize-use-nodiscard, -cppcoreguidelines-pro-bounds-pointer-arithmetic, -cppcoreguidelines-pro-type-union-access, -cppcoreguidelines-pro-bounds-array-to-pointer-decay, diff --git a/src/runtime_src/hip/api/hip_context.cpp b/src/runtime_src/hip/api/hip_context.cpp index 8d99822a9b4..fc91e0fc30c 100644 --- a/src/runtime_src/hip/api/hip_context.cpp +++ b/src/runtime_src/hip/api/hip_context.cpp @@ -169,7 +169,7 @@ hipCtxGetDevice(hipDevice_t* device) try { throw_invalid_value_if(!device, "device passed is nullptr"); - *device = xrt::core::hip::hip_ctx_get_device(); + *device = static_cast(xrt::core::hip::hip_ctx_get_device()); return hipSuccess; } catch (const xrt_core::system_error& ex) { @@ -235,4 +235,3 @@ hipDevicePrimaryCtxRelease(hipDevice_t dev) } return hipErrorUnknown; } - diff --git a/src/runtime_src/hip/api/hip_device.cpp b/src/runtime_src/hip/api/hip_device.cpp index e133d0f546d..32011da8fb1 100644 --- a/src/runtime_src/hip/api/hip_device.cpp +++ b/src/runtime_src/hip/api/hip_device.cpp @@ -21,7 +21,7 @@ std::once_flag device_init_flag; // Creates devices at library load // User may not explicitly call init or device create -struct X { +const struct X { X() { try { @@ -261,4 +261,3 @@ hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device) } return hipErrorUnknown; } - diff --git a/src/runtime_src/hip/core/memory.cpp b/src/runtime_src/hip/core/memory.cpp index d381a5ab55a..cc0275f8766 100644 --- a/src/runtime_src/hip/core/memory.cpp +++ b/src/runtime_src/hip/core/memory.cpp @@ -37,7 +37,7 @@ namespace xrt::core::hip { assert(m_device); - // TODO: useptr is not supported in NPU. + // TODO: useptr is not supported in NPU. auto xrt_device = m_device->get_xrt_device(); m_bo = xrt::ext::bo(xrt_device, host_mem, m_size); } @@ -59,7 +59,7 @@ namespace xrt::core::hip break; } case hipHostMallocWriteCombined: { - // This is a workaround to create a buffer with cacheable flag if WriteComined flag is provided. + // This is a workaround to create a buffer with cacheable flag if WriteComined flag is provided. // This gets used to create instruction buffer on NPU // TODO This would go away once xrt::elf flow is enabled auto xrt_device = m_device->get_xrt_device(); @@ -84,7 +84,7 @@ namespace xrt::core::hip return nullptr; } - + void* memory::get_device_address() const { @@ -103,7 +103,7 @@ namespace xrt::core::hip assert(src_hip_mem->get_flags() == hipHostMallocDefault || src_hip_mem->get_flags() == hipHostMallocPortable); } - const unsigned char *src_ptr = reinterpret_cast(src); + auto src_ptr = reinterpret_cast(src); src_ptr += src_offset; if (m_bo) { m_bo.write(src_ptr, size, offset); @@ -119,21 +119,21 @@ namespace xrt::core::hip // pinned hip mem assert(dst_hip_mem->get_flags() == hipHostMallocDefault || dst_hip_mem->get_flags() == hipHostMallocPortable); } - unsigned char *dst_ptr = reinterpret_cast(dst); + auto dst_ptr = reinterpret_cast(dst); dst_ptr += dst_offset; if (m_bo) { m_bo.sync(XCL_BO_SYNC_BO_FROM_DEVICE); m_bo.read(dst_ptr, size, offset); } } - + void memory::sync(xclBOSyncDirection direction) { assert(m_bo); m_bo.sync(direction); } - + void memory::init_xrt_bo() { @@ -189,7 +189,7 @@ namespace xrt::core::hip } else { auto offset = reinterpret_cast(addr) - reinterpret_cast(itr->first.address); - return std::pair(itr->second, offset); + return {itr->second, offset}; } } @@ -202,7 +202,7 @@ namespace xrt::core::hip } else { auto offset = reinterpret_cast(addr) - reinterpret_cast(itr->first.address); - return std::pair(itr->second, offset); + return {itr->second, offset}; } } diff --git a/src/runtime_src/tools/xclbinutil/aie-pdi-transform/README.rst b/src/runtime_src/tools/xclbinutil/aie-pdi-transform/README.rst new file mode 100644 index 00000000000..ac344c9380c --- /dev/null +++ b/src/runtime_src/tools/xclbinutil/aie-pdi-transform/README.rst @@ -0,0 +1,11 @@ +aie-pdi-transform +================= + +The code in aie-pdi-transform directory provide functionality to transform a +given PDI to make it more efficient to load. For example multiple DMAs are +merged together and LOAD/STOREs are consolidated. + +Please note that the coding style used in this subsystem is not conformant to +XRT coding style. Please do not use this code as an example to write new PRs +for XRT. In due course of time this subsystem will be rewritten in modern C++ +like the rest of the XRT code base.