mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-04-20 14:59:17 +00:00
[Compiler] Addressing new compiler warnings (#3640)
* [Compiler] Addressing new compiler warnings Clang enables new lifetime warnings in production and we see build errors due to this with the staging compiler. The attributes added in this PR are suggested by the compiler. However, I'm not very familiar with the code base, so the changes may be incorrect. * Update some more instances * Adds file-level ignores via clang diagnostic pragma The number of instances was large, so I decided to use file-level scope to disable the warning via pragma clang diagnostic ignored. It also showed this warning coming from the gtest dependency. For that, I did add the respective command line flag to the CMake variables. I don't know if this is acceptable or not. * This adds the remaining instances For a build on gfx90a. * fix clang format * Adding couple more instances from gfx1200 build * Fixed another few instances --------- Co-authored-by: Illia Silin <98187287+illsilin@users.noreply.github.com> Co-authored-by: illsilin_amdeng <Illia.Silin@amd.com>
This commit is contained in:
@@ -44,7 +44,8 @@ struct get_carrier<3>
|
||||
|
||||
// replacement of host std::copy_n()
|
||||
template <typename InputIterator, typename Size, typename OutputIterator>
|
||||
__device__ static OutputIterator copy_n(InputIterator from, Size size, OutputIterator to)
|
||||
__device__ static OutputIterator
|
||||
copy_n(InputIterator from, Size size, [[clang::lifetimebound]] OutputIterator to)
|
||||
{
|
||||
if(0 < size)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#pragma once
|
||||
#include "ck/utility/data_type.hpp"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wlifetime-safety-intra-tu-suggestions"
|
||||
namespace ck {
|
||||
|
||||
// vector_type
|
||||
@@ -116,7 +118,7 @@ struct vector_type<T, 2, typename ck::enable_if_t<is_native_type<T>()>>
|
||||
__host__ __device__ constexpr vector_type(type v) : data_{v} {}
|
||||
|
||||
template <typename X>
|
||||
__host__ __device__ constexpr const auto& AsType() const
|
||||
__host__ __device__ constexpr const auto& AsType() const [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(is_same<X, d1_t>::value || is_same<X, d2_t>::value,
|
||||
"Something went wrong, please check src and dst types.");
|
||||
@@ -136,7 +138,7 @@ struct vector_type<T, 2, typename ck::enable_if_t<is_native_type<T>()>>
|
||||
}
|
||||
|
||||
template <typename X>
|
||||
__host__ __device__ constexpr auto& AsType()
|
||||
__host__ __device__ constexpr auto& AsType() [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(is_same<X, d1_t>::value || is_same<X, d2_t>::value,
|
||||
"Something went wrong, please check src and dst types.");
|
||||
@@ -248,7 +250,7 @@ struct vector_type<T, 4, typename ck::enable_if_t<is_native_type<T>()>>
|
||||
__host__ __device__ constexpr vector_type(type v) : data_{v} {}
|
||||
|
||||
template <typename X>
|
||||
__host__ __device__ constexpr const auto& AsType() const
|
||||
__host__ __device__ constexpr const auto& AsType() const [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(is_same<X, d1_t>::value || is_same<X, d2_t>::value || is_same<X, d4_t>::value,
|
||||
"Something went wrong, please check src and dst types.");
|
||||
@@ -272,7 +274,7 @@ struct vector_type<T, 4, typename ck::enable_if_t<is_native_type<T>()>>
|
||||
}
|
||||
|
||||
template <typename X>
|
||||
__host__ __device__ constexpr auto& AsType()
|
||||
__host__ __device__ constexpr auto& AsType() [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(is_same<X, d1_t>::value || is_same<X, d2_t>::value || is_same<X, d4_t>::value,
|
||||
"Something went wrong, please check src and dst types.");
|
||||
@@ -583,7 +585,7 @@ struct vector_type<T, 8, typename ck::enable_if_t<is_native_type<T>()>>
|
||||
}
|
||||
|
||||
template <typename X>
|
||||
__host__ __device__ constexpr auto& AsType()
|
||||
__host__ __device__ constexpr auto& AsType() [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(is_same<X, d1_t>::value || is_same<X, d2_t>::value ||
|
||||
is_same<X, d4_t>::value || is_same<X, d8_t>::value,
|
||||
@@ -754,7 +756,7 @@ struct vector_type<T, 16, typename ck::enable_if_t<is_native_type<T>()>>
|
||||
}
|
||||
|
||||
template <typename X>
|
||||
__host__ __device__ constexpr auto& AsType()
|
||||
__host__ __device__ constexpr auto& AsType() [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(is_same<X, d1_t>::value || is_same<X, d2_t>::value ||
|
||||
is_same<X, d4_t>::value || is_same<X, d8_t>::value ||
|
||||
@@ -1427,7 +1429,7 @@ struct non_native_vector_base<
|
||||
}
|
||||
|
||||
template <typename X>
|
||||
__host__ __device__ constexpr auto& AsType()
|
||||
__host__ __device__ constexpr auto& AsType() [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(is_same_v<X, data_t> || is_same_v<X, T> || is_same_v<X, data_v>,
|
||||
"Something went wrong, please check src and dst types.");
|
||||
@@ -1627,7 +1629,7 @@ struct vector_type<T, 2, typename ck::enable_if_t<!is_native_type<T>()>>
|
||||
__host__ __device__ constexpr vector_type(type v) : data_{v} {}
|
||||
|
||||
template <typename X>
|
||||
__host__ __device__ constexpr const auto& AsType() const
|
||||
__host__ __device__ constexpr const auto& AsType() const [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(is_same<X, d1_t>::value || is_same<X, d1_nnv_t>::value ||
|
||||
is_same<X, d2_t>::value,
|
||||
@@ -1797,7 +1799,7 @@ struct vector_type<T, 8, typename ck::enable_if_t<!is_native_type<T>()>>
|
||||
}
|
||||
|
||||
template <typename X>
|
||||
__host__ __device__ constexpr auto& AsType()
|
||||
__host__ __device__ constexpr auto& AsType() [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(is_same<X, d1_t>::value || is_same<X, d1_nnv_t>::value ||
|
||||
is_same<X, d2_t>::value || is_same<X, d4_t>::value ||
|
||||
@@ -2284,3 +2286,4 @@ using pk_i4x4_t = typename vector_type<pk_i4_t, 4>::type;
|
||||
using pk_i4x8_t = typename vector_type<pk_i4_t, 8>::type;
|
||||
|
||||
} // namespace ck
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include <string_view>
|
||||
#include <map>
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wlifetime-safety-intra-tu-suggestions"
|
||||
|
||||
namespace ck {
|
||||
namespace internal {
|
||||
template <typename T>
|
||||
@@ -188,5 +191,5 @@ void UpdateEnvVar(EnvVar, const std::string_view& val)
|
||||
// environment variable to enable logging:
|
||||
// export CK_LOGGING=ON or CK_LOGGING=1 or CK_LOGGING=ENABLED
|
||||
CK_DECLARE_ENV_VAR_BOOL(CK_LOGGING)
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,8 @@ enum struct PipelineVersion
|
||||
} // namespace ck
|
||||
|
||||
#if !defined(__HIPCC_RTC__) || !defined(CK_CODE_GEN_RTC)
|
||||
inline std::ostream& operator<<(std::ostream& os, const ck::PipelineVersion& p)
|
||||
inline std::ostream& operator<<([[clang::lifetimebound]] std::ostream& os,
|
||||
const ck::PipelineVersion& p)
|
||||
{
|
||||
switch(p)
|
||||
{
|
||||
|
||||
@@ -70,7 +70,8 @@ enum struct TailNumber
|
||||
} // namespace ck
|
||||
|
||||
#if !defined(__HIPCC_RTC__) || !defined(CK_CODE_GEN_RTC)
|
||||
inline std::ostream& operator<<(std::ostream& os, const ck::LoopScheduler& s)
|
||||
inline std::ostream& operator<<([[clang::lifetimebound]] std::ostream& os,
|
||||
const ck::LoopScheduler& s)
|
||||
{
|
||||
switch(s)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "statically_indexed_array.hpp"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wlifetime-safety-intra-tu-suggestions"
|
||||
namespace ck {
|
||||
|
||||
// static buffer for scalar
|
||||
@@ -104,7 +106,7 @@ struct StaticBufferTupleOfVector
|
||||
// Set S
|
||||
// i is offset of S
|
||||
template <index_t I>
|
||||
__host__ __device__ constexpr S& operator()(Number<I> i)
|
||||
__host__ __device__ constexpr S& operator()(Number<I> i) [[clang::lifetimebound]]
|
||||
{
|
||||
constexpr auto i_v = i / s_per_v;
|
||||
constexpr auto i_s = i % s_per_v;
|
||||
@@ -195,3 +197,4 @@ __host__ __device__ constexpr auto make_static_buffer(LongNumber<N>)
|
||||
}
|
||||
|
||||
} // namespace ck
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@@ -51,7 +51,7 @@ get_tuple_element_data_reference(const TupleElementKeyData<Key, Data>& x)
|
||||
// for write access of tuple element
|
||||
template <typename Key, typename Data>
|
||||
__host__ __device__ constexpr Data&
|
||||
get_tuple_element_data_reference(TupleElementKeyData<Key, Data>& x)
|
||||
get_tuple_element_data_reference([[clang::lifetimebound]] TupleElementKeyData<Key, Data>& x)
|
||||
{
|
||||
return x.mData;
|
||||
}
|
||||
@@ -106,6 +106,7 @@ struct TupleImpl<Sequence<Is...>, Xs...> : TupleElementKeyData<TupleElementKey<I
|
||||
|
||||
template <index_t I>
|
||||
__host__ __device__ constexpr auto& GetElementDataByKey(TupleElementKey<I>)
|
||||
[[clang::lifetimebound]]
|
||||
{
|
||||
return get_tuple_element_data_reference<TupleElementKey<I>>(*this);
|
||||
}
|
||||
@@ -147,7 +148,7 @@ struct Tuple : detail::TupleImpl<typename arithmetic_sequence_gen<0, sizeof...(X
|
||||
|
||||
// write access
|
||||
template <index_t I>
|
||||
__host__ __device__ constexpr auto& At(Number<I>)
|
||||
__host__ __device__ constexpr auto& At(Number<I>) [[clang::lifetimebound]]
|
||||
{
|
||||
static_assert(I < base::Size(), "wrong! out of range");
|
||||
return base::GetElementDataByKey(detail::TupleElementKey<I>{});
|
||||
@@ -162,7 +163,7 @@ struct Tuple : detail::TupleImpl<typename arithmetic_sequence_gen<0, sizeof...(X
|
||||
|
||||
// write access
|
||||
template <index_t I>
|
||||
__host__ __device__ constexpr auto& operator()(Number<I> i)
|
||||
__host__ __device__ constexpr auto& operator()(Number<I> i) [[clang::lifetimebound]]
|
||||
{
|
||||
return At(i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user