Skip to content

Commit af6195d

Browse files
smilczekigcbot
authored andcommitted
Remove global fences for integrated graphics.
Global fences are not needed for integra. Runtime already disabled support for global fence allocation for integra. This commit implements the change compiler side.
1 parent e4183e0 commit af6195d

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed

IGC/Compiler/CISACodeGen/Platform.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,22 @@ bool supportsZEBin() const
774774
}
775775
}
776776

777+
778+
bool isIntegratedGraphics() const
779+
{
780+
switch (m_platformInfo.eProductFamily)
781+
{
782+
case IGFX_DG1:
783+
case IGFX_XE_HP_SDV:
784+
case IGFX_DG2:
785+
case IGFX_PVC:
786+
case IGFX_BMG:
787+
return false;
788+
default:
789+
return true;
790+
}
791+
}
792+
777793
bool loosenSimd32occu() const
778794
{
779795
if (IGC_GET_FLAG_VALUE(ForceLoosenSimd32Occu) == 2)

IGC/Compiler/Optimizer/OpenCLPasses/LSCFuncs/LSCFuncsResolution.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace {
8787
Instruction* CreateSubGroup2DBlockOperation(llvm::CallInst& CI, llvm::StringRef funcName, bool isRead);
8888

8989
/// LSC Fence intrinsics call method
90-
Instruction* CreateLSCFenceIntrinsicCallInst();
90+
Instruction* CreateLSCFenceIntrinsicCallInst(CallInst& CI);
9191

9292
Instruction* CreateLSCFenceEvictToMemory();
9393

@@ -176,6 +176,7 @@ namespace {
176176
CodeGenContext* m_pCtx = nullptr;
177177
CallInst* m_pCurrInst = nullptr;
178178
Function* m_pCurrInstFunc = nullptr;
179+
std::set<Instruction*> m_instsToErase{};
179180

180181
// For verifying address payload for block 2d read/write.
181182
llvm::SmallVector<Instruction *, 32> m_lsc2dblock_readwrite;
@@ -278,6 +279,11 @@ bool LSCFuncsResolution::runOnFunction(Function &F)
278279

279280
visit(F);
280281

282+
for (auto* inst : m_instsToErase) {
283+
inst->eraseFromParent();
284+
}
285+
m_instsToErase.clear();
286+
281287
verifyBlock2DAddressPayload();
282288

283289
if (hasError()) {
@@ -388,7 +394,7 @@ void LSCFuncsResolution::visitCallInst(CallInst &CI)
388394
}
389395
else if (FN.startswith(LSCFuncsResolution::PREFIX_LSC_FENCE)) {
390396
// LSC fence
391-
lscCall = CreateLSCFenceIntrinsicCallInst();
397+
lscCall = CreateLSCFenceIntrinsicCallInst(CI);
392398
} else {
393399
// not an LSC message, bail silently
394400
return;
@@ -404,7 +410,7 @@ void LSCFuncsResolution::visitCallInst(CallInst &CI)
404410
if (lscCall != nullptr) {
405411
lscCall->setDebugLoc(CI.getDebugLoc());
406412
CI.replaceAllUsesWith(lscCall);
407-
CI.eraseFromParent();
413+
m_instsToErase.insert(&CI);
408414

409415
m_changed = true;
410416
}
@@ -1454,7 +1460,7 @@ Instruction* LSCFuncsResolution::CreateLSCStoreCmaskIntrinsicCallInst(
14541460
return lscCall;
14551461
}
14561462

1457-
Instruction* LSCFuncsResolution::CreateLSCFenceIntrinsicCallInst() {
1463+
Instruction* LSCFuncsResolution::CreateLSCFenceIntrinsicCallInst(CallInst& CI) {
14581464
LSC_SFID memPort = decodeSfidFromName();
14591465

14601466
auto context = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
@@ -1479,6 +1485,12 @@ Instruction* LSCFuncsResolution::CreateLSCFenceIntrinsicCallInst() {
14791485

14801486
if (scope && (scope->getZExtValue() == LSC_SCOPE_SYSACQ || scope->getZExtValue() == LSC_SCOPE_SYSREL))
14811487
{
1488+
if (context->platform.isIntegratedGraphics() || context->platform.isCoreXE2())
1489+
{
1490+
// Global memory fences are not needed on integrated devices or on Xe2 platforms.
1491+
m_instsToErase.insert(&CI);
1492+
return nullptr;
1493+
}
14821494
if (!context->platform.supportSystemFence())
14831495
{
14841496
reportError("platform does not support system fence");
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2025 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
;
9+
; REQUIRES: llvm-14-plus
10+
; RUN: igc_opt --opaque-pointers --igc-lsc-funcs-translation -platformmtl -S < %s 2>&1 | FileCheck %s
11+
; ------------------------------------------------
12+
; LSCFuncsResolution
13+
; ------------------------------------------------
14+
15+
; Test checks lsc global fences are removed for integra and XE2 platforms.
16+
17+
define spir_kernel void @test_lsc(ptr %base) {
18+
; CHECK-NOT: call void @llvm.genx.GenISA.LSCFence
19+
; CHECK-NOT: call spir_func void @__builtin_IB_lsc_fence_global
20+
;
21+
call spir_func void @__builtin_IB_lsc_fence_global_untyped(i32 6, i32 1)
22+
ret void
23+
}
24+
25+
declare void @__builtin_IB_lsc_fence_global_untyped(i32, i32)
26+
27+
!igc.functions = !{!0}
28+
29+
!0 = !{ptr @test_lsc, !1}
30+
!1 = !{!2, !3}
31+
!2 = !{!"function_type", i32 0}
32+
!3 = !{!"sub_group_size", i32 16}

0 commit comments

Comments
 (0)