[rocm-libraries] ROCm/rocm-libraries#5921 (commit 032ac1b)

[CK] fix clang lifetimebound errors with staging compiler
 (#5921)

## Motivation

The ROCm staging compiler (newer Clang) enforces
`[[clang::lifetimebound]]` annotations on methods that return references
or pointers to internal object data. Without these annotations, the
staging compiler emits compilation errors for container accessor methods
across the CK and CK Tile namespaces.

  ## Technical Details

Adds `[[clang::lifetimebound]]` to all reference/pointer-returning
accessors in core container types:

  **`ck::` namespace:**
  - `Array` -- `At()`, `operator[]`, `operator()`, `begin()`, `end()`
  - `index_array` -- `operator[]`
  - `StaticallyIndexedArray_v2` -- `At()`, `operator[]`, `operator()`
  - `IndexLookupTable` -- `operator[]`

  **`ck_tile::` namespace:**
  - `array` -- `get(i)`, `at()`, `operator[]`, `operator()`
  - `static_array` -- `operator[]`
  - `thread_buffer` -- `get(i)`, `at()`, `operator[]`, `operator()`
  - `make_kernel()` -- parameter pack

Also removes the unused `instance_index` variable from
`batched_gemm_reduce_fp16.cpp` and simplifies its argument parsing
  accordingly.

  ## Test Plan

- Compile with the staging compiler to verify all lifetimebound errors
are resolved
- Existing tests pass unchanged -- the attribute is a compile-time
annotation with no runtime effect

 ## Test Result

<!-- Briefly summarize test outcomes. -->

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
This commit is contained in:
Illia Silin
2026-03-30 14:20:20 +00:00
committed by assistant-librarian[bot]
parent 2dcae9d173
commit e6b8094f94
12 changed files with 82 additions and 71 deletions

View File

@@ -11,8 +11,7 @@
#include "profiler/profile_batched_gemm_reduce_impl.hpp"
static ck::index_t param_mask = 0xffff;
static ck::index_t instance_index = -1;
static ck::index_t param_mask = 0xffff;
struct GemmParams
{
ck::index_t M;
@@ -105,15 +104,14 @@ int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
if(argc == 1) {}
else if(argc == 3)
else if(argc == 2)
{
param_mask = strtol(argv[1], nullptr, 0);
instance_index = atoi(argv[2]);
param_mask = strtol(argv[1], nullptr, 0);
}
else
{
std::cout << "Usage of " << argv[0] << std::endl;
std::cout << "Arg1,2: param_mask instance_index(-1 means all)" << std::endl;
std::cout << "Arg1: param_mask " << std::endl;
}
return RUN_ALL_TESTS();
}

View File

@@ -18,8 +18,7 @@
#include <type_traits>
#include <vector>
static ck::index_t param_mask = 0xffffff;
static ck::index_t instance_index = -1;
static ck::index_t param_mask = 0xffffff;
using FP32 = float;
using FP16 = ck::half_t;
@@ -292,15 +291,14 @@ int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
if(argc == 1) {}
else if(argc == 3)
else if(argc == 2)
{
param_mask = strtol(argv[1], nullptr, 0);
instance_index = atoi(argv[2]);
param_mask = strtol(argv[1], nullptr, 0);
}
else
{
std::cout << "Usage of " << argv[0] << std::endl;
std::cout << "Arg1,2: param_mask instance_index(-1 means all)" << std::endl;
std::cout << "Arg1: param_mask " << std::endl;
}
return RUN_ALL_TESTS();
}

View File

@@ -15,9 +15,6 @@
#include "gtest/gtest.h"
static ck::index_t param_mask = 0xffffff;
static ck::index_t instance_index = -1;
using FP32 = float;
using FP16 = ck::half_t;
using BF16 = ck::bhalf_t;
@@ -238,19 +235,5 @@ TYPED_TEST(TestGroupedGemmMultiABDFixedNK, Regular)
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
if(argc == 1)
{
// Run with default arguments.
}
else if(argc == 3)
{
param_mask = strtol(argv[1], nullptr, 0);
instance_index = atoi(argv[2]);
}
else
{
std::cout << "Usage of " << argv[0] << std::endl;
std::cout << "Arg1,2: param_mask instance_index(-1 means all)" << std::endl;
}
return RUN_ALL_TESTS();
}