SWDEV-480209 - Make internal callbacks non-blocking
Change-Id: Ic918d08f341abfd9a7c167d09f9c723cdc43157f
This commit is contained in:
committed by
Anusha Godavarthy Surya
vanhempi
c9dd95bf6c
commit
683a942364
@@ -190,10 +190,11 @@ bool Event::resetStatus(int32_t status) {
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
bool Event::setCallback(int32_t status, Event::CallBackFunction callback, void* data) {
|
||||
bool Event::setCallback(int32_t status, Event::CallBackFunction callback, void* data,
|
||||
bool blocking) {
|
||||
assert(status >= CL_COMPLETE && status <= CL_QUEUED && "invalid status");
|
||||
|
||||
CallBackEntry* entry = new CallBackEntry(status, callback, data);
|
||||
CallBackEntry* entry = new CallBackEntry(status, callback, data, blocking);
|
||||
if (entry == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -72,10 +72,10 @@ class Event : public RuntimeObject {
|
||||
|
||||
std::atomic<CallBackFunction> callback_; //!< callback function pointer.
|
||||
void* data_; //!< user data passed to the callback function.
|
||||
int32_t status_; //!< execution status triggering the callback.
|
||||
|
||||
CallBackEntry(int32_t status, CallBackFunction callback, void* data)
|
||||
: callback_(callback), data_(data), status_(status) {}
|
||||
int32_t status_; //!< execution status triggering the callback.
|
||||
bool blocking_; //!< TRUE if callback is blocking
|
||||
CallBackEntry(int32_t status, CallBackFunction callback, void* data, bool blocking)
|
||||
: callback_(callback), data_(data), status_(status), blocking_(blocking) {}
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -173,7 +173,7 @@ class Event : public RuntimeObject {
|
||||
int32_t status() const { return status_.load(std::memory_order_relaxed); }
|
||||
|
||||
//! Insert the given \a callback into the callback stack.
|
||||
bool setCallback(int32_t status, CallBackFunction callback, void* data);
|
||||
bool setCallback(int32_t status, CallBackFunction callback, void* data, bool blocking = true);
|
||||
|
||||
/*! \brief Set the event status.
|
||||
*
|
||||
|
||||
@@ -57,8 +57,9 @@ HostQueue::HostQueue(Context& context, Device& device, cl_command_queue_properti
|
||||
}
|
||||
|
||||
bool HostQueue::terminate() {
|
||||
// incase of force destroy skip checking on the last command
|
||||
if (AMD_DIRECT_DISPATCH) {
|
||||
if (vdev() != nullptr) {
|
||||
if (!forceDestroy_ && vdev() != nullptr) {
|
||||
// If the queue still has the last command, then wait and release it
|
||||
// We must be in protected way to get last command when calling
|
||||
// awaitCompletion() where lastCommand will be released and possibly
|
||||
|
||||
@@ -294,6 +294,9 @@ class HostQueue : public CommandQueue {
|
||||
//! Get queue status
|
||||
bool GetQueueStatus() { return isActive_; }
|
||||
|
||||
//! Set the force destory to terminate queue without checking last command
|
||||
void SetForceDestroy(bool forceDestroy) { forceDestroy_ = forceDestroy; }
|
||||
|
||||
uint64_t getQueueID() {
|
||||
return thread_.vdev()->getQueueID();
|
||||
}
|
||||
@@ -305,6 +308,7 @@ private:
|
||||
|
||||
//! True if this command queue is active
|
||||
bool isActive_;
|
||||
bool forceDestroy_ = false; //!< Destroy the queue in the current state
|
||||
};
|
||||
|
||||
class DeviceQueue : public CommandQueue {
|
||||
|
||||
Viittaa uudesa ongelmassa
Block a user