41c0ddd72d
* Convert LOG() -> ROCP_X logging macros. This patch converts the LOG() macro to the ROCP_X logging macros. There are the following levels of logs. Logs whos expressions are not evaluated unless the log level is enabled: ROCP_TRACE - VLOG(2) (enabeled by env variable GLOG_v=2) ROCP_INFO - VLOG(1) (enabeled by env variable GLOG_v=1) Logs whos expressions are always evaluated: ROCP_WARNING - LOG(WARNING) ROCP_ERROR - LOG(ERROR) ROCP_FATAL - LOG(FATAL) ROCP_DFATAL - DLOG(FATAL) (only fatal in debug mode) * source formatting (clang-format v11) (#696) Co-authored-by: bwelton <1683479+bwelton@users.noreply.github.com> * Minor fix * Fixes for VLOG before main * fix vmodule * source formatting (clang-format v11) (#718) Co-authored-by: bwelton <1683479+bwelton@users.noreply.github.com> * memory leak fix * Vlog change --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: bwelton <1683479+bwelton@users.noreply.github.com>
85 wiersze
2.4 KiB
C++
85 wiersze
2.4 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.
|
|
|
|
#include "lib/common/environment.hpp"
|
|
#include "lib/common/logging.hpp"
|
|
#include "lib/common/static_object.hpp"
|
|
#include "lib/rocprofiler-sdk/allocator.hpp"
|
|
#include "lib/rocprofiler-sdk/registration.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
namespace rocprofiler
|
|
{
|
|
namespace shared_library
|
|
{
|
|
namespace
|
|
{
|
|
struct lifetime
|
|
{
|
|
lifetime();
|
|
~lifetime();
|
|
};
|
|
|
|
lifetime::lifetime()
|
|
{
|
|
registration::init_logging();
|
|
|
|
if(common::get_env("ROCPROFILER_LIBRARY_CTOR", false))
|
|
{
|
|
ROCP_INFO << "Initializing rocprofiler-sdk library...";
|
|
registration::initialize();
|
|
ROCP_INFO << "rocprofiler-sdk library initialized";
|
|
}
|
|
}
|
|
|
|
lifetime::~lifetime()
|
|
{
|
|
if(common::get_env("ROCPROFILER_LIBRARY_DTOR", false))
|
|
{
|
|
ROCP_INFO << "Finalizing rocprofiler-sdk library...";
|
|
registration::finalize();
|
|
ROCP_INFO << "rocprofiler-sdk library finalized";
|
|
}
|
|
}
|
|
|
|
auto*&
|
|
get_lifetime()
|
|
{
|
|
static auto* _v = common::static_object<lifetime>::construct();
|
|
return _v;
|
|
}
|
|
} // namespace
|
|
} // namespace shared_library
|
|
|
|
auto rocprofiler_sdk_shlib_lifetime = shared_library::get_lifetime();
|
|
|
|
void
|
|
rocprofiler_sdk_shlib_ctor() ROCPROFILER_ATTRIBUTE(constructor(101));
|
|
|
|
void
|
|
rocprofiler_sdk_shlib_ctor()
|
|
{
|
|
(void) shared_library::get_lifetime();
|
|
}
|
|
} // namespace rocprofiler
|