Skip to content

Commit 8c74233

Browse files
weiyu-chenZuul
authored andcommitted
Refactor fence before EOT and handle function calls.
Change-Id: I36abb94de10927a88486ee4e0fb319612c17a2cf
1 parent c121c15 commit 8c74233

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

visa/Optimizer.cpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8060,11 +8060,30 @@ void genBucket(G4_INST *send, Bucket *bucket, RW rwType) {
80608060
return;
80618061
}
80628062

8063+
if (!kernel.fg.builder->getIsKernel())
8064+
{
8065+
// we dont allow a function to exit
8066+
return;
8067+
}
8068+
80638069
bool hasUAVWrites = false;
80648070
bool hasSLMWrites = false;
8065-
std::list<SFID> funcIDs;
8071+
bool hasTypedWrites = false;
8072+
8073+
80668074
for (auto bb : kernel.fg)
80678075
{
8076+
if (bb->isEndWithFCall())
8077+
{
8078+
// conservatively assume we need a fence
8079+
// ToDo: we don't need a SLM fence if kernel doesnt use SLM, since function can't allocate SLM on its own
8080+
// We can move this W/A to IGC for more precise analysis
8081+
hasUAVWrites = true;
8082+
hasSLMWrites = true;
8083+
hasTypedWrites = true;
8084+
break;
8085+
}
8086+
80688087
for (auto inst : *bb)
80698088
{
80708089
if (inst->isSend())
@@ -8078,6 +8097,10 @@ void genBucket(G4_INST *send, Bucket *bucket, RW rwType) {
80788097
{
80798098
hasSLMWrites = true;
80808099
}
8100+
else if (msgDesc->isHdcTypedSurfaceWrite())
8101+
{
8102+
hasTypedWrites = true;
8103+
}
80818104
else
80828105
{
80838106
hasUAVWrites = true;
@@ -8086,23 +8109,14 @@ void genBucket(G4_INST *send, Bucket *bucket, RW rwType) {
80868109

80878110
}
80888111
}
8089-
if (hasUAVWrites && hasSLMWrites)
8090-
{
8091-
break;
8092-
}
8093-
}
8094-
if (hasUAVWrites && hasSLMWrites)
8095-
{
8096-
break;
80978112
}
80988113
}
80998114

8100-
if ((!hasUAVWrites) && (!hasSLMWrites) && funcIDs.empty())
8115+
if (!hasUAVWrites && !hasSLMWrites && !hasTypedWrites)
81018116
{
81028117
return;
81038118
}
81048119

8105-
funcIDs.unique();
81068120
for (auto bb : kernel.fg)
81078121
{
81088122
if (bb->isLastInstEOT())

0 commit comments

Comments
 (0)