From 628232efc797ee565661ae73a170de14be71edcd Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 15 May 2015 11:14:53 -0400
Subject: [PATCH] P4 to Git Change 1151415 by jatang@jatang-opencl-hsa-stg1 on
2015/05/15 11:06:22
EPR #412821 - Fix a crash when the ThreadTrace Object is freed before a ThreadTrace command is processed.
Also change 'None' to 'Undefined', since 'None' is a macro defined in X.h.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#77 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/threadtrace.hpp#5 edit
[ROCm/clr commit: 5da96e702c4732dfb9867b85ce945fe31e5401ea]
---
.../clr/rocclr/runtime/platform/command.hpp | 28 +++++++++++++++++--
.../rocclr/runtime/platform/threadtrace.hpp | 4 +--
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/projects/clr/rocclr/runtime/platform/command.hpp b/projects/clr/rocclr/runtime/platform/command.hpp
index f84e038f44..4627e8b03b 100644
--- a/projects/clr/rocclr/runtime/platform/command.hpp
+++ b/projects/clr/rocclr/runtime/platform/command.hpp
@@ -23,6 +23,8 @@
#include "device/device.hpp"
#include "utils/concurrent.hpp"
#include "platform/memory.hpp"
+#include "platform/perfctr.hpp"
+#include "platform/threadtrace.hpp"
#include "CL/cl_ext.h"
@@ -1043,7 +1045,18 @@ public:
: Command(queue, 0, eventWaitList)
, counterList_(counterList)
, state_(state)
- { }
+ {
+ for (uint i = 0; i < counterList_.size(); ++i) {
+ counterList_[i]->retain();
+ }
+ }
+
+ void releaseResources() {
+ for (uint i = 0; i < counterList_.size(); ++i) {
+ counterList_[i]->release();
+ }
+ Command::releaseResources();
+ }
//! Gets the number of PerfCounter objects
size_t getNumCounters() const { return counterList_.size(); }
@@ -1090,9 +1103,11 @@ public:
obj->retain();
memObjects_[i] = obj;
}
+ threadTrace_.retain();
}
//! Release all resources associated with this command
void releaseResources() {
+ threadTrace_.release();
for(std::vector::const_iterator itr = memObjects_.begin();
itr != memObjects_.end(); itr++) {
(*itr)->release();
@@ -1143,7 +1158,7 @@ public:
Resume = 3 //!< Issue a resume command
};
- //! Construct a new PerfCounterCommand
+ //! Construct a new ThreadTraceCommand
ThreadTraceCommand(
HostQueue& queue,
const EventWaitList& eventWaitList,
@@ -1160,6 +1175,13 @@ public:
if (threadTraceConfig_) {
memcpy(threadTraceConfig_, threadTraceConfig, size);
}
+ threadTrace_.retain();
+ }
+
+ //! Release all resources associated with this command
+ void releaseResources() {
+ threadTrace_.release();
+ Command::releaseResources();
}
//! Get the thread trace object
@@ -1176,7 +1198,7 @@ public:
void* threadTraceConfig() const { return threadTraceConfig_; }
private:
- ThreadTrace& threadTrace_; //!< The list of performance counters
+ ThreadTrace& threadTrace_; //!< The list of performance counters
State state_; //!< State of the issued command
};
diff --git a/projects/clr/rocclr/runtime/platform/threadtrace.hpp b/projects/clr/rocclr/runtime/platform/threadtrace.hpp
index 377ec6c7da..80d0ec8699 100644
--- a/projects/clr/rocclr/runtime/platform/threadtrace.hpp
+++ b/projects/clr/rocclr/runtime/platform/threadtrace.hpp
@@ -29,7 +29,7 @@ class ThreadTrace : public RuntimeObject
{
public:
enum State {
- None,
+ Undefined,
MemoryBound,
Begin,
End,
@@ -64,7 +64,7 @@ public:
const Device& device) //!< device object
: deviceThreadTrace_(NULL)
,device_(device)
- ,state_(None)
+ ,state_(Undefined)
{ }
//! Get the thread trace's associated device