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

[SYCL] Check for nan/inf in stream class #522

Merged
merged 1 commit into from
Aug 20, 2019
Merged

Conversation

againull
Copy link
Contributor

Signed-off-by: Artur Gainullin artur.gainullin@intel.com

Copy link
Contributor

@romanovvlad romanovvlad left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -83,7 +83,7 @@ static inline std::string codeToString(cl_int code){
#endif

#if __has_attribute(always_inline)
#define ALWAYS_INLINE __attribute__((always_inline))
#define ALWAYS_INLINE __attribute__((always_inline)) inline
Copy link
Contributor

Choose a reason for hiding this comment

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

How this modification related to the adding check for nan values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use sycl builtins to check for nan/inf values. Usage of these builtins causes warnings. Purpose of this change is to fix these warnings.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are changing the define semantics w/o updating the name!
Can you just apply inline keyword to specific built-ins you are using?
Also I'm not sure I follow what warning is emitted, so it's hard to say what is the right fix.

Copy link
Contributor Author

@againull againull Aug 19, 2019

Choose a reason for hiding this comment

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

Moved inline keyword from macro to builtin declaration.

Short description of the problem:
According to always_inline attribute description in gcc's documentation https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html:
For functions *declared inline*, this attribute inlines the function independent of any restrictions that otherwise apply to inlining.
This means that if declaration is not marked inline then warning will be generated.

Problem could be reproduced in the following test case:

#include <CL/sycl.hpp>

int main() {
  return 0;
}

When compiling with gcc 5.4.0:
g++ -std=c++11 -I$PATH_TO_SYCL/sycl/include test.cpp -c
gives the bunch of warnings:
"sycl/include/CL/sycl/detail/builtins.hpp:32:19: warning: always_inline function might not be inlinable [-Wattributes]"

If you think that I shouldn't fix this in this patch or my fix doesn't look good then I can create issue and assign it to the author.

if (Exp16 == 0x1f) {
if (Sign)
return append(Buf, "-inf");
else
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, do not put else after return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx, fixed.

else if (isinf(Val)) {
if (signbit(Val))
return append(Buf, "-inf");
else
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, do not put else after return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx, fixed.

checkForInfNan(char *Buf, T Val) {
if (isnan(Val))
return append(Buf, "nan");
else if (isinf(Val)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

No else after return, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, fixed.

Signed-off-by: Artur Gainullin <artur.gainullin@intel.com>
@bader bader merged commit b63a96f into intel:sycl Aug 20, 2019
steffenlarsen added a commit to steffenlarsen/llvm that referenced this pull request Apr 8, 2022
intel#522 removed the propagation of the ImportedHostPtr argument
from _pi_buffer to the _pi_mem superclass. This seems like an unintended
change and this commit re-adds the propagation.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
againull pushed a commit that referenced this pull request Apr 8, 2022
#522 removed the propagation of the ImportedHostPtr argument
from _pi_buffer to the _pi_mem superclass. This seems like an unintended
change and this commit re-adds the propagation.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
@againull againull deleted the stream_nan_inf branch December 3, 2022 00:02
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.

4 participants