Generalized updates (#174)
- include/rocprofiler/agent.h
- move rocprofiler_dim3_t
- include/rocprofiler/buffer_tracing.h
- size fields
- update kernel dispatch record
- include/rocprofiler/callback_tracing.h
- remove rocprofiler_callback_tracing_code_object_unload_data_t
- remove rocprofiler_callback_tracing_code_object_register_host_kernel_symbol_data_t
- include/rocprofiler/fwd.h
- added ROCPROFILER_STATUS_ERROR_CONTEXT_CONFLICT
- remove ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_UNLOAD
- remove ROCPROFILER_CALLBACK_TRACING_CODE_OBJECT_DEVICE_KERNEL_SYMBOL_UNREGISTER
- add rocprofiler_kernel_id_t typedef
- add rocprofiler_dim3_t (moved from agent.h)
- lib/common/synchronized.hpp
- rlock/wlock return decltype(auto)
- separate prototype from definition
- lib/common/utility.{hpp,cpp}
- timestamp functions replicating HSA implementation(s)
- init_public_api_struct for setting size field and ensuring certain type traits
- simplified static_cleanup_wrapper
- separate prototype from definition in active_capacity_gate
- lib/rocprofiler/agent.cpp
- tweak get_rocprofiler_agent impl
- lib/rocprofiler/buffer.cpp
- fix buffer message log level
- lib/rocprofiler/context.cpp
- use new paradigm for getting active contexts
- lib/rocprofiler/internal_threading.hpp
- update to simplified static_cleanup_wrapper implementation
- lib/rocprofiler/registration.cpp
- fix deactivating contexts
- lib/rocprofiler/rocprofiler.cpp
- status string for context conflict
- lib/rocprofiler/context/context.*
- correlation_id struct
- new get_active_contexts paradigm
- lib/rocprofiler/counters/core.*
- rocprofiler_packet union
- tweak start/stop context to accept pointer instead of handle
- lib/rocprofiler/counters/dimensions.cpp
- update to new get_rocp_agent() return type
- lib/rocprofiler/hsa/hsa.*
- update to new get_active_contexts paradigm
- update to new correlation id implementation
- guard against hsa.def.cpp direct compilation
- lib/rocprofiler/hsa/queue_controller.*
- update to change in get_rocp_agent return type
- consistent aliases
- lookup function for getting queue pointer from hsa queue id
- lib/rocprofiler/hsa/queue.*
- rocprofiler_packet
- extend queue_info_session_t
- lib/rocprofiler/tests/registration.cpp
- improve diagnostic on perf check for rocprofiler_lib.callback_registration_lambda_with_result
This commit is contained in:
committed by
GitHub
parent
63775f241a
commit
55f2dabbb3
@@ -75,24 +75,10 @@ public:
|
||||
Synchronized& operator=(const Synchronized&) = delete;
|
||||
|
||||
template <typename FuncT, typename... Args>
|
||||
auto rlock(FuncT&& lambda, Args&&... args) const
|
||||
{
|
||||
static_assert(std::is_invocable<FuncT, const value_type&, Args...>::value,
|
||||
"function must accept const reference to locked type");
|
||||
|
||||
auto lock = std::shared_lock{m_mutex};
|
||||
return std::forward<FuncT>(lambda)(m_data, std::forward<Args>(args)...);
|
||||
}
|
||||
decltype(auto) rlock(FuncT&& lambda, Args&&... args) const;
|
||||
|
||||
template <typename FuncT, typename... Args>
|
||||
auto wlock(FuncT&& lambda, Args&&... args)
|
||||
{
|
||||
static_assert(std::is_invocable<FuncT, value_type&, Args...>::value,
|
||||
"function must accept reference to locked type");
|
||||
|
||||
auto lock = std::unique_lock{m_mutex};
|
||||
return std::forward<FuncT>(lambda)(m_data, std::forward<Args>(args)...);
|
||||
}
|
||||
decltype(auto) wlock(FuncT&& lambda, Args&&... args);
|
||||
|
||||
// This overload to wlock allows a synchronized map whose keys map to synchronized data to
|
||||
// use a read lock on the key data and then a write lock on the mapped data.
|
||||
@@ -100,42 +86,86 @@ public:
|
||||
typename... Args,
|
||||
bool EnableForMappedType = IsMappedTypeV,
|
||||
std::enable_if_t<EnableForMappedType, int> = 0>
|
||||
auto wlock(FuncT&& lambda, Args&&... args) const
|
||||
{
|
||||
return const_cast<this_type*>(this)->wlock(std::forward<FuncT>(lambda),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
decltype(auto) wlock(FuncT&& lambda, Args&&... args) const;
|
||||
|
||||
// Upgradable lock. If read returns false, write will be called with a unique_lock.
|
||||
// Essentially a helper function that does .rlock() followed by .wlock().
|
||||
template <typename ReadFuncT, typename WriteFuncT, typename... Args>
|
||||
bool ulock(ReadFuncT&& read, WriteFuncT&& write, Args&&... args)
|
||||
{
|
||||
static_assert(std::is_invocable<ReadFuncT, const value_type&, Args...>::value,
|
||||
"read function must accept const reference to locked type");
|
||||
static_assert(std::is_invocable<WriteFuncT, value_type&, Args...>::value,
|
||||
"write function must accept reference to locked type");
|
||||
|
||||
using read_return_type = std::invoke_result_t<ReadFuncT, const value_type&, Args...>;
|
||||
using write_return_type = std::invoke_result_t<WriteFuncT, value_type&, Args...>;
|
||||
|
||||
static_assert(std::is_same<read_return_type, write_return_type>::value,
|
||||
"read and write functions must return same type");
|
||||
static_assert(std::is_same<read_return_type, bool>::value,
|
||||
"read/write functions must return bool");
|
||||
|
||||
{
|
||||
auto lock = std::shared_lock{m_mutex};
|
||||
if(read(m_data, std::forward<Args>(args)...)) return true;
|
||||
}
|
||||
|
||||
auto lock = std::unique_lock{m_mutex};
|
||||
return write(m_data, std::forward<Args>(args)...);
|
||||
}
|
||||
bool ulock(ReadFuncT&& read, WriteFuncT&& write, Args&&... args);
|
||||
|
||||
private:
|
||||
mutable std::shared_mutex m_mutex = {};
|
||||
value_type m_data = {};
|
||||
};
|
||||
|
||||
//
|
||||
// member definitions
|
||||
//
|
||||
template <typename LockedType, bool IsMappedTypeV>
|
||||
template <typename FuncT, typename... Args>
|
||||
decltype(auto)
|
||||
Synchronized<LockedType, IsMappedTypeV>::rlock(FuncT&& lambda, Args&&... args) const
|
||||
{
|
||||
static_assert(std::is_invocable<FuncT, const value_type&, Args...>::value,
|
||||
"function must accept const reference to locked type");
|
||||
|
||||
auto lock = std::shared_lock{m_mutex};
|
||||
return std::forward<FuncT>(lambda)(m_data, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename LockedType, bool IsMappedTypeV>
|
||||
template <typename FuncT, typename... Args>
|
||||
decltype(auto)
|
||||
Synchronized<LockedType, IsMappedTypeV>::wlock(FuncT&& lambda, Args&&... args)
|
||||
{
|
||||
static_assert(std::is_invocable<FuncT, value_type&, Args...>::value,
|
||||
"function must accept reference to locked type");
|
||||
|
||||
auto lock = std::unique_lock{m_mutex};
|
||||
return std::forward<FuncT>(lambda)(m_data, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// This overload to wlock allows a synchronized map whose keys map to synchronized data to
|
||||
// use a read lock on the key data and then a write lock on the mapped data.
|
||||
template <typename LockedType, bool IsMappedTypeV>
|
||||
template <typename FuncT,
|
||||
typename... Args,
|
||||
bool EnableForMappedType,
|
||||
std::enable_if_t<EnableForMappedType, int>>
|
||||
decltype(auto)
|
||||
Synchronized<LockedType, IsMappedTypeV>::wlock(FuncT&& lambda, Args&&... args) const
|
||||
{
|
||||
return const_cast<this_type*>(this)->wlock(std::forward<FuncT>(lambda),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// Upgradable lock. If read returns false, write will be called with a unique_lock.
|
||||
// Essentially a helper function that does .rlock() followed by .wlock().
|
||||
template <typename LockedType, bool IsMappedTypeV>
|
||||
template <typename ReadFuncT, typename WriteFuncT, typename... Args>
|
||||
bool
|
||||
Synchronized<LockedType, IsMappedTypeV>::ulock(ReadFuncT&& read, WriteFuncT&& write, Args&&... args)
|
||||
{
|
||||
static_assert(std::is_invocable<ReadFuncT, const value_type&, Args...>::value,
|
||||
"read function must accept const reference to locked type");
|
||||
static_assert(std::is_invocable<WriteFuncT, value_type&, Args...>::value,
|
||||
"write function must accept reference to locked type");
|
||||
|
||||
using read_return_type = std::invoke_result_t<ReadFuncT, const value_type&, Args...>;
|
||||
using write_return_type = std::invoke_result_t<WriteFuncT, value_type&, Args...>;
|
||||
|
||||
static_assert(std::is_same<read_return_type, write_return_type>::value,
|
||||
"read and write functions must return same type");
|
||||
static_assert(std::is_same<read_return_type, bool>::value,
|
||||
"read/write functions must return bool");
|
||||
|
||||
{
|
||||
auto lock = std::shared_lock{m_mutex};
|
||||
if(read(m_data, std::forward<Args>(args)...)) return true;
|
||||
}
|
||||
|
||||
auto lock = std::unique_lock{m_mutex};
|
||||
return write(m_data, std::forward<Args>(args)...);
|
||||
}
|
||||
} // namespace common
|
||||
} // namespace rocprofiler
|
||||
|
||||
Reference in New Issue
Block a user