Skip to content

Commit

Permalink
Silence C++ [[nodiscard]] warning (#8090)
Browse files Browse the repository at this point in the history
* Silence C++ [[nodiscard]] warning

Add a note about new air-pdi-transform component

Signed-off-by: Sonal Santan <[email protected]>

* Resolve a few additional clang-tidy warnings

Signed-off-by: Sonal Santan <[email protected]>

* Let compiler manage the type of auto

Signed-off-by: Sonal Santan <[email protected]>

---------

Signed-off-by: Sonal Santan <[email protected]>
  • Loading branch information
sonals authored Apr 20, 2024
1 parent fe8d2e1 commit 471896a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/runtime_src/hip/api/hip_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(xrt::core::hip::hip_ctx_get_device());
return hipSuccess;
}
catch (const xrt_core::system_error& ex) {
Expand Down Expand Up @@ -235,4 +235,3 @@ hipDevicePrimaryCtxRelease(hipDevice_t dev)
}
return hipErrorUnknown;
}

3 changes: 1 addition & 2 deletions src/runtime_src/hip/api/hip_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -261,4 +261,3 @@ hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int device)
}
return hipErrorUnknown;
}

18 changes: 9 additions & 9 deletions src/runtime_src/hip/core/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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();
Expand All @@ -84,7 +84,7 @@ namespace xrt::core::hip

return nullptr;
}

void*
memory::get_device_address() const
{
Expand All @@ -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<const unsigned char *>(src);
auto src_ptr = reinterpret_cast<const unsigned char *>(src);
src_ptr += src_offset;
if (m_bo) {
m_bo.write(src_ptr, size, offset);
Expand All @@ -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<unsigned char *>(dst);
auto dst_ptr = reinterpret_cast<unsigned char *>(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()
{
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace xrt::core::hip
}
else {
auto offset = reinterpret_cast<uint64_t>(addr) - reinterpret_cast<uint64_t>(itr->first.address);
return std::pair(itr->second, offset);
return {itr->second, offset};
}
}

Expand All @@ -202,7 +202,7 @@ namespace xrt::core::hip
}
else {
auto offset = reinterpret_cast<uint64_t>(addr) - reinterpret_cast<uint64_t>(itr->first.address);
return std::pair(itr->second, offset);
return {itr->second, offset};
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/runtime_src/tools/xclbinutil/aie-pdi-transform/README.rst
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 471896a

Please sign in to comment.