a78753d392
* Updating to v3 API * General fixes * Extending dimension bits to 54 * Disabling agent profiling tests * Fixed unit test * Adding accumulate metric support for parsing counters (#609) * Adding accumulate metric support for parsing counters * Adding metric flag * Updating tests * source formatting (clang-format v11) (#610) Co-authored-by: Manjunath-Jakaraddi <21177428+Manjunath-Jakaraddi@users.noreply.github.com> * source formatting (clang-format v11) (#614) Co-authored-by: jrmadsen <6001865+jrmadsen@users.noreply.github.com> * Adding evaluate ast test * source formatting (clang-format v11) (#633) Co-authored-by: Manjunath-Jakaraddi <21177428+Manjunath-Jakaraddi@users.noreply.github.com> * Update scanner generated file * Adding flags to events for aqlprofile * Fix Mi200 failing test --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Manjunath-Jakaraddi <21177428+Manjunath-Jakaraddi@users.noreply.github.com> Co-authored-by: jrmadsen <6001865+jrmadsen@users.noreply.github.com> * Revert "Extending dimension bits to 54" This reverts commit 3cd6628452484044a93e129f27974f996a0e4c08. * Removing CU dimension * Fixing merge conflicts * Revert "Disabling agent profiling tests" This reverts commit 7e01518ed8c51fbb0c3b2575e1e0b8f9ddfa8237. * Fixing merge conflicts * Fix parser tests * Adding accumulate metric documentation * Update counter_collection_services.md * Update index.md * fix nested expression use * Update source/lib/rocprofiler-sdk/counters/evaluate_ast.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Doc update --------- Co-authored-by: Benjamin Welton <ben@amd.com> Co-authored-by: Manjunath P Jakaraddi <manjunath180397@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Manjunath-Jakaraddi <21177428+Manjunath-Jakaraddi@users.noreply.github.com> Co-authored-by: jrmadsen <6001865+jrmadsen@users.noreply.github.com> Co-authored-by: Manjunath-Jakaraddi <manjunath.jakaraddi@amd.com>
137 satır
5.2 KiB
C++
137 satır
5.2 KiB
C++
// MIT License
|
|
//
|
|
// Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
// copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
// SOFTWARE.
|
|
|
|
#pragma once
|
|
|
|
#include <rocprofiler-sdk/fwd.h>
|
|
|
|
#include "lib/common/logging.hpp"
|
|
|
|
#include <limits>
|
|
#include <string_view>
|
|
#include <unordered_map>
|
|
|
|
namespace rocprofiler
|
|
{
|
|
namespace counters
|
|
{
|
|
constexpr uint64_t COUNTER_BIT_LENGTH = 16;
|
|
constexpr uint64_t DIM_BIT_LENGTH = 48;
|
|
constexpr uint64_t MAX_64 = std::numeric_limits<uint64_t>::max();
|
|
enum rocprofiler_profile_counter_instance_types
|
|
{
|
|
ROCPROFILER_DIMENSION_NONE = 0, ///< No dimension data, returns/sets 48 bit value as is
|
|
ROCPROFILER_DIMENSION_XCC, ///< XCC dimension of result
|
|
ROCPROFILER_DIMENSION_AID, ///< AID dimension of result
|
|
ROCPROFILER_DIMENSION_SHADER_ENGINE, ///< SE dimension of result
|
|
ROCPROFILER_DIMENSION_AGENT, ///< Agent dimension
|
|
ROCPROFILER_DIMENSION_SHADER_ARRAY, ///< Number of shader arrays
|
|
ROCPROFILER_DIMENSION_WGP, ///< Number of workgroup processors
|
|
ROCPROFILER_DIMENSION_INSTANCE, ///< Number of instances
|
|
ROCPROFILER_DIMENSION_LAST
|
|
};
|
|
|
|
using DimensionMap =
|
|
std::unordered_map<rocprofiler_profile_counter_instance_types, std::string_view>;
|
|
|
|
const DimensionMap&
|
|
dimension_map();
|
|
|
|
inline rocprofiler_counter_id_t
|
|
rec_to_counter_id(rocprofiler_counter_instance_id_t id);
|
|
inline void
|
|
set_dim_in_rec(rocprofiler_counter_instance_id_t& id,
|
|
rocprofiler_profile_counter_instance_types dim,
|
|
size_t value);
|
|
inline void
|
|
set_counter_in_rec(rocprofiler_counter_instance_id_t& id, rocprofiler_counter_id_t value);
|
|
|
|
inline size_t
|
|
rec_to_dim_pos(rocprofiler_counter_instance_id_t id,
|
|
rocprofiler_profile_counter_instance_types dim);
|
|
|
|
const std::unordered_map<int, rocprofiler_profile_counter_instance_types>&
|
|
aqlprofile_id_to_rocprof_instance();
|
|
|
|
} // namespace counters
|
|
} // namespace rocprofiler
|
|
|
|
inline rocprofiler_counter_id_t
|
|
rocprofiler::counters::rec_to_counter_id(rocprofiler_counter_instance_id_t id)
|
|
{
|
|
return {.handle = id >> DIM_BIT_LENGTH};
|
|
}
|
|
|
|
inline void
|
|
rocprofiler::counters::set_dim_in_rec(rocprofiler_counter_instance_id_t& id,
|
|
rocprofiler_profile_counter_instance_types dim,
|
|
size_t value)
|
|
{
|
|
size_t bit_length = DIM_BIT_LENGTH / ROCPROFILER_DIMENSION_LAST;
|
|
int64_t mask = (MAX_64 >> (64 - bit_length)) << ((dim - 1) * bit_length);
|
|
|
|
if(dim == ROCPROFILER_DIMENSION_NONE)
|
|
{
|
|
// Set all 48 bits of dimension
|
|
id = (id & ~(MAX_64 >> COUNTER_BIT_LENGTH)) | value;
|
|
bit_length = DIM_BIT_LENGTH;
|
|
}
|
|
else
|
|
{
|
|
// Reset bits to 0 for dimension. Does so by getting the bit length as F's then
|
|
// shifiting that into the position of dim. Not's that value and then and's it
|
|
// with id.
|
|
id = (id & ~(mask));
|
|
// Set the value for the dimenstion
|
|
id = id | (value << ((dim - 1) * bit_length));
|
|
}
|
|
|
|
CHECK(value <= (MAX_64 >> (64 - bit_length))) << "Dimension value exceeds max allowed";
|
|
}
|
|
|
|
inline void
|
|
rocprofiler::counters::set_counter_in_rec(rocprofiler_counter_instance_id_t& id,
|
|
rocprofiler_counter_id_t value)
|
|
{
|
|
// Maximum counter value given the current setup.
|
|
CHECK(value.handle <= 0xffff) << "Counter id exceeds max allowed";
|
|
// Reset bits to 0 for counter id
|
|
id = id & ~((MAX_64 >> (64 - DIM_BIT_LENGTH)) << (DIM_BIT_LENGTH));
|
|
// Set the value for the dimenstion
|
|
id = id | (value.handle << (DIM_BIT_LENGTH));
|
|
}
|
|
|
|
inline size_t
|
|
rocprofiler::counters::rec_to_dim_pos(rocprofiler_counter_instance_id_t id,
|
|
rocprofiler_profile_counter_instance_types dim)
|
|
{
|
|
if(dim == ROCPROFILER_DIMENSION_NONE)
|
|
{
|
|
// read all 48 bits of dimension
|
|
return id & (MAX_64 >> COUNTER_BIT_LENGTH);
|
|
}
|
|
|
|
size_t bit_length = DIM_BIT_LENGTH / ROCPROFILER_DIMENSION_LAST;
|
|
id = id & ((MAX_64 >> (64 - bit_length)) << ((dim - 1) * bit_length));
|
|
return id >> ((dim - 1) * bit_length);
|
|
}
|