Open Yihao-Shi opened 1 year ago
We welcome contribution for this feature. We are happy to offer help if anyone is interested. This PR which adds popcnt to Taichi may be helpful on how to add intrinsics to Taichi.
Hi! I'm willing to work on this issue.
Hi! I'm willing to work on this issue.
Thank you! Please let us know if you need any assistance.
Thanks! To be clear, I am writing a manual implementation for __clz()
with python, similar to the mentioned PR, eg..
for i in range(32):
if 2**i > n:
return 32 - i
, right?
Not exactly. We should add an intrinsic to the IR and use the built-in intrinsics in the LLVM and SPIRV based backends.
We can use llvm::Intrinsic::ctlz
in LLVM and use 32 - findMSB
in SPIRV backend.
noted, thanks!
In the process of building linear bvh in gpu, a good idea is that dividing the objectsd by the highest differing bit in their Morton codes, corresponds to classifying them on either side of an axis-aligned plane in 3D. Thus, cuda provides intrinsic function clz() to count the number of leading zero bits in a 32-bit integer. However, Taichi is not aviliable for this feature (but it is important in building linear bvh). I am calling for adding the features which is similar to clz().