Grab the event lock before fetching the last command
Hip applications assume that hipEventRecord called from multiple threads will contain exactly the last queued command to the stream. Change-Id: I1da3259f143d7670d0870d9a47c08e32336b2222
Bu işleme şunda yer alıyor:
işlemeyi yapan:
Subodh Gupta
ebeveyn
9f3cf75713
işleme
d491dbd796
@@ -230,6 +230,7 @@ hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop) {
|
||||
HIP_RETURN(eStart->elapsedTime(*eStop, *ms), "Elapsed Time = ", *ms);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) {
|
||||
HIP_INIT_API(hipEventRecord, event, stream);
|
||||
|
||||
@@ -237,6 +238,9 @@ hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) {
|
||||
HIP_RETURN(hipErrorInvalidHandle);
|
||||
}
|
||||
|
||||
hip::Event* e = reinterpret_cast<hip::Event*>(event);
|
||||
amd::ScopedLock lock(e->lock());
|
||||
|
||||
amd::HostQueue* queue = hip::getQueue(stream);
|
||||
amd::Command* command = queue->getLastQueuedCommand(true);
|
||||
if (command == nullptr) {
|
||||
@@ -244,12 +248,11 @@ hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) {
|
||||
command->enqueue();
|
||||
}
|
||||
|
||||
hip::Event* e = reinterpret_cast<hip::Event*>(event);
|
||||
e->addMarker(queue, command, true);
|
||||
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
hipError_t hipEventSynchronize(hipEvent_t event) {
|
||||
HIP_INIT_API(hipEventSynchronize, event);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
|
||||
class Event {
|
||||
public:
|
||||
Event(unsigned int flags) : flags(flags), lock_("hipEvent_t"),
|
||||
Event(unsigned int flags) : flags(flags), lock_("hipEvent_t", true),
|
||||
event_(nullptr), recorded_(false) {
|
||||
// No need to init event_ here as addMarker does that
|
||||
}
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
|
||||
void addMarker(amd::HostQueue* queue, amd::Command* command, bool record);
|
||||
|
||||
amd::Monitor& lock() { return lock_; }
|
||||
|
||||
private:
|
||||
amd::Monitor lock_;
|
||||
amd::HostQueue* stream_;
|
||||
|
||||
Yeni konuda referans
Bir kullanıcı engelle