Skip to content

Commit

Permalink
Modified m_RunningCount read-modify-write operations to use memory_or…
Browse files Browse the repository at this point in the history
…der_acq_rel
  • Loading branch information
dougbinks committed Jun 10, 2023
1 parent 845b837 commit d1752d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/TaskScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ bool TaskScheduler::TryRunTask( uint32_t threadNum_, uint32_t priority_, uint32_
}
SplitAndAddTask( threadNum_, subTask, rangeToSplit );
taskToRun.pTask->ExecuteRange( taskToRun.partition, threadNum_ );
int prevCount = taskToRun.pTask->m_RunningCount.fetch_sub(1,std::memory_order_release );
int prevCount = taskToRun.pTask->m_RunningCount.fetch_sub(1,std::memory_order_acq_rel );
if( gc_TaskStartCount == prevCount )
{
TaskComplete( taskToRun.pTask, true, threadNum_ );
Expand All @@ -611,7 +611,7 @@ bool TaskScheduler::TryRunTask( uint32_t threadNum_, uint32_t priority_, uint32_
{
// the task has already been divided up by AddTaskSetToPipe, so just run it
subTask.pTask->ExecuteRange( subTask.partition, threadNum_ );
int prevCount = subTask.pTask->m_RunningCount.fetch_sub(1,std::memory_order_release );
int prevCount = subTask.pTask->m_RunningCount.fetch_sub(1,std::memory_order_acq_rel );
if( gc_TaskStartCount == prevCount )
{
TaskComplete( subTask.pTask, true, threadNum_ );
Expand Down Expand Up @@ -844,7 +844,7 @@ void TaskScheduler::SplitAndAddTask( uint32_t threadNum_, SubTaskSet subTask_, u
}
int32_t countToRemove = upperBoundNumToAdd - numAdded;
ENKI_ASSERT( countToRemove > 0 );
int prevCount = subTask_.pTask->m_RunningCount.fetch_sub( countToRemove, std::memory_order_release );
int prevCount = subTask_.pTask->m_RunningCount.fetch_sub( countToRemove, std::memory_order_acq_rel );
if( countToRemove-1 + gc_TaskStartCount == prevCount )
{
TaskComplete( subTask_.pTask, false, threadNum_ );
Expand Down Expand Up @@ -880,7 +880,7 @@ void TaskScheduler::AddTaskSetToPipeInt( ITaskSet* pTaskSet_, uint32_t threadNum
subTask.partition.start = 0;
subTask.partition.end = pTaskSet_->m_SetSize;
SplitAndAddTask( threadNum_, subTask, rangeToSplit );
int prevCount = pTaskSet_->m_RunningCount.fetch_sub(1, std::memory_order_release );
int prevCount = pTaskSet_->m_RunningCount.fetch_sub(1, std::memory_order_acq_rel );
if( gc_TaskStartCount == prevCount )
{
TaskComplete( pTaskSet_, true, threadNum_ );
Expand Down Expand Up @@ -963,7 +963,7 @@ void TaskScheduler::RunPinnedTasks( uint32_t threadNum_, uint32_t priority_ )
if( pPinnedTaskSet )
{
pPinnedTaskSet->Execute();
pPinnedTaskSet->m_RunningCount.fetch_sub(1,std::memory_order_release);
pPinnedTaskSet->m_RunningCount.fetch_sub(1,std::memory_order_acq_rel);
TaskComplete( pPinnedTaskSet, true, threadNum_ );
}
} while( pPinnedTaskSet );
Expand Down
2 changes: 1 addition & 1 deletion src/TaskScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ namespace enki

inline void ICompletable::OnDependenciesComplete( TaskScheduler* pTaskScheduler_, uint32_t threadNum_ )
{
m_RunningCount.fetch_sub( 1, std::memory_order_release );
m_RunningCount.fetch_sub( 1, std::memory_order_acq_rel );
pTaskScheduler_->TaskComplete( this, true, threadNum_ );
}

Expand Down

0 comments on commit d1752d0

Please sign in to comment.