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


[ROCm/hip commit: d491dbd796]
Αυτή η υποβολή περιλαμβάνεται σε:
German Andryeyev
2020-07-15 15:11:59 -04:00
υποβλήθηκε από Subodh Gupta
γονέας c1456808c5
υποβολή ddd3d77037
2 αρχεία άλλαξαν με 8 προσθήκες και 3 διαγραφές
@@ -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);