Use small_vector for API iterate_args (#597)
* Use small_vector for API iterate_args - replace dim3 value arguments with rocprofiler_dim3_t - dim3 has a non-trivial destructor - common::mpl::unqualified_type - common::stringified_argument_array_t<N> alias - assert_public_data_type_properties() - common::container::small_vector<T>::at function - stringize returns small_vector<stringified_argument> - stack allocated vector - remove has_pc_sampling condition (HSA, HIP) - this will be handled in queue interception * Misc tweaks
This commit is contained in:
zatwierdzone przez
GitHub
rodzic
2a262235db
commit
8591ed1c96
@@ -50,6 +50,7 @@
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
@@ -345,6 +346,17 @@ public:
|
||||
return begin()[idx];
|
||||
}
|
||||
|
||||
reference at(size_type idx)
|
||||
{
|
||||
if(idx >= size()) throw std::out_of_range{"small_vector::at"};
|
||||
return begin()[idx];
|
||||
}
|
||||
const_reference at(size_type idx) const
|
||||
{
|
||||
if(idx >= size()) throw std::out_of_range{"small_vector::at"};
|
||||
return begin()[idx];
|
||||
}
|
||||
|
||||
reference front()
|
||||
{
|
||||
assert(!empty());
|
||||
|
||||
@@ -147,6 +147,15 @@ template <typename Tp>
|
||||
struct indirection_level
|
||||
: indirection_level_impl_n<std::remove_cv_t<std::remove_reference_t<std::decay_t<Tp>>>, 0>
|
||||
{};
|
||||
|
||||
template <typename Tp>
|
||||
struct unqualified_type
|
||||
{
|
||||
using type = std::remove_reference_t<std::remove_cv_t<std::decay_t<Tp>>>;
|
||||
};
|
||||
|
||||
template <typename Tp>
|
||||
using unqualified_type_t = typename unqualified_type<Tp>::type;
|
||||
} // namespace mpl
|
||||
} // namespace common
|
||||
} // namespace rocprofiler
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "lib/common/container/small_vector.hpp"
|
||||
#include "lib/common/mpl.hpp"
|
||||
|
||||
#include <fmt/core.h>
|
||||
@@ -40,10 +41,14 @@ struct stringified_argument
|
||||
int32_t indirection_level = 0;
|
||||
int32_t dereference_count = 0;
|
||||
const char* type = nullptr;
|
||||
std::string name = {};
|
||||
const char* name = nullptr;
|
||||
std::string value = {};
|
||||
};
|
||||
|
||||
template <size_t N>
|
||||
using stringified_argument_array_t =
|
||||
container::small_vector<stringified_argument, std::min<size_t>(N, 6)>;
|
||||
|
||||
template <typename Tp, typename FuncT>
|
||||
auto
|
||||
stringize_arg_impl(const Tp& _v, const int32_t max_deref, int32_t& deref_cnt, FuncT&& impl)
|
||||
@@ -114,7 +119,7 @@ stringize_arg(int32_t max_deref, const std::pair<const char*, Tp>& arg, FuncT&&
|
||||
auto _arg = common::stringified_argument{};
|
||||
_arg.indirection_level = mpl::indirection_level<Tp>::value;
|
||||
_arg.type = typeid(Tp).name();
|
||||
_arg.name = std::string{arg.first};
|
||||
_arg.name = arg.first;
|
||||
_arg.value = stringize_arg_impl(
|
||||
arg.second, max_deref, _arg.dereference_count, std::forward<FuncT>(impl));
|
||||
return _arg;
|
||||
|
||||
@@ -107,26 +107,33 @@ get_val(Container& map, const Key& key)
|
||||
return (pos != map.end() ? &pos->second : nullptr);
|
||||
}
|
||||
|
||||
template <typename Tp>
|
||||
constexpr void
|
||||
assert_public_data_type_properties()
|
||||
{
|
||||
static_assert(std::is_standard_layout<Tp>::value,
|
||||
"public data type struct should have a standard layout");
|
||||
static_assert(std::is_trivial<Tp>::value, "public data type should be trivial");
|
||||
static_assert(std::is_default_constructible<Tp>::value,
|
||||
"public data type struct should be default constructible");
|
||||
static_assert(std::is_trivially_copy_constructible<Tp>::value,
|
||||
"public data type struct should be trivially copy constructible");
|
||||
static_assert(std::is_trivially_move_constructible<Tp>::value,
|
||||
"public data type struct should be trivially move constructible");
|
||||
static_assert(std::is_trivially_copy_assignable<Tp>::value,
|
||||
"public data type struct should be trivially move assignable");
|
||||
static_assert(std::is_trivially_move_assignable<Tp>::value,
|
||||
"public data type struct should be trivially move assignable");
|
||||
static_assert(std::is_trivially_copyable<Tp>::value,
|
||||
"public data type struct should be trivially move assignable");
|
||||
}
|
||||
|
||||
template <typename Tp>
|
||||
constexpr void
|
||||
assert_public_api_struct_properties()
|
||||
{
|
||||
assert_public_data_type_properties<Tp>();
|
||||
static_assert(std::is_class<Tp>::value, "this is not a public API struct");
|
||||
static_assert(std::is_standard_layout<Tp>::value,
|
||||
"public API struct should have a standard layout");
|
||||
static_assert(std::is_trivially_default_constructible<Tp>::value,
|
||||
"public API struct should be trivially default constructible");
|
||||
static_assert(std::is_trivially_copy_constructible<Tp>::value,
|
||||
"public API struct should be trivially copy constructible");
|
||||
static_assert(std::is_trivially_move_constructible<Tp>::value,
|
||||
"public API struct should be trivially move constructible");
|
||||
static_assert(std::is_trivially_copy_assignable<Tp>::value,
|
||||
"public API struct should be trivially move assignable");
|
||||
static_assert(std::is_trivially_move_assignable<Tp>::value,
|
||||
"public API struct should be trivially move assignable");
|
||||
static_assert(std::is_trivially_copyable<Tp>::value,
|
||||
"public API struct should be trivially move assignable");
|
||||
static_assert(std::is_trivial<Tp>::value, "public API struct should be trivial");
|
||||
static_assert(offsetof(Tp, size) == 0, "public API struct should have a size field first");
|
||||
static_assert(sizeof(std::declval<Tp>().size) == sizeof(uint64_t),
|
||||
"public API struct size field should be 64 bits");
|
||||
|
||||
Reference in New Issue
Block a user