2f9b1767e9
* Handle hsa_queue_destroy after finalization
- fixes issue where hsa_queue_destroy(...) is invoked after rocprofiler-sdk has finalized
- hsa::get_queue_controller() returns pointer
- if queue controller is a null pointer, skip invoking QueueController::destroy_queue
* Update HIP/HSA/marker update_table logging
* Update rocprofv3 tests
- remove HSA_TOOLS_LIB env variable
- remove setting ROCPROFILER_LOG_LEVEL env variable
- add timeouts to tests which are missing them
* Disable thread sanitizer deadlock detection
* Update CI workflow
- rename vega20-ubuntu job to core-ci
- enable navi32 in core-ci and sanitizers
* Update run-ci.py
- set gcovr html medium and high threshold
* Update lib/rocprofiler-sdk/hsa/queue_controller.cpp
- remove this capture from enable/disable serialization
* Update lib/rocprofiler-sdk/hsa/{hsa_barrier,profile_serializer}.*
- hsa_barrier::set_barrier accepts const-ref to queue map
- profile_serializer::enable and profile_serializer::disable accept const-ref to queue map
* Logging for HIP/HSA/marker/profile_serializer
* Logging for HIP/HSA/marker/queue_controller
* Improve test_retired_correlation_ids asserts
* Fix tests/counter-collection/validate.py
- scale expected SQ_WAVES counter value based on warp size of GPU
* Tweak github comment for code coverage
* Remove gcovr html high/medium threshold args
* Fix tests/counter-collection/validate.py
- round before casting to int in test_counter_values
* operator bool for profile_serializer
- only wait on CV if profile_serializer is used
* Logging updates (profile_serializer + code_object)
* Update counter-collection validate.py
* QueueController does not wait on CV if finalizing/finalized
* Update CI workflow
- remove navi32 from core job
* Improve HIP/HSA/marker tracing get_functor/functor
- remove lambda wrapper around functor
* Update lib/rocprofiler-sdk/hsa/queue_controller.cpp
- do not acquire cvmutex lock during finalization
* Update lib/rocprofiler-sdk/hsa/hsa_barrier.*
- move ctor and dtor to implementation
- skip signal store screlease and destroy if already finalized
* Update CI workflow
- remove navi32 runners
* bwelton fixes for hangs
* CMake improvements + simplified demangle
- remove amd-comgr from common target (and thus removed from roctx DT_NEEDED)
---------
Co-authored-by: Benjamin Welton <bewelton@amd.com>
166 linhas
5.2 KiB
C++
166 linhas
5.2 KiB
C++
// MIT License
|
|
//
|
|
// Copyright (c) 2023 Advanced Micro Devices, Inc.
|
|
//
|
|
// 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.
|
|
|
|
#include "lib/common/demangle.hpp"
|
|
|
|
#include <glog/logging.h>
|
|
|
|
#include <cxxabi.h>
|
|
#include <cstdarg>
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <iomanip>
|
|
#include <iostream>
|
|
#include <set>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
namespace rocprofiler
|
|
{
|
|
namespace common
|
|
{
|
|
std::string
|
|
cxa_demangle(std::string_view _mangled_name, int* _status)
|
|
{
|
|
// return the mangled since there is no buffer
|
|
if(_mangled_name.empty())
|
|
{
|
|
*_status = -2;
|
|
return std::string{};
|
|
}
|
|
|
|
auto _demangled_name = std::string{_mangled_name};
|
|
|
|
// PARAMETERS to __cxa_demangle
|
|
// mangled_name:
|
|
// A NULL-terminated character string containing the name to be demangled.
|
|
// buffer:
|
|
// A region of memory, allocated with malloc, of *length bytes, into which the
|
|
// demangled name is stored. If output_buffer is not long enough, it is expanded
|
|
// using realloc. output_buffer may instead be NULL; in that case, the demangled
|
|
// name is placed in a region of memory allocated with malloc.
|
|
// _buflen:
|
|
// If length is non-NULL, the length of the buffer containing the demangled name
|
|
// is placed in *length.
|
|
// status:
|
|
// *status is set to one of the following values
|
|
size_t _demang_len = 0;
|
|
char* _demang = abi::__cxa_demangle(_demangled_name.c_str(), nullptr, &_demang_len, _status);
|
|
switch(*_status)
|
|
{
|
|
// 0 : The demangling operation succeeded.
|
|
// -1 : A memory allocation failure occurred.
|
|
// -2 : mangled_name is not a valid name under the C++ ABI mangling rules.
|
|
// -3 : One of the arguments is invalid.
|
|
case 0:
|
|
{
|
|
if(_demang) _demangled_name = std::string{_demang};
|
|
break;
|
|
}
|
|
case -1:
|
|
{
|
|
PLOG(ERROR) << "memory allocation failure occurred demangling " << _demangled_name;
|
|
break;
|
|
}
|
|
case -2: break;
|
|
case -3:
|
|
{
|
|
PLOG(ERROR) << "Invalid argument in: (\"" << _demangled_name << "\", nullptr, nullptr, "
|
|
<< _status << ")";
|
|
break;
|
|
}
|
|
default: break;
|
|
};
|
|
|
|
// if it "demangled" but the length is zero, set the status to -2
|
|
if(_demang_len == 0 && *_status == 0) *_status = -2;
|
|
|
|
// free allocated buffer
|
|
::free(_demang);
|
|
return _demangled_name;
|
|
}
|
|
|
|
// C++ symbol demangle
|
|
std::string
|
|
cxx_demangle(std::string_view symbol)
|
|
{
|
|
int _status = 0;
|
|
auto demangled_str = cxa_demangle(symbol, &_status);
|
|
|
|
if(_status == 0) return demangled_str;
|
|
|
|
return std::string{symbol};
|
|
}
|
|
|
|
// The function extracts the kernel name from
|
|
// input string. By using the iterators it finds the
|
|
// window in the string which contains only the kernel name.
|
|
// For example 'Foo<int, float>::foo(a[], int (int))' -> 'foo'
|
|
std::string
|
|
truncate_name(std::string_view name)
|
|
{
|
|
auto rit = name.rbegin();
|
|
auto rend = name.rend();
|
|
uint32_t counter = 0;
|
|
char open_token = 0;
|
|
char close_token = 0;
|
|
while(rit != rend)
|
|
{
|
|
if(counter == 0)
|
|
{
|
|
switch(*rit)
|
|
{
|
|
case ')':
|
|
counter = 1;
|
|
open_token = ')';
|
|
close_token = '(';
|
|
break;
|
|
case '>':
|
|
counter = 1;
|
|
open_token = '>';
|
|
close_token = '<';
|
|
break;
|
|
case ']':
|
|
counter = 1;
|
|
open_token = ']';
|
|
close_token = '[';
|
|
break;
|
|
case ' ': ++rit; continue;
|
|
}
|
|
if(counter == 0) break;
|
|
}
|
|
else
|
|
{
|
|
if(*rit == open_token) counter++;
|
|
if(*rit == close_token) counter--;
|
|
}
|
|
++rit;
|
|
}
|
|
auto rbeg = rit;
|
|
while((rit != rend) && (*rit != ' ') && (*rit != ':'))
|
|
rit++;
|
|
return std::string{name.substr(rend - rit, rit - rbeg)};
|
|
}
|
|
} // namespace common
|
|
} // namespace rocprofiler
|