From 458cca25ced4dc0b6c8a6ceb1c47545f707efb04 Mon Sep 17 00:00:00 2001
From: foreman
Date: Tue, 7 Apr 2015 12:03:48 -0400
Subject: [PATCH] P4 to Git Change 1138047 by gandryey@gera-w8 on 2015/04/07
11:38:28
ECR #304775 - Some code clean-up
- Remove amd::Context reference from the event object. Runtime can use queue to get the context for the limited number of use cases
- User/GL events will keep the context as a member
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_event.cpp#8 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.cpp#69 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#75 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#120 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.hpp#91 edit
---
rocclr/runtime/platform/command.cpp | 13 ++++++++-----
rocclr/runtime/platform/command.hpp | 28 ++++++++++++++++++----------
rocclr/runtime/platform/memory.cpp | 2 +-
rocclr/runtime/platform/memory.hpp | 2 +-
4 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/rocclr/runtime/platform/command.cpp b/rocclr/runtime/platform/command.cpp
index 0b71140125..a2fe754606 100644
--- a/rocclr/runtime/platform/command.cpp
+++ b/rocclr/runtime/platform/command.cpp
@@ -26,17 +26,15 @@
namespace amd {
Event::Event(HostQueue& queue)
- : context_(queue.context())
- , callbacks_(NULL)
+ : callbacks_(NULL)
, status_(CL_INT_MAX)
, profilingInfo_(
queue.properties().test(CL_QUEUE_PROFILING_ENABLE)
|| Agent::shouldPostEventEvents())
{ notified_.clear(); }
-Event::Event(Context& context)
- : context_(context)
- , callbacks_(NULL)
+Event::Event()
+ : callbacks_(NULL)
, status_(CL_SUBMITTED)
{ notified_.clear(); }
@@ -252,6 +250,11 @@ Command::enqueue()
}
}
+const Context&
+Command::context() const
+{
+ return queue_->context();
+}
NDRangeKernelCommand::NDRangeKernelCommand(
HostQueue& queue,
diff --git a/rocclr/runtime/platform/command.hpp b/rocclr/runtime/platform/command.hpp
index e7311c72ba..f84e038f44 100644
--- a/rocclr/runtime/platform/command.hpp
+++ b/rocclr/runtime/platform/command.hpp
@@ -75,7 +75,6 @@ private:
Monitor lock_;
- SharedReference context_; //!< context associated with this event.
std::atomic callbacks_; //!< linked list of callback entries.
volatile cl_int status_; //!< current execution status.
std::atomic_flag notified_; //!< Command queue was notified
@@ -117,8 +116,8 @@ protected:
} profilingInfo_;
- //! Construct a new event in the given \a context.
- Event(Context& context);
+ //! Construct a new event.
+ Event();
//! Construct a new event associated to the given command \a queue.
Event(HostQueue& queue);
@@ -138,10 +137,8 @@ protected:
void processCallbacks(cl_int status) const;
public:
-
//! Return the context for this event.
- Context& context() { return context_(); }
- const Context& context() const { return context_(); }
+ virtual const Context& context() const = 0;
//! Return the command this event is associated with.
inline Command& command();
@@ -219,8 +216,8 @@ protected:
const EventWaitList& eventWaitList = nullWaitList);
//! Construct a new command of the given OpenCL type.
- Command(Context& context, cl_command_type type) :
- Event(context), queue_(NULL), next_(NULL), type_(type),
+ Command(cl_command_type type) :
+ Event(), queue_(NULL), next_(NULL), type_(type),
exception_(0), data_(NULL), eventWaitList_(nullWaitList)
{ }
@@ -280,27 +277,36 @@ public:
//! Get the next GPU command
Command* getNext() const { return next_; }
+ //! Return the context for this event.
+ virtual const Context& context() const;
};
class UserEvent : public Command
{
+ const Context& context_;
+
public:
- UserEvent(Context& context) : Command(context, CL_COMMAND_USER) {
+ UserEvent(Context& context) : Command(CL_COMMAND_USER), context_(context) {
setStatus(CL_SUBMITTED);
}
virtual void submit(device::VirtualDevice& device) {
ShouldNotCallThis();
}
+
+ virtual const Context& context() const { return context_; }
};
class ClGlEvent : public Command
{
private:
+ const Context& context_;
bool waitForFence();
public:
- ClGlEvent(Context& context) : Command(context, CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR) {
+ ClGlEvent(Context& context)
+ : Command(CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR)
+ , context_(context) {
setStatus(CL_SUBMITTED);
}
@@ -311,6 +317,8 @@ public:
bool awaitCompletion() {
return waitForFence();
}
+
+ virtual const Context& context() const { return context_; }
};
inline Command&
diff --git a/rocclr/runtime/platform/memory.cpp b/rocclr/runtime/platform/memory.cpp
index d31f820cdd..1fcb5b0a0e 100644
--- a/rocclr/runtime/platform/memory.cpp
+++ b/rocclr/runtime/platform/memory.cpp
@@ -1543,7 +1543,7 @@ SvmBuffer::malloc(
}
void
-SvmBuffer::free(Context& context, void* ptr)
+SvmBuffer::free(const Context& context, void* ptr)
{
Remove(reinterpret_cast(ptr));
context.svmFree(ptr);
diff --git a/rocclr/runtime/platform/memory.hpp b/rocclr/runtime/platform/memory.hpp
index 24bc78b5e3..a8edbc09d0 100644
--- a/rocclr/runtime/platform/memory.hpp
+++ b/rocclr/runtime/platform/memory.hpp
@@ -647,7 +647,7 @@ public:
size_t alignment);
//! Release shared buffer
- static void free(Context& context, void* ptr);
+ static void free(const Context& context, void* ptr);
//! Fill the destination buffer \a dst with the contents of the source
//! buffer \a src \times times.