SIMD or Int what should I use ?

A single integer value can be represented as both SIMD[Dtype, 1] or as Int. When should I use the first and when the former ?
4 Replies
Melody Daniel
Melody Daniel5mo ago
Int is already represented as SIMD of one element, use that
ModularBot
ModularBot5mo ago
Congrats @Melody Daniel, you just advanced to level 14!
Ehsan M. Kermani (Modular)
Please check out our recently explainer in X https://x.com/Modular/status/1776287802533245372 also note that Int (not Int*) is different and a special case. It's a numeric type in index MLIR dialect which can be implicitly converted back and forth to Int*, Scalar.
Modular (@Modular) on X
In this thread 🧵 we want to dive into SIMD: Mojo's 🔥 main runtime numeric type. SIMD stands for Single Instruction, Multiple Data. Using SIMD types allows a single operation to be applied to multiple data simultaneously 🚀 . Let's explore 👇
From An unknown user
Twitter
benny
benny5mo ago
Just to add a quick explination for anyone stumbling on this. Int8/16/32/64 along with all the other simple numeric types like Float32, Float64, UInt8, etc.. are simply Scalar[DType.int], which is equivilent to SIMD[DType.int, 1] (Where DType.int changes depending on the actual type. These are defined in the stdlib simply as alias Int32 = SIMD[DType.int32, 1]. That being said, as the above mentions, Int is a special case and provides additional methods, but also comes with potentially additional overhead. Depending on application, Int8/16/32/64 may be more efficient than Int
Want results from more Discord servers?
Add your server