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

feat[cartesian]: Specify compiler optimization level and flags via env variables #1491

Merged
merged 10 commits into from
Jun 25, 2024

Conversation

stubbiali
Copy link
Contributor

Description

This PR allows downstream applications to specify compiler optimization level and flags on a stencil basis.

Requirements

  • All fixes and/or new features come with corresponding tests.
  • Important design decisions have been documented in the approriate ADR inside the docs/development/ADRs/ folder.

If this PR contains code authored by new contributors please make sure:

  • All the authors are covered by a valid contributor assignment agreement provided to ETH Zurich and signed by the employer if needed.
  • The PR contains an updated version of the AUTHORS.md file adding the names of all the new contributors.

Copy link
Contributor

@havogt havogt left a comment

Choose a reason for hiding this comment

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

Please add a test that illustrates using the feature. Not sure if removing debug_mode is a good idea.

@havogt
Copy link
Contributor

havogt commented Mar 19, 2024

Adding @egparedes and @FlorianDeconinck for more opinions.

Copy link
Contributor

@FlorianDeconinck FlorianDeconinck left a comment

Choose a reason for hiding this comment

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

LGTM


mode_flags = ["-O0", "-ggdb"] if debug_mode else ["-O3", "-DNDEBUG"]
mode_flags = [f"-O{opt_level}", "-DNDEBUG", *extra_opt_flags.split()]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@havogt On (my) mac, the flag -DNDEBUG is required to make compilation works with any optimization level, so I hardcoded it into mode_flags for the sake of convenience. If you prefer, we could be more flexible:

Suggested change
mode_flags = [f"-O{opt_level}", "-DNDEBUG", *extra_opt_flags.split()]
mode_flags = [f"-O{opt_level}"]
if extra_opt_flags != "":
mode_flags += [*extra_opt_flags.split()]
elif opt_level == "0":
mode_flags.append("-ggdb")
else:
mode_flags.append("-DNDEBUG")

@havogt havogt removed the request for review from egparedes March 20, 2024 16:53
@havogt
Copy link
Contributor

havogt commented Jun 25, 2024

cscs-ci run

@havogt havogt merged commit 198c0ae into GridTools:main Jun 25, 2024
39 checks passed
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