Skip to content

Commit

Permalink
[SYCL] Don't assert for unsupported GRF sizes in CompileTimePropertie…
Browse files Browse the repository at this point in the history
…sPass (#12503)

It's already checked up-front at compile time in the SYCL headers. I can
provide more background for this change offline if required.

---------

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
  • Loading branch information
sarnex authored Jan 26, 2024
1 parent c1c9184 commit efcfa2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,10 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) {
// TODO: Remove SYCL_REGISTER_ALLOC_MODE_ATTR support in next ABI break.
uint32_t PropVal = getAttributeAsInteger<uint32_t>(Attr);
if (AttrKindStr == SYCL_GRF_SIZE_ATTR) {
assert((PropVal == 0 || PropVal == 128 || PropVal == 256) &&
"Unsupported GRF Size");
// The RegisterAllocMode metadata supports only 0, 128, and 256 for
// PropVal.
if (PropVal != 0 && PropVal != 128 && PropVal != 256)
return std::nullopt;
// Map sycl-grf-size values to RegisterAllocMode values used in SPIR-V.
static constexpr int SMALL_GRF_REGALLOCMODE_VAL = 1;
static constexpr int LARGE_GRF_REGALLOCMODE_VAL = 2;
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/SYCLLowerIR/CompileTimePropertiesPass/sycl-grf-mode.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; Check we don't assert for different GRF values and don't add the RegisterAllocMode metadata
; RUN: opt -passes=compile-time-properties %s -S | FileCheck %s --implicit-check-not=RegisterAllocMode

; CHECK: spir_kernel void @foo()
define weak_odr dso_local spir_kernel void @foo() #0 {
entry:
ret void
}

attributes #0 = { convergent mustprogress norecurse nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-grf-size"="16384" "sycl-module-id"="main.cpp" "sycl-optlevel"="2" "uniform-work-group-size"="true" }

0 comments on commit efcfa2b

Please sign in to comment.