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

feature switch for thread_local variables and multi-threading #159

Merged
merged 2 commits into from
Apr 28, 2024

Conversation

CrustyAuklet
Copy link
Member

thread local variables will trigger a memory allocation on a bare metal system. When running tests on a single thread, or a system without threads, there is no benefit to using a thread_local variable. As discussed in #158.

This change creates a feature flag to control if snitch should be compiled with support for threading. A macro SNITCH_THREAD_LOCAL is defined in the config header that resolves to nothing when the feature flag is disabled, or thread_local when it is enabled. The feature flag is enabled by default to preserve existing behavior.

I names the feature flag SNITCH_WITH_MULTITHREADING to let it be used for any future threading features as well. If you want a more granular option that is an easy change.

I updated the CMake project file, and the meson options. I don't use meson so someone double checking my work there would be great. The change seems simple enough though 😄

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.87%. Comparing base (fb1f8dd) to head (73f4935).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #159   +/-   ##
=======================================
  Coverage   93.87%   93.87%           
=======================================
  Files          27       27           
  Lines        1664     1664           
=======================================
  Hits         1562     1562           
  Misses        102      102           
Files Coverage Δ
src/snitch_test_data.cpp 95.45% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb1f8dd...73f4935. Read the comment docs.

meson_options.txt Outdated Show resolved Hide resolved
@snitch-org snitch-org deleted a comment from cschreib-ibex Apr 27, 2024
CMakeLists.txt Outdated Show resolved Hide resolved
@cschreib
Copy link
Member

The CI failures weren't related to this PR and have been fixed in main. Once you have addressed the review comments above; please rebase onto the latest main, or merge main. This should make the build go green.

thread local variables will trigger a memory allocation on a bare metal system.
use a macro to define the variable as thread local. Bare metal by definition has no
threads and so needs no qualifier.
Cleanup of option documentation, usage, and meson configuration. Based
on code review in merge request from cschreib.
@CrustyAuklet CrustyAuklet force-pushed the build-option-threading branch from af299a1 to 73f4935 Compare April 27, 2024 19:58
Copy link
Member

@cschreib cschreib 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! Thank you for your contribution.

@cschreib cschreib merged commit ccd3afa into snitch-org:main Apr 28, 2024
45 checks passed
@CrustyAuklet CrustyAuklet deleted the build-option-threading branch April 28, 2024 17:58
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