-
Notifications
You must be signed in to change notification settings - Fork 3
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
add more examples + add calling nim from python #15
base: main
Are you sure you want to change the base?
Conversation
@Vindaar @HugoGranstrom Some improvement over speeding Python with Nim :) LMK what you think and how we can build better example (like maybe some non-dummy examples on random data ? ) |
… & fastest loop. Perf goes from 90 seconds to 500/600 ms
…cinim into clonk/improve-npy-array-interop
examples/numpyarrays/examply.nims
Outdated
--b:cpp | ||
--outdir:bin | ||
--out:examply.so | ||
--cc:gcc | ||
--mm:arc |
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.
Why C++ and ARC (and not ORC)?
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.
arc is equivalent to orc without cyclic type but both should work.
c++ because I tested calling some openmp loop from python and had some issue with it using C backend and gcc-14. g++ seemed to work fine so I just rolled with it.
Also found out clang and openmp do not like each other (on OSX at least).
Looks good to me aside from my two minor comments! |
Looks good to me 😄 Crazy that Nim is sooo much faster 🤯 |
I updated the perf, with better python perf as well. I added strides to get indexing syntax but this makes iterating over 1D a little bit slower than with rax buffer access. |
examples/numpyarrays/examply.nim
Outdated
for i in 0||(x.shape[0]-1): | ||
for j in 0||(x.shape[1]-1): | ||
result[i, j] = doStuff x[i, j] |
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.
I don't think this compiles correctly, or does it? Last time I tried that, I ended up writing my own loop fusion macro https://github.com/Vindaar/llm.nim/blob/master/fuse_loops.nim.
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.
Just remembered that this was of course in the context of using an OpenMP collapse
statement as well.
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.
And on the C backend in general ||
does not seem to compile at the moment due to goto
statements. Only compiling with --exceptions:quirky
makes it work. Maybe there's a different exception approach that also compiles, but well.
No description provided.