-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Lang] [ir] [cuda] Add clz instruction #8276
Conversation
✅ Deploy Preview for docsite-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi! I have added the respective operators and tests into taichi, though I am not quite sure regarding whether the failed tests are a result of my addition of the clz operator (one of them seems to be a git cloning issue). Any help would be much appreciated! |
/rebase |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
31dec45
to
0378de1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks! Sorry for the late review. |
Issue: #8212
Brief Summary
🤖 Generated by Copilot at 5d312ab
This pull request implements a new
clz
function in Taichi, which counts the number of leading zeros for a 32-bit integer. The function is available as a Python function decorator, a unary operation in the Taichi expression system, and a backend-specific intrinsic in the code generation. The pull request modifies the relevant files in thepython
,taichi
, andcodegen
directories.Walkthrough
🤖 Generated by Copilot at 5d312ab
clz
to count the number of leading zeros for a 32-bit integer (link, link, link, link, link)clz
in theops
module inpython/taichi/lang/ops.py
using a unary operation wrapper (link)clz
in themathimpl
module inpython/taichi/math/mathimpl.py
to allow usingclz
as a Taichi function decorator (link)clz
unary operation intaichi/inc/unary_op.inc.h
andtaichi/ir/expression_ops.h
to expand to the corresponding enum value and expression class (link, link)clz
unary operation intaichi/python/export_lang.cpp
to bind the operation to the Python interface (link)clz
unary operation for different backends (link, link, link)clz
unary operation in the CUDA backend code generation intaichi/codegen/cuda/codegen_cuda.cpp
, which calls the CUDA intrinsic function__clz
and checks the input type (link)clz
unary operation in the LLVM backend code generation intaichi/codegen/llvm/codegen_llvm.cpp
, which calls the LLVM intrinsic functionctlz
and assigns the result to the statement value (link)clz
unary operation in the SPIRV backend code generation intaichi/codegen/spirv/spirv_codegen.cpp
, which calls the GLSL 450 extended instructionFindMSB
and subtracts the result from 32 (link)clz
unary operation in the IR builder class, which is a helper class for constructing IR statements (link, link)clz
unary operation method in the IR builder class header file intaichi/ir/ir_builder.h
(link)clz
unary operation method in the IR builder class source file intaichi/ir/ir_builder.cpp
, which creates and inserts a new unary operation statement with theclz
type and the input value (link)