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

Update non-compliance version to allow definition checks #603

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

vmalia
Copy link
Contributor

@vmalia vmalia commented Dec 10, 2024

Problem Statement

When using a definition check,

#ifdef ONEMATH_BLAS_SPEC_VERSION

a preprocessor may evaluate an undefined macro to 0. This means that the existing 000 version for non-compliance is equivalent to the macro not being defined at all and yields the same result for #ifdef.

Solution

To enable the check for definition of the macro itself, meaning, provide different outputs for:

#define ONEMATH_BLAS_SPEC_VERSION 0   // domain non-compliant with specification

case and

// #define ONEMATH_BLAS_SPEC_VERSION   // missing macro definition, may be 0

case, we need to use a number other than 0. 001 is hence proposed as the non-compliance version. It does not conflict with any existing release of the specification. As a natural extension, versions between 001 and 100(Spec release 1.0), can be treated as alpha/beta and used as per special cases that can be defined later as and if needed.

Thanks to @zettai-reido for detecting this issue.

@vmalia
Copy link
Contributor Author

vmalia commented Dec 10, 2024

@rscohn2 @zettai-reido please approve.

@Rbiessy
Copy link
Contributor

Rbiessy commented Dec 11, 2024

I have no issues with this change but I don't understand the motivation for it.

a preprocessor may evaluate an undefined macro to 0

Can you elaborate more on this? This sounds like a compiler issue or a different issue. Which compiler are you using and do you have a reproducer?

This example shows that the ifdef branch should only be taken if a macro is defined on clang: https://gcc.godbolt.org/z/6P6rh5cv5

@zettai-reido
Copy link
Contributor

I have no issues with this change but I don't understand the motivation for it.

a preprocessor may evaluate an undefined macro to 0

Can you elaborate more on this? This sounds like a compiler issue or a different issue. Which compiler are you using and do you have a reproducer?

This example shows that the ifdef branch should only be taken if a macro is defined on clang: https://gcc.godbolt.org/z/6P6rh5cv5

Please try simpler one:

#if X > 0
#warning "X > 0"
#else
#warning "X == 0"
#endif

https://gcc.gnu.org/onlinedocs/cpp/If.html

@Rbiessy
Copy link
Contributor

Rbiessy commented Dec 11, 2024

Thanks for the explanation, that's good to know!
The situation could always be de-ambiguated by checking if defined(X) but maybe it is easier if the version is set to a positive integer.

@vmalia
Copy link
Contributor Author

vmalia commented Dec 11, 2024

@rscohn2 can you please help with the merge?

@Rbiessy
Copy link
Contributor

Rbiessy commented Dec 11, 2024

Is this urgent? I am also able to merge.

@vmalia
Copy link
Contributor Author

vmalia commented Dec 11, 2024

@Rbiessy please go ahead. Not urgent, but trying to close on the spec versioning, since there are oneMKL product changes pending on this PR.

@Rbiessy Rbiessy merged commit 177829a into uxlfoundation:main Dec 11, 2024
3 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