Skip to content

[SYCL][libclc] Remangler tool for consistent mangling #4207

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 5 commits into from
Aug 13, 2021

Conversation

steffenlarsen
Copy link
Contributor

Libclc mangling is either done manually or done based on the function signatures if requested. However, since libclc uses OpenCL C, the primitive types are of set sizes and signedness, eg. long must be 64 bits and char must be signed.

When a target disagrees on primitive types it may use incompatible libclc functions due to inconsistent mangling between libclc and the target.

This commit adds a tool for remangling libclc bitcode files such that the mangled names match the primitive types for the target.
Additionally it creates aliases where appropriate, eg. if long is 32 bits on the target a function using long will have its mangling changed to appear as if it is using long long instead, and the old mangling will be made an alias to an existing 32-bit integer version of the function if such a function exists.

The remangler is used for the SYCL CUDA and ROCm backends to avoid having to "fake" signed char, long long and unsigned long long in libclc.

Libclc mangling is either done manually or done based on the function
signatures if requested. However, since libclc uses OpenCL C, the
primitive types are of set sizes and signedness, eg. long must be 64
bits and char must be signed.

When a target disagrees on primitive types it may use incompatible
libclc functions due to inconsistent mangling between libclc and the
target.

This commit adds a tool for remangling libclc bitcode files such that
the mangled names match the primitive types for the target.
Additionally it creates aliases where appropriate, eg. if long is 32
bits on the target a function using long will have its mangling changed
to appear as if it is using long long instead, and  the old mangling
will be made an alias to an existing 32-bit integer version of the
function if such a function exists.

Signed-off-by: Steffen Larsen <[email protected]>
Signed-off-by: Steffen Larsen <[email protected]>
@dm-vodopyanov
Copy link
Contributor

/summary:run

Copy link
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

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

FE changes look ok to me but @AaronBallman @premanandrao, can one of you take a look as well? I'm not very familiar with this

dm-vodopyanov
dm-vodopyanov previously approved these changes Jul 29, 2021
Copy link
Contributor

@dm-vodopyanov dm-vodopyanov left a comment

Choose a reason for hiding this comment

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

Temporarily approving for triggering Github checks. Will revoke the approval after that.

@dm-vodopyanov dm-vodopyanov dismissed their stale review July 29, 2021 15:04

Revoke the approval, checks were started.

@bader bader added cuda CUDA back-end libclc libclc project related issues labels Jul 29, 2021
dm-vodopyanov
dm-vodopyanov previously approved these changes Jul 29, 2021
Copy link
Contributor

@dm-vodopyanov dm-vodopyanov left a comment

Choose a reason for hiding this comment

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

sycl/include/CL/__spirv/spirv_ops.hpp LGTM

Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

I have no issues with this, just a minor nit with a diagnostic quoting.

Signed-off-by: Steffen Larsen <[email protected]>
AaronBallman
AaronBallman previously approved these changes Jul 30, 2021
Copy link
Contributor

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

FE bits LGTM!

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.

Signed-off-by: Steffen Larsen <[email protected]>
@bader
Copy link
Contributor

bader commented Aug 2, 2021

@mdtoguchi, @AGindinson, ping.

bader
bader previously approved these changes Aug 2, 2021
AGindinson
AGindinson previously approved these changes Aug 2, 2021
Copy link
Contributor

@AGindinson AGindinson left a comment

Choose a reason for hiding this comment

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

The Driver part looks good in the context of the change.

@AGindinson AGindinson requested a review from AaronBallman August 2, 2021 10:22
dm-vodopyanov
dm-vodopyanov previously approved these changes Aug 2, 2021
Copy link
Contributor

@dm-vodopyanov dm-vodopyanov left a comment

Choose a reason for hiding this comment

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

sycl/include/CL/__spirv/spirv_ops.hpp LGTM

@AidanBeltonS AidanBeltonS dismissed stale reviews from dm-vodopyanov, AGindinson, and bader via 73b844e August 4, 2021 15:57
@codeplay-sycl codeplay-sycl force-pushed the steffen/libclc-remangler branch 3 times, most recently from fb5cc9f to e8171e6 Compare August 9, 2021 09:41
@bader bader added the hip Issues related to execution on HIP backend. label Aug 10, 2021
Copy link
Contributor

@dm-vodopyanov dm-vodopyanov left a comment

Choose a reason for hiding this comment

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

sycl/include/CL/__spirv/spirv_ops.hpp LGTM

@keryell
Copy link
Contributor

keryell commented Aug 10, 2021

The introduction of this PR has a lot of information that should be present somewhere as comments in the code or is the design documentation, if it is not done already.

@AidanBeltonS
Copy link
Contributor

The introduction of this PR has a lot of information that should be present somewhere as comments in the code or is the design documentation, if it is not done already.

The PR introduction information has not been commented or added into the design docs within this PR. I could do a separate PR adding to the design docs and commenting the relevant portions with the details in the intro. Would this work for you?

@steffenlarsen
Copy link
Contributor Author

The introduction of this PR has a lot of information that should be present somewhere as comments in the code or is the design documentation, if it is not done already.

LibclcRemangler.cpp has a description early in the file to document the purpose of the tool, similar to the PR introduction. That said, if there is a suitable place to give a quick summary and refer to it I agree that it would be a good idea to do so. It is a bit of a shadow agent tool.

Copy link
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

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

FE changes LGTM

@bader bader merged commit 66276bd into intel:sycl Aug 13, 2021
steffenlarsen added a commit to steffenlarsen/llvm that referenced this pull request Aug 16, 2021
bader pushed a commit that referenced this pull request Aug 17, 2021
…4348)

Remangler tool introduced with #4207 also included simplifications to the use of `signed char` in libclc. These simplifications changed the generated SPIRV builtins in a way that causes previously passing CTS tests to fail.

This PR reverts the `signed char` simplifications, preserving the remangler and the `long` simplifications.

Signed-off-by: Steffen Larsen <[email protected]>
bader pushed a commit that referenced this pull request Sep 13, 2021
Patch adds windows support for CUDA backend. 

Adds general handling of Windows file paths
Windows support is enabled with remangling of variables from PR #4207 as it fixes mismatch between windows 32-bit longs and default 64-bit long and handles wchar_size.
Adds changes to account for MSVC's default to private classes.
Fixes to unittests for windows.

Signed-off-by: Steffen Larsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda CUDA back-end hip Issues related to execution on HIP backend. libclc libclc project related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants