SWDEV-480772 - Remove name variable from amd::Monitor class.

Change-Id: Ie2a4fa44f485786227230f8a892e090e718aa30e
Этот коммит содержится в:
kjayapra-amd
2024-08-07 18:10:41 -04:00
коммит произвёл Karthik Jayaprakash
родитель cfdc9dfc36
Коммит 12a39fbf22
27 изменённых файлов: 76 добавлений и 83 удалений
+4 -2
Просмотреть файл
@@ -103,7 +103,8 @@ private:
//Dynamic Code Object
class DynCO : public CodeObject {
amd::Monitor dclock_{"Guards Dynamic Code object", true};
// Guards Dynamic Code object
amd::Monitor dclock_{true};
public:
DynCO() : device_id_(ihipGetDevice()), fb_info_(nullptr) {}
@@ -151,7 +152,8 @@ private:
//Static Code Object
class StatCO: public CodeObject {
amd::Monitor sclock_{"Guards Static Code object", true};
// Guards Static Code object
amd::Monitor sclock_{true};
public:
StatCO();
virtual ~StatCO();
+2 -1
Просмотреть файл
@@ -27,7 +27,8 @@
namespace hip {
static amd::Monitor eventSetLock{"Guards global event set"};
// Guards global event set
static amd::Monitor eventSetLock{};
static std::unordered_set<hipEvent_t> eventSet;
bool Event::ready(eventType type) {
+1 -1
Просмотреть файл
@@ -108,7 +108,7 @@ class Event {
}
public:
Event(uint32_t flags) : flags_(flags), lock_("hipEvent_t", true),
Event(uint32_t flags) : flags_(flags), lock_(true) /* hipEvent_t lock*/,
event_(nullptr), unrecorded_(false), stream_(nullptr) {
// No need to init event_ here as addMarker does that
device_id_ = hip::getCurrentDevice()->deviceId(); // Created in current device ctx
+4 -2
Просмотреть файл
@@ -31,8 +31,10 @@ extern std::unordered_map<GraphExec*, std::pair<hip::Stream*, bool>> GraphExecSt
extern amd::Monitor GraphExecStatusLock_;
std::vector<hip::Stream*> g_captureStreams;
amd::Monitor g_captureStreamsLock{"StreamCaptureGlobalList"};
amd::Monitor g_streamSetLock{"StreamCaptureset"};
// StreamCaptureGlobalList lock
amd::Monitor g_captureStreamsLock{};
// StreamCaptureset lock
amd::Monitor g_streamSetLock{};
std::unordered_set<hip::Stream*> g_allCapturingStreams;
hipError_t ihipGraphDebugDotPrint(hipGraph_t graph, const char* path, unsigned int flags);
hipError_t ihipStreamUpdateCaptureDependencies(hipStream_t stream, hipGraphNode_t* dependencies,
+12 -7
Просмотреть файл
@@ -53,20 +53,25 @@ const char* GetGraphNodeTypeString(uint32_t op) {
namespace hip {
std::unordered_map<GraphExec *, std::pair<hip::Stream *, bool>>
GraphExecStatus_ ROCCLR_INIT_PRIORITY(101);
amd::Monitor GraphExecStatusLock_ ROCCLR_INIT_PRIORITY(101){
"Guards graph execution state", true};
// Guards graph execution state
amd::Monitor GraphExecStatusLock_ ROCCLR_INIT_PRIORITY(101){true};
int GraphNode::nextID = 0;
int Graph::nextID = 0;
std::unordered_set<GraphNode*> GraphNode::nodeSet_;
amd::Monitor GraphNode::nodeSetLock_{"Guards global node set"};
// Guards global node set
amd::Monitor GraphNode::nodeSetLock_{};
std::unordered_set<Graph*> Graph::graphSet_;
amd::Monitor Graph::graphSetLock_{"Guards global graph set"};
// Guards global graph set
amd::Monitor Graph::graphSetLock_{};
std::unordered_set<GraphExec*> GraphExec::graphExecSet_;
amd::Monitor GraphExec::graphExecSetLock_{"Guards global exec graph set"};
// Guards global exec graph set
amd::Monitor GraphExec::graphExecSetLock_{};
std::unordered_set<UserObject*> UserObject::ObjectSet_;
amd::Monitor UserObject::UserObjectLock_{"Guards global user object"};
amd::Monitor GraphNode::WorkerThreadLock_{"Guards mem map add/remove against work thread"};
// Guards global user object
amd::Monitor UserObject::UserObjectLock_{};
// Guards mem map add/remove against work thread
amd::Monitor GraphNode::WorkerThreadLock_{};
hipError_t GraphMemcpyNode1D::ValidateParams(void* dst, const void* src, size_t count,
hipMemcpyKind kind) {
+4 -2
Просмотреть файл
@@ -453,8 +453,10 @@ public:
/// HIP Device class
class Device : public amd::ReferenceCountedObject {
amd::Monitor lock_{"Device lock", true};
amd::Monitor streamSetLock{"Guards device stream set"};
// Device lock
amd::Monitor lock_{true};
// Guards device stream set
amd::Monitor streamSetLock{};
std::unordered_set<hip::Stream*> streamSet;
/// ROCclr context
amd::Context* context_;
+2 -1
Просмотреть файл
@@ -28,7 +28,8 @@
#include "platform/external_memory.hpp"
namespace hip {
amd::Monitor hipArraySetLock{"Guards global hipArray set"};
// Guards global hipArray set
amd::Monitor hipArraySetLock{};
std::unordered_set<hipArray*> hipArraySet;
// ================================================================================================
+1 -1
Просмотреть файл
@@ -199,7 +199,7 @@ class MemoryPool : public amd::ReferenceCountedObject {
MemoryPool(hip::Device* device, const hipMemPoolProps* props = nullptr, bool phys_mem = false)
: busy_heap_(device),
free_heap_(device),
lock_pool_ops_("Pool operations", true),
lock_pool_ops_(true), /* Pool operations */
device_(device),
shared_(nullptr),
max_total_size_(0) {
+4 -2
Просмотреть файл
@@ -43,10 +43,12 @@ struct UniqueFD {
namespace hip {
class PlatformState {
amd::Monitor lock_{"Guards PlatformState globals", true};
// Guards PlatformState globals
amd::Monitor lock_{true};
// global level lock for unique file descritor map: ufd_map_
amd::Monitor ufd_lock_{"Unique FD Store Lock", true};
// Unique FD Store Lock
amd::Monitor ufd_lock_{true};
// Singleton object
static PlatformState* platform_;
+2 -1
Просмотреть файл
@@ -306,7 +306,8 @@ bool RTCCompileProgram::transformOptions(std::vector<std::string>& compile_optio
return findIsa();
}
amd::Monitor RTCProgram::lock_("HIPRTC Program", true);
// HIPRTC Program lock
amd::Monitor RTCProgram::lock_(true);
bool RTCCompileProgram::compile(const std::vector<std::string>& options, bool fgpu_rdc) {
if (!addSource_impl()) {
+2 -1
Просмотреть файл
@@ -72,7 +72,8 @@ template <typename T, typename... Args> inline std::string ToString(T first, Arg
} // namespace internal
} // namespace hiprtc
static amd::Monitor g_hiprtcInitlock{"hiprtcInit lock"};
// hiprtcInit lock
static amd::Monitor g_hiprtcInitlock{};
#define HIPRTC_INIT_API_INTERNAL(...) \
amd::Thread* thread = amd::Thread::current(); \
if (!VDI_CHECK_THREAD(thread)) { \
+4 -2
Просмотреть файл
@@ -301,7 +301,8 @@ std::vector<Device*>* Device::devices_ = nullptr;
AppProfile Device::appProfile_;
Context* Device::glb_ctx_ = nullptr;
Monitor Device::p2p_stage_ops_("P2P Staging Lock", true);
// P2P Staging Lock
Monitor Device::p2p_stage_ops_(true);
Memory* Device::p2p_stage_ = nullptr;
Monitor MemObjMap::AllocatedLock_ ROCCLR_INIT_PRIORITY(101) ("Guards MemObjMap allocation list");
@@ -714,7 +715,8 @@ bool Device::ValidateHsail() {
bool Device::create(const Isa &isa) {
assert(!vaCacheAccess_ && !vaCacheMap_);
isa_ = &isa;
vaCacheAccess_ = new amd::Monitor("VA Cache Ops Lock", true);
// VA Cache Ops Lock
vaCacheAccess_ = new amd::Monitor(true);
if (nullptr == vaCacheAccess_) {
return false;
}
+2 -2
Просмотреть файл
@@ -1265,7 +1265,7 @@ class VirtualDevice : public amd::HeapObject {
VirtualDevice(amd::Device& device)
: device_(device)
, blitMgr_(NULL)
, execution_("Virtual device execution lock", true)
, execution_(true) /* Virtual device execution lock */
, index_(0) {}
//! Destroy this virtual device.
@@ -2156,7 +2156,7 @@ class Device : public RuntimeObject {
uint64_t stack_size_{1024}; //!< Device stack size
device::Memory* initial_heap_buffer_; //!< Initial heap buffer
uint64_t initial_heap_size_{HIP_INITIAL_DM_SIZE}; //!< Initial device heap size
amd::Monitor activeQueuesLock_ {"Guards access to the activeQueues set"};
amd::Monitor activeQueuesLock_ {}; //!< Guards access to the activeQueues set
std::unordered_set<amd::CommandQueue*> activeQueues; //!< The set of active queues
private:
const Isa *isa_; //!< Device isa
+4 -2
Просмотреть файл
@@ -69,7 +69,8 @@ inline static std::vector<std::string> splitSpaceSeparatedString(const char *str
}
#if defined(WITH_COMPILER_LIB)
amd::Monitor Program::buildLock_("HSAIL build lock", true);
// HSAIL build lock
amd::Monitor Program::buildLock_(true);
#endif
// ================================================================================================
@@ -2939,7 +2940,8 @@ bool Program::getGlobalVarFromCodeObj(std::vector<std::string>* var_names) const
#endif
}
amd::Monitor Program::initFiniLock_("Init Fini Launch Lock", true);
// Init Fini Launch Lock
amd::Monitor Program::initFiniLock_(true);
bool Program::runInitFiniKernel(kernel_kind_t kind) const {
amd::HostQueue* queue = nullptr;
+1 -1
Просмотреть файл
@@ -659,7 +659,7 @@ KernelBlitManager::KernelBlitManager(VirtualGPU& gpu, Setup setup)
: DmaBlitManager(gpu, setup),
program_(NULL),
xferBufferSize_(0),
lockXferOps_("Transfer Ops Lock", true) {
lockXferOps_(true) /* Transfer Ops Lock */ {
for (uint i = 0; i < BlitTotal; ++i) {
kernels_[i] = NULL;
}
+7 -7
Просмотреть файл
@@ -803,13 +803,13 @@ Device::ScopedLockVgpus::~ScopedLockVgpus() {
Device::Device()
: NullDevice(),
numOfVgpus_(0),
lockAsyncOps_("Device Async Ops Lock", true),
lockForInitHeap_("Initialization of Heap Resource", true),
lockPAL_("PAL Ops Lock", true),
vgpusAccess_("Virtual GPU List Ops Lock", true),
scratchAlloc_("Scratch Allocation Lock", true),
mapCacheOps_("Map Cache Lock", true),
lockResourceOps_("Resource List Ops Lock", true),
lockAsyncOps_(true), /* Device Async Ops Lock */
lockForInitHeap_(true), /* Initialization of Heap Resource */
lockPAL_(true), /* PAL Ops Lock */
vgpusAccess_(true), /* Virtual GPU List Ops Lock */
scratchAlloc_(true), /* Scratch Allocation Lock */
mapCacheOps_(true), /* Map Cache Lock */
lockResourceOps_(true), /* Resource List Ops Lock */
xferRead_(nullptr),
mapCache_(nullptr),
resourceCache_(nullptr),
+1 -1
Просмотреть файл
@@ -259,7 +259,7 @@ class Device : public NullDevice {
amd::Monitor queue_lock_; //!< Queue lock for access
AqlPacketMgmt aql_packet_mgmt_; //!< AQL packets management class for debugger support
QueueRecycleInfo() : counter_(1), engineType_(Pal::EngineTypeCompute), index_(0),
queue_lock_("Queue lock for sharing", true) {}
queue_lock_(true) /* Queue lock for sharing */ {}
//! Returns the aql packet list
uintptr_t AqlPacketList() const {
+1 -1
Просмотреть файл
@@ -579,7 +579,7 @@ class ResourceCache : public amd::HeapObject {
public:
//! Default constructor
ResourceCache(Device* device, size_t cacheSizeLimit)
: lockCacheOps_("PAL resource cache", true),
: lockCacheOps_(true), /* PAL resource cache */
cacheSize_(0),
lclCacheSize_(0),
persistentCacheSize_(0),
+1 -1
Просмотреть файл
@@ -872,7 +872,7 @@ KernelBlitManager::KernelBlitManager(VirtualGPU& gpu, Setup setup)
: DmaBlitManager(gpu, setup),
program_(nullptr),
xferBufferSize_(0),
lockXferOps_("Transfer Ops Lock", true) {
lockXferOps_(true) /* Transfer Ops Lock*/ {
for (uint i = 0; i < BlitTotal; ++i) {
kernels_[i] = nullptr;
}
+3 -2
Просмотреть файл
@@ -181,7 +181,7 @@ Device::Device(hsa_agent_t bkendDevice)
, xferRead_(nullptr)
, xferWrite_(nullptr)
, freeMem_(0)
, vgpusAccess_("Virtual GPU List Ops Lock", true)
, vgpusAccess_(true) /* Virtual GPU List Ops Lock */
, hsa_exclusive_gpu_access_(false)
, queuePool_(QueuePriority::Total)
, coopHostcallBuffer_(nullptr)
@@ -809,7 +809,8 @@ bool Device::create() {
return false;
}
mapCacheOps_ = new amd::Monitor("Map Cache Lock", true);
// Map Cache Lock
mapCacheOps_ = new amd::Monitor(true);
if (nullptr == mapCacheOps_) {
return false;
}
+1 -1
Просмотреть файл
@@ -98,7 +98,7 @@ public:
ProfilingSignal()
: ts_(nullptr)
, engine_(HwQueueEngine::Compute)
, lock_("Signal Ops Lock", true)
, lock_(true) /* Signal Ops Lock */
, isPacketDispatch_(false)
{
signal_.handle = 0;
+1 -1
Просмотреть файл
@@ -124,7 +124,7 @@ class Timestamp : public amd::ReferenceCountedObject {
, command_(command)
, parsedCommand_(nullptr)
, callback_signal_(hsa_signal_t{})
, lock_("Timestamp lock", true) {}
, lock_(true) /* Timestamp lock */ {}
~Timestamp() {}
+2 -2
Просмотреть файл
@@ -96,7 +96,7 @@ Memory::Memory(Context& context, Type type, Flags flags, size_t size, void* svmP
svmHostAddress_(svmPtr),
resOffset_(0),
flagsEx_(0),
lockMemoryOps_("Memory Ops Lock", true) {
lockMemoryOps_(true) /* Memory Ops Lock */ {
svmPtrCommited_ = (flags & CL_MEM_SVM_FINE_GRAIN_BUFFER) ? true : false;
canBeCached_ = true;
}
@@ -120,7 +120,7 @@ Memory::Memory(Memory& parent, Flags flags, size_t origin, size_t size, Type typ
svmHostAddress_(parent.getSvmPtr()),
resOffset_(0),
flagsEx_(0),
lockMemoryOps_("Memory Ops Lock", true) {
lockMemoryOps_(true) /* Memory Ops Lock */ {
svmPtrCommited_ = parent.isSvmPtrCommited();
canBeCached_ = true;
parent_->retain();
+1 -1
Просмотреть файл
@@ -195,7 +195,7 @@ struct Coord3D {
template <class T>
class SysmemPool {
public:
SysmemPool(): chunk_access_("Sysmem Pool Lock", true) {}
SysmemPool(): chunk_access_(true) /* Sysmem Pool Lock */ {}
~SysmemPool() {
// Release current chunk
if (chunks_.size() == 1) {
+2 -2
Просмотреть файл
@@ -137,7 +137,7 @@ class Program : public RuntimeObject {
language_(language),
symbolTable_(NULL),
programLog_(),
programLock_("Program lock", true) {
programLock_(true) /* Program lock */ {
for (auto i = 0; i != numHeaders; ++i) {
headers_.emplace_back(headers[i]);
headerNames_.emplace_back(headerNames[i]);
@@ -148,7 +148,7 @@ class Program : public RuntimeObject {
Program(Context& context, Language language = Binary)
: context_(context), language_(language),
symbolTable_(NULL),
programLock_("Program lock", true) {}
programLock_(true) /* Program lock */ {}
//! Returns context, associated with the current program.
const Context& context() const { return context_(); }
+2 -11
Просмотреть файл
@@ -33,17 +33,8 @@ MonitorBase::~MonitorBase() {}
namespace legacy_monitor {
Monitor::Monitor(const char* name, bool recursive)
: contendersList_(0), onDeck_(0), waitersList_(NULL), owner_(NULL), recursive_(recursive) {
if (name == NULL) {
const char unknownName[] = "@unknown@";
assert(sizeof(unknownName) < sizeof(name_) && "just checking");
::strncpy(name_, unknownName, sizeof(name_) - 1);
} else {
::strncpy(name_, name, sizeof(name_) - 1);
}
name_[sizeof(name_) - 1] = '\0';
}
Monitor::Monitor(bool recursive)
: contendersList_(0), onDeck_(0), waitersList_(NULL), owner_(NULL), recursive_(recursive) {}
bool Monitor::trySpinLock() {
if (tryLock()) {
+5 -25
Просмотреть файл
@@ -80,7 +80,6 @@ public:
virtual void wait() = 0;
virtual void notify() = 0;
virtual void notifyAll() = 0;
virtual const char* name() const = 0;
};
namespace legacy_monitor {
@@ -97,8 +96,6 @@ class Monitor final: public HeapObject, public MonitorBase {
* and main lock.
*/
std::atomic_intptr_t contendersList_;
//! The Mutex's name
char name_[64];
//! Semaphore of the next thread to contend for the lock.
std::atomic_intptr_t onDeck_;
@@ -135,7 +132,7 @@ class Monitor final: public HeapObject, public MonitorBase {
void setOwner(Thread* thread) { owner_ = thread; }
public:
explicit Monitor(const char* name = NULL, bool recursive = false);
explicit Monitor(bool recursive = false);
~Monitor() {}
//! Try to acquire the lock, return true if successful.
@@ -165,9 +162,6 @@ class Monitor final: public HeapObject, public MonitorBase {
* \note The monitor must be owned before calling notifyAll().
*/
void notifyAll();
//! Return this lock's name.
const char* name() const { return name_; }
};
@@ -176,17 +170,8 @@ class Monitor final: public HeapObject, public MonitorBase {
namespace mutex_monitor {
class Monitor final: public HeapObject, public MonitorBase {
public:
explicit Monitor(const char* name = nullptr, bool recursive = false)
explicit Monitor(bool recursive = false)
: recursive_(recursive) {
if (name == NULL) {
const char unknownName[] = "@unknown@";
assert(sizeof(unknownName) < sizeof(name_) && "just checking");
::strncpy(name_, unknownName, sizeof(name_) - 1);
} else {
::strncpy(name_, name, sizeof(name_) - 1);
}
name_[sizeof(name_) - 1] = '\0';
if (recursive)
new (&rec_mutex_) std::recursive_mutex();
else
@@ -244,16 +229,12 @@ class Monitor final: public HeapObject, public MonitorBase {
*/
void notifyAll() { cv_.notify_all(); }
//! Return this lock's name.
const char* name() const { return name_; }
private:
union {
std::mutex mutex_;
std::recursive_mutex rec_mutex_;
};
std::condition_variable cv_; //!< The condition variable for sync on the mutex
char name_[64]; //!< The mutex's name
const bool recursive_; //!< True if this is a recursive mutex, false otherwise.
};
} // namespace mutex_monitor
@@ -261,12 +242,12 @@ class Monitor final: public HeapObject, public MonitorBase {
// Monitor API wrapper to user
class Monitor {
public:
explicit Monitor(const char* name = nullptr, bool recursive = false) {
explicit Monitor(bool recursive = false) {
if (DEBUG_CLR_USE_STDMUTEX_IN_AMD_MONITOR) {
monitor_ = new mutex_monitor::Monitor(name, recursive);
monitor_ = new mutex_monitor::Monitor(recursive);
}
else {
monitor_ = new legacy_monitor::Monitor(name, recursive);
monitor_ = new legacy_monitor::Monitor(recursive);
}
}
inline ~Monitor() { delete monitor_; };
@@ -276,7 +257,6 @@ public:
inline void wait() { monitor_->wait(); }
inline void notify() { monitor_->notify(); }
inline void notifyAll() { monitor_->notifyAll(); }
inline const char* name() { return monitor_->name(); }
private:
MonitorBase* monitor_;