Skip to content

Commit

Permalink
Merge pull request #269 from insertinterestingnamehere/fences
Browse files Browse the repository at this point in the history
Adjust Fences on X86 to Correct Performance Regression
  • Loading branch information
insertinterestingnamehere authored Sep 3, 2024
2 parents cb0c514 + 65ec77a commit 1aa1958
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/qthread/qthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ using std::memory_order_relaxed;
#define Q_ALIGNED(x) __attribute__((aligned(x)))
#endif

#if QTHREAD_ASSEMBLY_ARCH == QTHREAD_AMD64
#define QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES
#endif

Q_STARTCXX /* */
/* NOTE!!!!!!!!!!!
* Reads and writes operate on aligned_t-size segments of memory.
Expand Down
8 changes: 8 additions & 0 deletions src/feb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,9 @@ int API_FUNC qthread_writeEF(aligned_t *restrict dest,
&me->thread_state, QTHREAD_STATE_FEB_BLOCKED, memory_order_relaxed);
me->rdata->blockedon.addr = m;
QTHREAD_WAIT_TIMER_START();
#ifndef QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES
MACHINE_FENCE;
#endif
qthread_back_to_master(me);
QTHREAD_WAIT_TIMER_STOP(me, febwait);
#ifdef QTHREAD_USE_EUREKAS
Expand Down Expand Up @@ -1300,7 +1302,9 @@ int API_FUNC qthread_writeFF(aligned_t *restrict dest,
&me->thread_state, QTHREAD_STATE_FEB_BLOCKED, memory_order_relaxed);
me->rdata->blockedon.addr = m;
QTHREAD_WAIT_TIMER_START();
#ifndef QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES
MACHINE_FENCE;
#endif
qthread_back_to_master(me);
QTHREAD_WAIT_TIMER_STOP(me, febwait);
#ifdef QTHREAD_USE_EUREKAS
Expand Down Expand Up @@ -1414,7 +1418,9 @@ int API_FUNC qthread_readFF(aligned_t *restrict dest,
me->rdata->blockedon.addr = m;
QTHREAD_WAIT_TIMER_START();
qthread_back_to_master(me);
#ifndef QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES
MACHINE_FENCE;
#endif
QTHREAD_WAIT_TIMER_STOP(me, febwait);
#ifdef QTHREAD_USE_EUREKAS
qt_eureka_check(0);
Expand Down Expand Up @@ -1600,7 +1606,9 @@ int API_FUNC qthread_readFE(aligned_t *restrict dest,
me->rdata->blockedon.addr = m;
QTHREAD_WAIT_TIMER_START();
qthread_back_to_master(me);
#ifndef QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES
MACHINE_FENCE;
#endif
QTHREAD_WAIT_TIMER_STOP(me, febwait);
#ifdef QTHREAD_USE_EUREKAS
qt_eureka_check(0);
Expand Down

0 comments on commit 1aa1958

Please sign in to comment.