Skip to content

Add support for fpbuiltin accuracy lookup #9167

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 12 commits into from
May 30, 2023
Merged

Add support for fpbuiltin accuracy lookup #9167

merged 12 commits into from
May 30, 2023

Conversation

andykaylor
Copy link
Contributor

This patch adds a new interface that can be used to lookup the required accuracy of floating-point builtin intrinsics for a specified type and accuracy level (high, medium, low, sycl, or cuda).

A later change will add support for this functionality in the IRBuilder class.

@andykaylor andykaylor requested a review from zahiraam April 22, 2023 00:15
@andykaylor andykaylor requested a review from a team as a code owner April 22, 2023 00:15
@andykaylor andykaylor temporarily deployed to aws April 22, 2023 01:20 — with GitHub Actions Inactive
@andykaylor andykaylor temporarily deployed to aws April 22, 2023 03:12 — with GitHub Actions Inactive
@andykaylor andykaylor requested review from bader and asudarsa April 24, 2023 23:44
@andykaylor andykaylor temporarily deployed to aws April 25, 2023 01:09 — with GitHub Actions Inactive
@andykaylor andykaylor temporarily deployed to aws April 25, 2023 04:35 — with GitHub Actions Inactive
@andykaylor
Copy link
Contributor Author

@AlexeySachkov Can you review this PR? Some of the code in PR #8280 is taken from this PR. I've addressed the comment you made there. I would like to land this first to unblock progress in 8280. Thanks!

@andykaylor andykaylor temporarily deployed to aws May 5, 2023 22:57 — with GitHub Actions Inactive
@andykaylor andykaylor temporarily deployed to aws May 6, 2023 03:45 — with GitHub Actions Inactive
Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

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

A few (rather minor) comments, but otherwise looks good to me

Copy link
Contributor

@asudarsa asudarsa left a comment

Choose a reason for hiding this comment

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

Sorry for delayed review. Looks good to me. Thanks. Just one minor nit.

assert((Ty->isFloatTy() || Ty->isDoubleTy()) &&
"Invalid type for FPAccuracy");

// High and medium accuracy have the same requirement for all functions
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there documentation for how these values are selected? May be a link here can be handy?

Copy link
Contributor Author

@andykaylor andykaylor May 11, 2023

Choose a reason for hiding this comment

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

For high, medium, and low, the accuracy requirements are copied from the icc compiler's -fimf-precision=[high|medium|low] option (https://www.intel.com/content/www/us/en/docs/dpcpp-cpp-compiler/developer-guide-reference/2023-0/fimf-precision-qimf-precision.html). To those who have never used icc, these values are essentially arbitrary, but we've found them to be good choices for users.

I don't intend for this to be permanently bound to the icc meaning, so I don't think this is worth mentioning in the comments.

Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

LGTM.

Just a few minor comments.

Comment on lines 22 to 23
// Note: for single-precision fdiv and sqrt, the value returned here assumes
// that the "-cl-fp32-correctly-rounded-divide-sqrt " option is not used.
Copy link
Contributor

Choose a reason for hiding this comment

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

`

Suggested change
// Note: for single-precision fdiv and sqrt, the value returned here assumes
// that the "-cl-fp32-correctly-rounded-divide-sqrt " option is not used.
// Note: for single-precision fdiv and sqrt, the value returned here assumes
// that the "-cl-fp32-correctly-rounded-divide-sqrt" option is not used.

-cl-fp32-correctly-rounded-divide-sqrt is OpenCL flag, but this table defines accuracy only for SYCL and CUDA. This note is confusing.

Are there plans to define accuracy for other GPU programming languages like HIP, OpenMP offloading, OpenCL?

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've updated the comment. I'm not aware of any current plans to define accuracy levels for other models. I'm not sure what requirements other platforms have. In fact, I think even the CUDA accuracy is a statement of the actual accuracy provided by CUDA's math library and not a "requirement" as such. I think its usefulness here is for people who aren't using CUDA but want results that are as accurate as they would have gotten with CUDA. The SYCL level defined here is actually derived from the OpenCL standard, and it would also apply to OpenMP implementations that use OpenCL as their offload mechanism. I couldn't find any accuracy requirement documentation for HIP.

@andykaylor andykaylor temporarily deployed to aws May 11, 2023 19:50 — with GitHub Actions Inactive
@andykaylor andykaylor temporarily deployed to aws May 11, 2023 22:46 — with GitHub Actions Inactive
Andy Kaylor added 7 commits May 19, 2023 13:20
This patch adds a new interface that can be used to lookup the required
accuracy of floating-point builtin intrinsics for a specified type and
accuracy level (high, medium, low, sycl, or cuda).

A later change will add support for this functionality in the IRBuilder
class.
@andykaylor andykaylor temporarily deployed to aws May 19, 2023 21:31 — with GitHub Actions Inactive
@andykaylor andykaylor temporarily deployed to aws May 19, 2023 22:33 — with GitHub Actions Inactive
@zahiraam
Copy link
Contributor

The #include in the LIT test seems to still be there. When removed, this LGTM. Thanks.

@andykaylor andykaylor temporarily deployed to aws May 22, 2023 18:35 — with GitHub Actions Inactive
@andykaylor andykaylor temporarily deployed to aws May 22, 2023 19:59 — with GitHub Actions Inactive
@andykaylor andykaylor temporarily deployed to aws May 24, 2023 17:40 — with GitHub Actions Inactive
@andykaylor andykaylor temporarily deployed to aws May 24, 2023 18:13 — with GitHub Actions Inactive
@bader bader merged commit eafd768 into intel:sycl May 30, 2023
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.

5 participants