Skip to content

Commit 9eff454

Browse files
jsantillan2017igcbot
authored andcommitted
Refactor and update typed atomic implementation
Convert raw send to typed atomic visa instruction uniform implementation for certain ops for typed atomics
1 parent cc91c3e commit 9eff454

File tree

5 files changed

+271
-109
lines changed

5 files changed

+271
-109
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,74 @@ namespace IGC
561561
}
562562
}
563563

564+
void CEncoder::TypedAtomic(
565+
AtomicOp atomic_op,
566+
CVariable* dst,
567+
const ResourceDescriptor& resource,
568+
CVariable* pU,
569+
CVariable* pV,
570+
CVariable* pR,
571+
CVariable* src0,
572+
CVariable* src1,
573+
CVariable* lod,
574+
bool is16Bit)
575+
{
576+
VISAAtomicOps subOp = convertAtomicOpEnumToVisa(atomic_op);
577+
VISA_PredOpnd* pred = GetFlagOperand(m_encoderState.m_flag);
578+
VISA_EMask_Ctrl emask = ConvertMaskToVisaType(m_encoderState.m_mask, m_encoderState.m_noMask);
579+
VISA_Exec_Size executionSize = visaExecSize(m_encoderState.m_simdSize);
580+
581+
VISA_StateOpndHandle* pSurfStateOpndHandle = GetVISASurfaceOpnd(resource);
582+
583+
if (pU && pU->GetType() != ISA_TYPE_UD)
584+
pU = m_program->BitCast(pU, ISA_TYPE_UD);
585+
if (pV && pV->GetType() != ISA_TYPE_UD)
586+
pV = m_program->BitCast(pV, ISA_TYPE_UD);
587+
if (pR && pR->GetType() != ISA_TYPE_UD)
588+
pR = m_program->BitCast(pR, ISA_TYPE_UD);
589+
590+
VISA_RawOpnd* pUOpnd = GetRawSource(pU);
591+
VISA_RawOpnd* pVOpnd = GetRawSource(pV);
592+
VISA_RawOpnd* pROpnd = GetRawSource(pR);
593+
594+
VISA_Type type = ISA_TYPE_UD;
595+
if (atomic_op == EATOMIC_IMAX || atomic_op == EATOMIC_IMIN)
596+
type = ISA_TYPE_D;
597+
598+
if (dst && dst->GetType() != type)
599+
dst = m_program->BitCast(dst, type);
600+
if (src0 && src0->GetType() != type)
601+
src0 = m_program->BitCast(src0, type);
602+
if (src1 && src1->GetType() != type)
603+
src1 = m_program->BitCast(src1, type);
604+
605+
VISA_RawOpnd* pDst = GetRawDestination(dst);
606+
VISA_RawOpnd* pSrc0 = GetRawSource(src0);
607+
VISA_RawOpnd* pSrc1 = GetRawSource(src1);
608+
609+
// See DwordAtomicRaw for explanation why we need this
610+
if (atomic_op == EATOMIC_CMPXCHG) {
611+
std::swap(pSrc0, pSrc1);
612+
}
613+
614+
VISA_RawOpnd* pLOD = GetRawSource(lod);
615+
616+
V(vKernel->AppendVISA3dTypedAtomic(
617+
subOp,
618+
is16Bit,
619+
pred,
620+
emask,
621+
executionSize,
622+
pSurfStateOpndHandle,
623+
pUOpnd,
624+
pVOpnd,
625+
pROpnd,
626+
pLOD,
627+
pSrc0,
628+
pSrc1,
629+
pDst));
630+
}
631+
564632
void CEncoder::Cmp(e_predicate p, CVariable* dst, CVariable* src0, CVariable* src1)
565633
{
566634
VISA_Cond_Mod subOp = ConvertCondModToVisaType(p);

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ namespace IGC
150150
void AtomicRawA64(AtomicOp atomic_op, const ResourceDescriptor& resource, CVariable* dst,
151151
CVariable* elem_offset, CVariable* src0, CVariable* src1,
152152
unsigned short bitwidth);
153+
void TypedAtomic(
154+
AtomicOp atomic_op,
155+
CVariable* dst,
156+
const ResourceDescriptor& resource,
157+
CVariable* pU,
158+
CVariable* pV,
159+
CVariable* pR,
160+
CVariable* src0,
161+
CVariable* src1,
162+
CVariable* lod,
163+
bool is16Bit = false);
153164
void Cmp(e_predicate p, CVariable* dst, CVariable* src0, CVariable* src1);
154165
void Select(CVariable* flag, CVariable* dst, CVariable* src0, CVariable* src1);
155166
void GenericAlu(e_opcode opcode, CVariable* dst, CVariable* src0, CVariable* src1, CVariable* src2 = nullptr);

0 commit comments

Comments
 (0)