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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

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
extra_link_args = copy.deepcopy(gt_config.build_settings["extra_link_args"])

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

Choose a reason for hiding this comment

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

this fixes my comment above

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.

None yet

3 participants