Simplify isStatusCompletedByTermination.

- remove default parameter.
- remove branch.

Change-Id: Ia829adfc684057516a2fc204e853ad3948853e22
This commit is contained in:
Mrozek, Michal
2019-07-08 18:07:46 +02:00
committed by sys_ocldev
parent 042901857f
commit baa11187c3
5 changed files with 46 additions and 16 deletions

View File

@@ -141,10 +141,11 @@ bool CommandQueue::isQueueBlocked() {
TakeOwnershipWrapper<CommandQueue> takeOwnershipWrapper(*this);
//check if we have user event and if so, if it is in blocked state.
if (this->virtualEvent) {
if (this->virtualEvent->peekExecutionStatus() <= CL_SUBMITTED) {
auto executionStatus = this->virtualEvent->peekExecutionStatus();
if (executionStatus <= CL_SUBMITTED) {
UNRECOVERABLE_IF(this->virtualEvent == nullptr);
if (this->virtualEvent->isStatusCompletedByTermination() == false) {
if (this->virtualEvent->isStatusCompletedByTermination(executionStatus) == false) {
taskCount = this->virtualEvent->peekTaskCount();
flushStamp->setStamp(this->virtualEvent->flushStamp->peekStamp());
taskLevel = this->virtualEvent->taskLevel;

View File

@@ -358,7 +358,7 @@ void Event::updateExecutionStatus() {
}
if (statusSnapshot == CL_QUEUED) {
bool abortBlockedTasks = isStatusCompletedByTermination(&statusSnapshot);
bool abortBlockedTasks = isStatusCompletedByTermination(statusSnapshot);
submitCommand(abortBlockedTasks);
transitionExecutionStatus(CL_SUBMITTED);
executeCallbacks(CL_SUBMITTED);
@@ -399,7 +399,7 @@ void Event::unblockEventsBlockedByThis(int32_t transitionStatus) {
uint32_t taskLevelToPropagate = Event::eventNotReady;
if (isStatusCompletedByTermination(&transitionStatus) == false) {
if (isStatusCompletedByTermination(transitionStatus) == false) {
//if we are event on top of the tree , obtain taskLevel from CSR
if (taskLevel == Event::eventNotReady) {
this->taskLevel = getTaskLevel();
@@ -435,12 +435,12 @@ bool Event::setStatus(cl_int status) {
return false;
}
if (peekIsBlocked() && (isStatusCompletedByTermination(&status) == false)) {
if (peekIsBlocked() && (isStatusCompletedByTermination(status) == false)) {
return false;
}
if ((status == CL_SUBMITTED) || (isStatusCompleted(&status))) {
bool abortBlockedTasks = isStatusCompletedByTermination(&status);
bool abortBlockedTasks = isStatusCompletedByTermination(status);
submitCommand(abortBlockedTasks);
}
@@ -563,7 +563,7 @@ inline void Event::unblockEventBy(Event &event, uint32_t taskLevel, int32_t tran
int32_t blockerStatus = transitionStatus;
DEBUG_BREAK_IF(!(isStatusCompleted(&blockerStatus) || peekIsSubmitted(&blockerStatus)));
if ((numEventsBlockingThis > 0) && (isStatusCompletedByTermination(&blockerStatus) == false)) {
if ((numEventsBlockingThis > 0) && (isStatusCompletedByTermination(blockerStatus) == false)) {
return;
}
DBG_LOG(EventsDebugEnable, "Event", this, "is unblocked by", &event);
@@ -575,7 +575,7 @@ inline void Event::unblockEventBy(Event &event, uint32_t taskLevel, int32_t tran
}
int32_t statusToPropagate = CL_SUBMITTED;
if (isStatusCompletedByTermination(&blockerStatus)) {
if (isStatusCompletedByTermination(blockerStatus)) {
statusToPropagate = blockerStatus;
}
setStatus(statusToPropagate);
@@ -625,7 +625,7 @@ void Event::addCallback(Callback::ClbFuncT fn, cl_int type, void *data) {
void Event::executeCallbacks(int32_t executionStatusIn) {
int32_t execStatus = executionStatusIn;
bool terminated = isStatusCompletedByTermination(&execStatus);
bool terminated = isStatusCompletedByTermination(execStatus);
ECallbackTarget target;
if (terminated) {
target = ECallbackTarget::Completed;

View File

@@ -184,12 +184,8 @@ class Event : public BaseObject<_cl_event>, public IDNode<Event> {
// Note from OCL spec :
// "A negative integer value causes all enqueued commands that wait on this user event
// to be terminated."
bool isStatusCompletedByTermination(const int32_t *executionStatusSnapshot = nullptr) const {
if (executionStatusSnapshot == nullptr) {
return (peekExecutionStatus() < 0);
} else {
return (*executionStatusSnapshot < 0);
}
bool isStatusCompletedByTermination(const int32_t executionStatusSnapshot) const {
return executionStatusSnapshot < 0;
}
bool peekIsSubmitted(const int32_t *executionStatusSnapshot = nullptr) const {

View File

@@ -76,7 +76,7 @@ uint32_t VirtualEvent::getTaskLevel() {
bool VirtualEvent::setStatus(cl_int status) {
// virtual events are just helper events and will have either
// "waiting" (after construction) or "complete" (on change if not blocked) execution state
if (isStatusCompletedByTermination(&status) == false) {
if (isStatusCompletedByTermination(status) == false) {
status = CL_COMPLETE;
}
return Event::setStatus(status);