Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion hit while compiling kernels from Darktable #1083

Closed
kpet opened this issue Apr 19, 2023 · 1 comment · Fixed by #1084
Closed

Assertion hit while compiling kernels from Darktable #1083

kpet opened this issue Apr 19, 2023 · 1 comment · Fixed by #1084
Assignees

Comments

@kpet
Copy link
Contributor

kpet commented Apr 19, 2023

Compiling the attached source with the following options

clspv source.cl  -w -cl-fast-relaxed-math  -DNVIDIA=1 -I"/usr/share/darktable/kernels" -cl-single-precision-constant  -cl-kernel-arg-info   -fp16=0  -rewrite-packed-structs  -std430-ubo-layout  -decorate-nonuniform    -arch=spir  --use-native-builtins=acos,acosh,acospi,asin,asinh,asinpi,atan,atan2,atan2pi,atanh,atanpi,ceil,copysign,fabs,fdim,floor,fma,fmax,fmin,frexp,half_rsqrt,half_sqrt,isequal,isfinite,isgreater,isgreaterequal,isinf,isless,islessequal,islessgreater,isnan,isnormal,isnotequal,isordered,isunordered,ldexp,mad,rint,round,rsqrt,signbit,sqrt,tanh,trunc,  -spv-version=1.6  -max-pushconstant-size=256  -max-ubo-size=65536  -global-offset  -long-vector  -module-constants-in-storage-buffer  -cl-arm-non-uniform-work-group-size     -o compiled.spv

results in the following assertion being hit:

clspv: /mnt/work/repos/clvk/external/clspv/third_party/llvm/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = SelectInst; From = Value]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

Darktable used to run on top of clvk (not sure it was the exact same version) so this may be a regression.

source.txt

@rjodinchr rjodinchr self-assigned this Apr 19, 2023
@rjodinchr
Copy link
Collaborator

This is coming from FixupBuiltinsPass::fixupSqrt where the builder optimize CreateSelect because the condition is constant, thus ending up with a nullptr being cast to SelectInst asserting.
I'll push a fix for it tomorrow.

rjodinchr added a commit to rjodinchr/clspv that referenced this issue Apr 20, 2023
when sqrt/rsqrt input is a constant the IRBuilder optimize the select
to directly get the right node. This lead to an assertion trying to
cast select into an SelectInst.
Instead, just manage constant values staticaly

Fix google#1083
alan-baker pushed a commit that referenced this issue Apr 20, 2023
when sqrt/rsqrt input is a constant the IRBuilder optimize the select
to directly get the right node. This lead to an assertion trying to
cast select into an SelectInst.
Instead, just manage constant values staticaly

Fix #1083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants