Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use optimisation flags for C compiler in lpython decorator #2201

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

Merged
merged 6 commits into from
Jul 22, 2023

Conversation

czgdp1807
Copy link
Collaborator

I think we should use all the optimisations flags by default in lpython decorator and generate as fast code as possible. It produces a significant difference when comparing with other JIT compilers.

@@ -687,9 +687,9 @@ def get_rtlib_dir():

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the --fast` option works in the C backend. If it does, then we can use it in line 684?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't I think.

@czgdp1807 czgdp1807 force-pushed the gcc_opt branch 2 times, most recently from dbcc4d9 to 689a76d Compare July 22, 2023 11:59
@czgdp1807
Copy link
Collaborator Author

-funroll-loops and -ffast-math are useful optimisations because most of the computations which lpython intends to handle involve loops and math, so enabling both of these will speed up the code. In fact, enabling -O1, -O2 and -O3 speeds up the code significantly when the lpython decorated function doesn’t return arrays. As a user I would like to pass these flags via lpython decorator but since its a class based decorator , its not so easy to pass these flags.

@czgdp1807 czgdp1807 marked this pull request as ready for review July 22, 2023 12:26
The decorator should be used from CPython mode, i.e., when the module is
being run using CPython. When possible, it is recommended to use LPython
for the main program, and use the @cpython decorator from the LPython mode
to access CPython features that are not supported by LPython.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation should be somewhere.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this looks great! I left a comment.

@czgdp1807 czgdp1807 enabled auto-merge (squash) July 22, 2023 18:19
Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@czgdp1807 czgdp1807 merged commit 31a6be1 into lcompilers:main Jul 22, 2023
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