Darkmatter
Darkmatter
MModular
Created by rd4com on 10/18/2024 in #community-showcase
:hatching_chick: mojo-new-web-framework
ML apps probably want to call out to WebGPU.
8 replies
MModular
Created by JanEric1 on 11/10/2024 in #questions
Compile time facilities
You're rapidly approaching the point where knowing the exact CPU you execute on will be more useful than more things at compile time.
10 replies
MModular
Created by JanEric1 on 11/10/2024 in #questions
Compile time facilities
You could potentially do a bit better, but the compiler seems to mostly be figuring it out.
10 replies
MModular
Created by JanEric1 on 11/10/2024 in #questions
Compile time facilities
As far as I can tell what you have now works reasonably well due to constant folding references.
10 replies
MModular
Created by JanEric1 on 11/10/2024 in #questions
Compile time facilities
Now, if you had intended to compare each row, it would be like this:
fn _is_winner[size: Int, //, player: UInt8](board: SIMD[DType.uint8, size*size]) -> Bool:
# compile-time splat
alias reference = SIMD[DType.uint8, size](player)
@parameter
for row in range(size):
var row_vector = board.slice[size, offset=size*row]()
if (row_vector & reference).reduce_bit_count() == size:
return True

...
fn _is_winner[size: Int, //, player: UInt8](board: SIMD[DType.uint8, size*size]) -> Bool:
# compile-time splat
alias reference = SIMD[DType.uint8, size](player)
@parameter
for row in range(size):
var row_vector = board.slice[size, offset=size*row]()
if (row_vector & reference).reduce_bit_count() == size:
return True

...
10 replies
MModular
Created by JanEric1 on 11/10/2024 in #questions
Compile time facilities
@parameter does loop unrolling, so you've accidently made this function very expensive, and then Mojo is saving you from yourself. This is what you actually want:
fn _is_winner[size: Int, //, player: UInt8](board: SIMD[DType.uint8, size*size]) -> Bool:
# compile-time splat
alias reference = SIMD[DType.uint8, size*size](player)
if (board & reference).reduce_bit_count() == size:
return True

...
fn _is_winner[size: Int, //, player: UInt8](board: SIMD[DType.uint8, size*size]) -> Bool:
# compile-time splat
alias reference = SIMD[DType.uint8, size*size](player)
if (board & reference).reduce_bit_count() == size:
return True

...
10 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
numpy vs mojo is going to be a few bytes.
28 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
It has a vtable too!
28 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
28 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
🙂
28 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
Including lists.
28 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
So anything with an int is variable sized.
28 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
int takes a variable amount of memory.
28 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
In python, "element size" is a very interesting question to ask.
28 replies
MModular
Created by Teszaract on 11/3/2024 in #questions
Posix compliant Mojo Shell?
Most shells spend upwards of 90% of their time inside of kernel code unless they have built in facilities for doing number crunching. I think you’re describing the python REPL, and Mojo has a similar REPL. REPLs are not POSIX compliant because there isn’t a good way to make it so that you can evaluate Mojo code and be posix compliant, and the goal of a REPL is to do quick evaluation of Mojo code to do a quick calculation or play with a concept.
2 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
First, can you set a server nickname? I didn’t look at your name last time and we don’t allow profanity in usernames. As for what I recommend, top might be good enough if you can make the process hand around for a while. Ideally you’d way to use a proper profiler but I have no idea what that is on MacOS, I’m only familiar with Linux and windows dev tooling.
28 replies
MModular
Created by Ryan on 11/1/2024 in #questions
How Unsafe/Safe is this code?
I'm pretty sure this breaks the pointer provenance rules, so this is probably a lot of UB.
5 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
Scalene won’t work properly with Mojo if you’re on Linux due to some of the transparent hugepage and virtual memory shenanigans that tcmalloc does there.
28 replies
MModular
Created by fuckAllTechCompanies on 10/30/2024 in #questions
How can I see the peak memory usage of a datastructure like alist in mojo?
The other option is to allocate a very big list and check the process memory usage.
28 replies