파일

.git-blame-ignore-revs에 있는 리비전을 무시합니다. 일반 blame 보기를 보려면 여기를 클릭하여 우회하세요.

123 라인
3.3 KiB
C++
Raw 고유링크 일반 보기 히스토리

2022-01-26 23:25:00 -06:00
// MIT License
//
2025-01-15 13:06:12 -05:00
// Copyright (c) 2022-2025 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
2022-01-26 23:25:00 -06:00
// 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:
//
2022-01-26 23:25:00 -06:00
// 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
2022-01-26 23:25:00 -06:00
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2022-01-26 23:25:00 -06:00
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "library/components/pthread_gotcha.hpp"
#include "core/config.hpp"
#include "core/utility.hpp"
2022-05-08 04:40:10 -05:00
#include "library/components/pthread_create_gotcha.hpp"
#include "library/components/pthread_mutex_gotcha.hpp"
2022-04-25 17:00:52 -05:00
#include "library/runtime.hpp"
#include "library/thread_data.hpp"
2022-02-23 06:59:32 -06:00
#include <timemory/backends/threading.hpp>
2022-08-31 01:24:31 -05:00
#include <timemory/utility/macros.hpp>
#include <timemory/utility/types.hpp>
#include <pthread.h>
2022-05-08 04:40:10 -05:00
#include <array>
#include <vector>
2022-08-31 01:24:31 -05:00
namespace tim
{
namespace operation
{
template <>
struct stop<rocprofsys::component::pthread_create_gotcha_t>
2022-08-31 01:24:31 -05:00
{
using type = rocprofsys::component::pthread_create_gotcha_t;
2022-08-31 01:24:31 -05:00
ROCPROFSYS_DEFAULT_OBJECT(stop)
2022-08-31 01:24:31 -05:00
template <typename... Args>
explicit stop(type&, Args&&...)
{}
template <typename... Args>
void operator()(type&, Args&&...)
{}
};
} // namespace operation
} // namespace tim
namespace rocprofsys
{
2022-02-08 17:42:17 -06:00
namespace
{
2022-08-31 01:24:31 -05:00
using bundle_t = tim::lightweight_tuple<component::pthread_create_gotcha_t,
component::pthread_mutex_gotcha_t>;
auto&
2022-05-08 04:40:10 -05:00
get_bundle()
{
2022-05-08 04:40:10 -05:00
static auto _v = std::unique_ptr<bundle_t>{};
if(!_v) _v = std::make_unique<bundle_t>("pthread_gotcha");
return _v;
}
2022-08-31 01:24:31 -05:00
bool is_configured = false;
2022-02-08 17:42:17 -06:00
} // namespace
2022-04-27 16:56:38 -05:00
//--------------------------------------------------------------------------------------//
void
pthread_gotcha::configure()
{
2022-08-31 01:24:31 -05:00
if(!is_configured)
{
::rocprofsys::component::pthread_create_gotcha::configure();
::rocprofsys::component::pthread_mutex_gotcha::configure();
2022-08-31 01:24:31 -05:00
is_configured = true;
}
}
2022-02-08 17:42:17 -06:00
void
pthread_gotcha::shutdown()
{
2022-08-31 01:24:31 -05:00
if(is_configured)
{
::rocprofsys::component::pthread_mutex_gotcha::shutdown();
::rocprofsys::component::pthread_create_gotcha::shutdown();
2022-08-31 01:24:31 -05:00
is_configured = false;
}
2022-02-08 17:42:17 -06:00
}
2022-05-08 04:40:10 -05:00
void
pthread_gotcha::start()
{
2022-08-31 01:24:31 -05:00
configure();
2022-05-08 04:40:10 -05:00
get_bundle()->start();
}
2022-05-08 04:40:10 -05:00
void
pthread_gotcha::stop()
{
get_bundle()->stop();
}
2023-06-14 11:55:22 -05:00
std::set<pthread_gotcha::native_handle_t>
pthread_gotcha::get_native_handles()
{
return ::rocprofsys::component::pthread_create_gotcha::get_native_handles();
2023-06-14 11:55:22 -05:00
}
} // namespace rocprofsys