Arquivos
rocm-systems/source/lib/omnitrace/library/components/pthread_mutex_gotcha.hpp
T
Jonathan R. Madsen 424a3593e7 MPI headers + mutex gotcha + roctracer + kokkosp (#11)
* MPI headers, mutex gotcha + roctracer + kokkosp

- relocate internal MPI headers
- pthread_barrier in parallel-overhead
- doc fixes to DYNINST options
- minor tweaks to dynamic_library
- dlopen libamdhip64.so
- scoped thread state in kokkos
- extended pthread_mutex_gotcha

* Fix for unused-but-set-variables
2022-05-30 18:25:12 -05:00

74 linhas
2.8 KiB
C++

// MIT License
//
// Copyright (c) 2022 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 "library/common.hpp"
#include "library/defines.hpp"
#include "library/timemory.hpp"
#include <array>
#include <cstddef>
#include <string>
namespace omnitrace
{
// this is used to wrap pthread_mutex()
struct pthread_mutex_gotcha : comp::base<pthread_mutex_gotcha, void>
{
static constexpr size_t gotcha_capacity = 13;
using hash_array_t = std::array<size_t, gotcha_capacity>;
using gotcha_data_t = comp::gotcha_data;
TIMEMORY_DEFAULT_OBJECT(pthread_mutex_gotcha)
// string id for component
static std::string label() { return "pthread_mutex_gotcha"; }
// generate the gotcha wrappers
static void configure();
static void shutdown();
static void validate();
int operator()(const gotcha_data_t&, int (*)(pthread_mutex_t*),
pthread_mutex_t*) const;
int operator()(const gotcha_data_t&, int (*)(pthread_spinlock_t*),
pthread_spinlock_t*) const;
int operator()(const gotcha_data_t&, int (*)(pthread_rwlock_t*),
pthread_rwlock_t*) const;
int operator()(const gotcha_data_t&, int (*)(pthread_barrier_t*),
pthread_barrier_t*) const;
int operator()(const gotcha_data_t&, int (*)(pthread_t, void**), pthread_t,
void**) const;
private:
static bool is_disabled();
static hash_array_t& get_hashes();
template <typename... Args>
auto operator()(uintptr_t&&, const gotcha_data_t&, int (*)(Args...), Args...) const;
};
using pthread_mutex_gotcha_t = comp::gotcha<pthread_mutex_gotcha::gotcha_capacity,
quirk::fast, pthread_mutex_gotcha>;
} // namespace omnitrace