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

-Wmaybe-uninitialized #428

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

-Wmaybe-uninitialized #428

wants to merge 4 commits into from

Conversation

dANW34V3R
Copy link
Contributor

Fixes #426

Comment on lines +788 to 805
const N* n;
if (isXtn2) {
d = sourceValues[0].getAsVector<D>();
n = sourceValues[1].getAsVector<N>();
} else {
d = {};
n = sourceValues[0].getAsVector<N>();
}

D out[16 / sizeof(D)] = {0};
int index = 0;

for (int i = 0; i < I; i++) {
if (isXtn2 & (i < (I / 2))) {
assert(isXtn2 && "isXtn2 is false so d is not initialised");
out[i] = d[i];
} else {
out[i] = static_cast<D>(n[index]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FinnWilkinson this is a temporary solution as I didn't want to fiddle too much with the for loop below. If you have a preferred solution then feel free to push a commit implementing that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this proposed solution is good.

From our offline discussion aboout line 801 on whether it should be isXtn2 & (i < (I / 2)) or isXtn2 && (i < (I / 2)), given both arguments are bools the functionality would be the same, but using && may be marginally clearer of this fact?

@@ -128,7 +128,7 @@ class RegisterValue {

/** The underlying local member value. Aligned to 8 bytes to prevent
* potential alignment issue when casting. */
alignas(8) char value[MAX_LOCAL_BYTES];
alignas(8) char localValue[MAX_LOCAL_BYTES] = {};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is slightly inefficient as it initialises localValue to all 0's for every instance which will be overwritten when constructing the instance. We should test if there is any visible performance degradation from this change. Maybe another one for Leo @ABenC377

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternative solution is to do something like

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
    foo(b);         /* no diagnostic for this one */
#pragma GCC diagnostic pop

Copy link
Contributor

Choose a reason for hiding this comment

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

Given we use Pool's for RegisterValues this may not cause a huge performance hit. Worth checking though

Copy link
Contributor

@FinnWilkinson FinnWilkinson left a comment

Choose a reason for hiding this comment

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

All looks fine to me. Will approve once the main performance comment has been resolved

@@ -128,7 +128,7 @@ class RegisterValue {

/** The underlying local member value. Aligned to 8 bytes to prevent
* potential alignment issue when casting. */
alignas(8) char value[MAX_LOCAL_BYTES];
alignas(8) char localValue[MAX_LOCAL_BYTES] = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Given we use Pool's for RegisterValues this may not cause a huge performance hit. Worth checking though

Comment on lines +788 to 805
const N* n;
if (isXtn2) {
d = sourceValues[0].getAsVector<D>();
n = sourceValues[1].getAsVector<N>();
} else {
d = {};
n = sourceValues[0].getAsVector<N>();
}

D out[16 / sizeof(D)] = {0};
int index = 0;

for (int i = 0; i < I; i++) {
if (isXtn2 & (i < (I / 2))) {
assert(isXtn2 && "isXtn2 is false so d is not initialised");
out[i] = d[i];
} else {
out[i] = static_cast<D>(n[index]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this proposed solution is good.

From our offline discussion aboout line 801 on whether it should be isXtn2 & (i < (I / 2)) or isXtn2 && (i < (I / 2)), given both arguments are bools the functionality would be the same, but using && may be marginally clearer of this fact?

Copy link
Contributor

@JosephMoore25 JosephMoore25 left a comment

Choose a reason for hiding this comment

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

All looks good pending the performance check.

Is it worth including cstdint into Register.hh to also fix that issue, or will we leave it for the SME branch? Imo we may as well add it now to get rid of another potential error point. I didn't spot the separate PR, ignore!

@dANW34V3R
Copy link
Contributor Author

#rerun tests

Copy link
Contributor

@ABenC377 ABenC377 left a comment

Choose a reason for hiding this comment

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

Approval subject to performance review of initialising with 0s

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

Successfully merging this pull request may close these issues.

4 participants