-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Emit fpbuiltin version of function only for function with FP arguments. #17253
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ad4fde0
[SYCL] Emit fpbuiltin version of the function only if its arguments are
zahiraam 1ea6557
Fixed LIT test.
zahiraam e81f546
Fix LIT test.
zahiraam 5350251
Replaced fdiv with / operator.
zahiraam 630b373
Added a minimalist half class.
zahiraam a38a942
Fixed typo.
zahiraam 4e7009b
Merge remote-tracking branch 'origin/sycl' into NoFloatSqrtArgs
zahiraam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#define __SYCL_CONSTEXPR_HALF constexpr | ||
using StorageT = _Float16; | ||
|
||
class half { | ||
public: | ||
half() = default; | ||
constexpr half(const half &) = default; | ||
constexpr half(half &&) = default; | ||
|
||
__SYCL_CONSTEXPR_HALF half(const float &rhs) : Data(rhs) {} | ||
|
||
constexpr half &operator=(const half &rhs) = default; | ||
|
||
__SYCL_CONSTEXPR_HALF half &operator/=(const half &rhs) { | ||
Data /= rhs.Data; | ||
return *this; | ||
} | ||
|
||
#define OP(op, op_eq) \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const half lhs, \ | ||
const half rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend double operator op(const half lhs, \ | ||
const double rhs) { \ | ||
double rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend double operator op(const double lhs, \ | ||
const half rhs) { \ | ||
double rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend float operator op(const half lhs, \ | ||
const float rhs) { \ | ||
float rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend float operator op(const float lhs, \ | ||
const half rhs) { \ | ||
float rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const half lhs, \ | ||
const int rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const int lhs, \ | ||
const half rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const half lhs, \ | ||
const long rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const long lhs, \ | ||
const half rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const half lhs, \ | ||
const long long rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const long long lhs, \ | ||
const half rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const half &lhs, \ | ||
const unsigned int &rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const unsigned int &lhs, \ | ||
const half &rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const half &lhs, \ | ||
const unsigned long &rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const unsigned long &lhs, \ | ||
const half &rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op( \ | ||
const half &lhs, const unsigned long long &rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} \ | ||
__SYCL_CONSTEXPR_HALF friend half operator op(const unsigned long long &lhs, \ | ||
const half &rhs) { \ | ||
half rtn = lhs; \ | ||
rtn op_eq rhs; \ | ||
return rtn; \ | ||
} | ||
OP(/, /=) | ||
|
||
#undef OP | ||
|
||
// Operator float | ||
__SYCL_CONSTEXPR_HALF operator float() const { | ||
return static_cast<float>(Data); | ||
} | ||
|
||
private: | ||
__SYCL_CONSTEXPR_HALF StorageT getFPRep() const { return Data; } | ||
|
||
StorageT Data; | ||
}; | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.