Korneliusz
MModular
•Created by Korneliusz on 1/21/2025 in #questions
Compilation with constant lookup table
I'm so dumb, yeah I actually wrote that as a tuple above and still didn't think about that 😅
I'll try, thank you
18 replies
MModular
•Created by Korneliusz on 1/21/2025 in #questions
Compilation with constant lookup table
@Darkmatter I was trying to implement this as you said but I came across the fact that along with the big lookuo table I was also generating one smaller lookup and one medium lookup. Logic for that is bound together and I cannot split the generation into three constructors, because generating one optimizes generating another, let's the algorithm pack it better and all of this comes from random numbers, I need to be sure thag same random numbers were used for certain positions in the lookups, so that makes it totally impossible to split the logic to three cobstructors. That
things.
How can I define constructor that would initialize three aliases at once?
I would like to have something like:
Alias LOOKUP_1, LOOKUP_2, LOOKUP_3 = init_lookups()
fn init_lookups(out lookup1: Type, out lookup2: Type, out lookup3: Type) :
...
But this probably won't be that easy, is it even possible?
18 replies
MModular
•Created by Korneliusz on 1/21/2025 in #questions
Compilation with constant lookup table
I'll think about that for another more dynamic table that I will need for this project. But for now that's valid info, thanks. When I confirm that it works for me I will mark this as resolved or write message here if it doesn't work
18 replies
MModular
•Created by Korneliusz on 1/21/2025 in #questions
Compilation with constant lookup table
There is unsafe_get for InlineArray
18 replies
MModular
•Created by Korneliusz on 1/21/2025 in #questions
Compilation with constant lookup table
Do I understand correctly that for each element it makes allocation for whole array? It means 104960 times 0.8MB?
If this is correct then it shouldn't work like that 😅
18 replies
MModular
•Created by Korneliusz on 1/21/2025 in #questions
Compilation with constant lookup table
That is very interesting. You're awesome 🔥@Darkmatter , thanks.
I can re-derive values.
I'm still not sure why it took that much RAM tho. It would need to copy the array at least 2750 times to utilise that much RAM. I'll check using the constructor with re-derived values will fix this.
So is there anything with faster access by index than InlineArray for my case? I don't really need in bound checks or any safety as I'm 100% sure that getters will not go out of bounds. I only care about speed.
18 replies
MModular
•Created by Korneliusz on 1/21/2025 in #questions
Compilation with constant lookup table
Sorry, what is "variadic ctor"?
I have all values and I can hardcode them, coming from Rust, this is quite strange that I need to do this in a function.
How to make constructor with out parameter for an alias? Or what do you mean? I'm not that advanced yet I guess
18 replies
MModular
•Created by yaKir on 1/16/2025 in #questions
How to start move my project to mojo?
Mojo can use any Python libraries, so I would split your project into modules as Python libraries, then see what modules take most execution time and re-write them in mojo. You can basically use any language for that but with Mojo you will be able to use any libraries that your project modules already use, so that won't be painful, syntax is also quite similar
6 replies
MModular
•Created by Korneliusz on 1/15/2025 in #questions
Using BMI (pext_u64 and pdep_u64) in Mojo
It works, nice, for anyone having same question, here's example:
from sys import llvm_intrinsic
def main():
alias intrin: StringLiteral = "llvm.x86.bmi.pext.64"
var x = llvm_intrinsicintrin, UInt64, UInt64(12309))
print(x) # 22
7 replies
MModular
•Created by Korneliusz on 1/15/2025 in #questions
Using BMI (pext_u64 and pdep_u64) in Mojo
I didn't see this page, thanks
7 replies
MModular
•Created by Korneliusz on 1/15/2025 in #questions
Using BMI (pext_u64 and pdep_u64) in Mojo
Yes, that's exactly what I need
7 replies