Skip to content

Commit

Permalink
xe: gemm: skip locking flag register on no-load blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Simonsays095 authored and karturov committed Nov 18, 2024
1 parent 3dd4f43 commit 4c8fb2c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/gpu/intel/jit/gemm/generator/pieces/allocators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ FlagRegister VirtualFlagAllocator::assignPhysical(VirtualFlag vflag)
return pflag.toPhysical();
}

bool VirtualFlagAllocator::lock(VirtualFlag vflag, bool allowAlreadyLocked) {
bool wasLocked = isLocked(vflag);
if (wasLocked && !allowAlreadyLocked) stub("Illegally locking an already-locked flag register");
locked |= mask(vflag);
return wasLocked;
}

bool VirtualFlagAllocator::canLock(int n) const
{
uint8_t unlocked = ~locked & ((1 << nflag) - 1);
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/intel/jit/gemm/generator/pieces/allocators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class VirtualFlagAllocator {

bool isVirtual(VirtualFlag vflag) { return (vflag.idx >= nflag); }

bool lock(VirtualFlag vflag) { bool wasLocked = isLocked(vflag); locked |= mask(vflag); return wasLocked; }
bool lock(VirtualFlag vflag, bool allowAlreadyLocked = false);
void unlock(VirtualFlag vflag) { locked &= ~mask(vflag); }
bool isLocked(VirtualFlag vflag) const { return !(~locked & mask(vflag)); }
bool canLock(int n = 1) const;
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/intel/jit/gemm/generator/pieces/copy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void BLASKernelGenerator<hw>::copyExecute(CopyPlan &&plan, CommonState &state)
if (!state.vflagsEnabled())
for (int i = 0; i < nflag; i++)
if (!raVFlag0.isFree(VirtualFlag{i}))
raVFlag0.lock(VirtualFlag{i});
raVFlag0.lock(VirtualFlag{i}, true);
auto raVFlag = raVFlag0;

// If we have enough free flags, use those.
Expand Down
4 changes: 3 additions & 1 deletion src/gpu/intel/jit/gemm/generator/pieces/matrix_access.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ void BLASKernelGenerator<hw>::prepareSeriesRegisterBlockMasking(const vector<Reg
for (int startPreload = start; startPreload < nblocks; startPreload++) {
auto &block = layout[startPreload];

if (!block.isLoadBlock()) continue;

bool plFlag[2];
for (int i = 0; i <= 1; i++)
plFlag[i] = block.flag[i] && (block.flag[i] != state.blockEMask);
Expand All @@ -630,7 +632,7 @@ void BLASKernelGenerator<hw>::prepareSeriesRegisterBlockMasking(const vector<Reg

auto &flag = block.flag[plFlag[0] ? 0 : 1];
if (!state.raVFlag.canLock(flag.n)) break;
state.raVFlag.lock(getPhysicalFlag(flag, state));
state.raVFlag.lock(getPhysicalFlag(flag, state), true);
}
}
}
Expand Down

0 comments on commit 4c8fb2c

Please sign in to comment.