Skip to content

Commit 1f67684

Browse files
shumwayassistant-librarian[bot]
authored andcommitted
[rocm-libraries] ROCm/rocm-libraries#4598 (commit 9ff8af1)
[CK_BUILDER] Fix two staging-compiler errors in CK builder code (#4598) This PR fixes two compiler warnings that report as errors with the latest compiler: 1. In tensor descriptor, the `operator[]` accessor needs a `[[clang::lifetimebound]]` attribute. 2. In the unit tests for device buffer, there is a test that explicitly checks for an error on a pointer that went out of scope, so it needs a to disable `-Wlifetime-safety-permissive` in the test code. I ran the CK `smoke-builder` tests with the staging compiler to verify.
1 parent 2b2a39b commit 1f67684

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

experimental/builder/include/ck_tile/builder/testing/tensor_descriptor.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct Extent : std::array<size_t, RANK>
106106
/// @param i The index to index the array with.
107107
///
108108
/// @see std::array::operator[]
109-
__device__ __host__ size_t& operator[](size_t i)
109+
__device__ __host__ size_t& operator[](size_t i) [[clang::lifetimebound]]
110110
{
111111
if constexpr(RANK > 0)
112112
{
@@ -450,7 +450,8 @@ struct TensorDescriptor
450450
/// @brief Print tensor descriptor details.
451451
///
452452
/// Print tensor descriptor details - lengths and strides.
453-
friend std::ostream& operator<<(std::ostream& os, const TensorDescriptor<DT, RANK>& tensor_desc)
453+
friend std::ostream& operator<<([[clang::lifetimebound]] std::ostream& os,
454+
const TensorDescriptor<DT, RANK>& tensor_desc)
454455
{
455456
os << tensor_desc.inner_descriptor_;
456457
return os;

experimental/builder/test/unit_device_buffer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,18 @@ TEST(DeviceBuffer, AutoFree)
4848
const auto size = 12345;
4949
std::byte* ptr = nullptr;
5050

51+
// In this test we are explicitly testing a pointer that is out of scope, so
52+
// we have to disable the clang compiler's lifestime safety checks.
53+
#pragma clang diagnostic push
54+
#pragma clang diagnostic ignored "-Wlifetime-safety-permissive"
5155
{
5256
auto buffer = ckt::alloc_buffer(size);
5357
ptr = buffer.get();
5458
}
5559

5660
// Trying to use a pointer after freeing should return en error in HIP.
5761
EXPECT_THAT(hipMemset(ptr, 0xFF, size), HipError(hipErrorInvalidValue));
62+
#pragma clang diagnostic pop
5863

5964
// Reset internal HIP error state.
6065
// Otherwise, the error may leak into other tests, triggering anything that

0 commit comments

Comments
 (0)