Skip to content

Conversation

@AidanBeltonS
Copy link
Contributor

This PR adds a static cast to builtins_relational functions which apply a negative operation to a boolean type.
This is only applied to functions which are specialised for cl_half. The cast prevents windows error message C4804.

This resolves a windows build issue introduced by #6061

@AidanBeltonS AidanBeltonS requested a review from a team as a code owner May 10, 2022 11:15
@AidanBeltonS
Copy link
Contributor Author

@yanfeng3721, ping

namespace {

template <typename T> inline T __vFOrdEqual(T x, T y) { return -(x == y); }
template <typename T> inline T __vFOrdEqual(T x, T y) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should these return a bool or T?
Where in the spec, this is stated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

__vFOrdEqual is not stated in the spec. I am not sure as to if this should return a bool or T.
The goal of this change to resolve an issue with building DPCPP on windows and not to change any functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

All these are part of 4.17.9. Relational functions. Some of them should return bool. However, you are right that the PR does not change any functionality. If there is a a problem, it was already there in the original code.

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 functions modified here are all ok, because they're vector and vector versions don't return bool at all (even all/any).

As for the scalar version (not touched in this PR), this is slightly more complicated as SYCL1.2.1 and SYCL2020 differ here. Those, however, are all internal details and not the user-visible routines so technically we can have them defined whatever way we want to be able to implement user-visible wrappers in a way dependent on the presence of SYCL2020_CONFORMANT_APIS macro.

Copy link
Contributor

@v-klochkov v-klochkov May 10, 2022

Choose a reason for hiding this comment

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

BTW, my guess why it returns -1 is because it is often good for vectorizer to have element filled with ones or with zeroes for using in vector mask operations like VANDPS/VORPS,
but I also was puzzled seeing return of -1.0 for float comparison.
It would be logically more correct to returning int32_t{-1} for float32 rather than -1.0

Copy link
Contributor

Choose a reason for hiding this comment

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

User-visible methods must do exactly that according to the spec. I guess/think/hope that only those internal functions behave differently for some reason.

Copy link
Contributor

@dkhaldi dkhaldi left a comment

Choose a reason for hiding this comment

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

While there seem to be ambiguity on the return type for these SYCL relational functions, this specific change to solve the build bugs on Windows LGTM.
I would suggest opening a new PR to check and correct the return type if something is wrong.

@pvchupin pvchupin merged commit 4667915 into intel:sycl May 10, 2022
@v-klochkov
Copy link
Contributor

This PR is supposed to fix the build errors on Windows, but CI still fails: http://llvm-ci-test2.intel.com:8080/blue/organizations/jenkins/SYCL_CI%2Fintel%2FWin%2FTest_Suite/detail/Test_Suite/1869/pipeline

`[2022-05-10T16:33:14.773Z] W:\jenkins-dir\workspace\SYCL_CI\intel\Win\Test_Suite\llvm.src\sycl\source\detail\builtins_relational.cpp(230): error C2220: the following warning is treated as an error

[2022-05-10T16:33:14.773Z] W:\jenkins-dir\workspace\SYCL_CI\intel\Win\Test_Suite\llvm.src\sycl\source\detail\builtins_relational.cpp(230): warning C4804: '-': unsafe use of type 'bool' in operation

[2022-05-10T16:33:14.773Z] W:\jenkins-dir\workspace\SYCL_CI\intel\Win\Test_Suite\llvm.src\sycl\source\detail\builtins_relational.cpp(24): warning C4804: '-': unsafe use of type 'bool' in operation

[2022-05-10T16:33:14.773Z] W:\jenkins-dir\workspace\SYCL_CI\intel\Win\Test_Suite\llvm.src\sycl\source\detail\builtins_relational.cpp(155): note: see reference to function template instantiation 'T cl::__host_std::`anonymous-namespace'::__vFOrdEqualcl::sycl::cl_half(T,T)' being compiled

[2022-05-10T16:33:14.773Z] with

[2022-05-10T16:33:14.773Z] [

[2022-05-10T16:33:14.773Z] T=cl::sycl::cl_half

[2022-05-10T16:33:14.773Z] ]

[2022-05-10T16:33:14.773Z] W:\jenkins-dir\workspace\SYCL_CI\intel\Win\Test_Suite\llvm.src\sycl\source\detail\builtins_relational.cpp(28): warning C4804: '-': unsafe use of type 'bool' in operation`

@pvchupin
Copy link
Contributor

I've checked locally that it helps before merging. I think it fails for reference compiler, that's the only possible explanation I have.

@bader
Copy link
Contributor

bader commented May 10, 2022

I think it fails for reference compiler, that's the only possible explanation I have.

Whether it fails for reference compiler or not must be clear from the logs.

@pvchupin
Copy link
Contributor

@bader, I can't understand that from logs. Tagging @tfzhu.
In any case post-commit passed, so I believe original issue is resolved.

@AidanBeltonS AidanBeltonS deleted the fix_windows_build_error branch June 9, 2022 09:29
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.

6 participants