Skip to content

Commit 692228c

Browse files
author
Gang Chen
authored
[SYCL][ESIMD] always set up fence before barrier as required by HW (#3083)
Signed-off-by: Gang Y Chen <[email protected]>
1 parent 18f7cae commit 692228c

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

sycl/include/CL/sycl/INTEL/esimd/esimd_memory.hpp

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -583,15 +583,18 @@ ESIMD_NODEBUG ESIMD_INLINE
583583
src1.data(), pred.data());
584584
}
585585

586-
/// Generic work-group barrier.
587-
/// \ingroup sycl_esimd
588-
inline ESIMD_NODEBUG void esimd_barrier() { __esimd_barrier(); }
589-
590-
/// Generic work-group split barrier
591-
inline ESIMD_NODEBUG void esimd_sbarrier(EsimdSbarrierType flag) {
592-
__esimd_sbarrier(flag);
593-
}
594-
586+
/// Bits used to form the bitmask that controls the behavior of esimd_fence
587+
/// Bit 0: the “commit enable” bit. If set, the fence is guaranteed
588+
/// to be globally observable
589+
/// Bit 1: flush instruction cache if set.
590+
/// Bit 2: flush sampler cache if set
591+
/// Bit 3: flush constant cache if set
592+
/// Bit 4: flush read-write cache if set
593+
/// Bit 5: 0 means the fence is applied to global memory
594+
/// 1 means the fence applies to shared local memory only
595+
/// Bit 6: flush L1 read-only data cache if set
596+
/// Bit 7: indicates this is a scheduling barrier
597+
/// but will not generate an actual fence instruction
595598
enum EsimdFenceMask {
596599
ESIMD_GLOBAL_COHERENT_FENCE = 0x1,
597600
ESIMD_L3_FLUSH_INSTRUCTIONS = 0x2,
@@ -604,11 +607,30 @@ enum EsimdFenceMask {
604607
};
605608

606609
/// esimd_fence sets the memory read/write order.
610+
/// \tparam cntl is the bitmask composed from enum EsimdFenceMask
607611
/// \ingroup sycl_esimd
608612
ESIMD_INLINE ESIMD_NODEBUG void esimd_fence(uint8_t cntl) {
609613
__esimd_slm_fence(cntl);
610614
}
611615

616+
/// Generic work-group barrier.
617+
/// Performs barrier synchronization for all threads within the same thread
618+
/// group. The barrier instruction causes the executing thread to wait until
619+
/// all threads in the same thread group have executed the barrier instruction.
620+
/// Memory ordering is also guaranteed by this instruction.
621+
/// The behavior is undefined if this instruction is executed in divergent
622+
/// control flow.
623+
/// \ingroup sycl_esimd
624+
inline ESIMD_NODEBUG void esimd_barrier() {
625+
__esimd_slm_fence(ESIMD_GLOBAL_COHERENT_FENCE | ESIMD_LOCAL_BARRIER);
626+
__esimd_barrier();
627+
}
628+
629+
/// Generic work-group split barrier
630+
inline ESIMD_NODEBUG void esimd_sbarrier(EsimdSbarrierType flag) {
631+
__esimd_sbarrier(flag);
632+
}
633+
612634
/// @defgroup sycl_esimd_slm SLM functions
613635
/// \ingroup sycl_esimd
614636
/// @{

0 commit comments

Comments
 (0)