Skip to content
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

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

Clonkk
Copy link
Member

@Clonkk Clonkk commented Jun 12, 2024

No description provided.

@Clonkk
Copy link
Member Author

Clonkk commented Jun 12, 2024

@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 ? )

Comment on lines 1 to 5
--b:cpp
--outdir:bin
--out:examply.so
--cc:gcc
--mm:arc
Copy link
Member

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)?

Copy link
Member Author

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).

@Vindaar
Copy link
Member

Vindaar commented Jun 13, 2024

Looks good to me aside from my two minor comments!

@HugoGranstrom
Copy link
Member

Looks good to me 😄 Crazy that Nim is sooo much faster 🤯

@Clonkk
Copy link
Member Author

Clonkk commented Jun 14, 2024

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.

Comment on lines 38 to 40
for i in 0||(x.shape[0]-1):
for j in 0||(x.shape[1]-1):
result[i, j] = doStuff x[i, j]
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants