Skip to content

[SYCL][libdevice] Add always_inline for libdevice functions. #5979

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 4 commits into from
Apr 12, 2022

Conversation

jinge90
Copy link
Contributor

@jinge90 jinge90 commented Apr 7, 2022

Signed-off-by: jinge90 [email protected]

@jinge90 jinge90 requested a review from a team as a code owner April 7, 2022 08:36
@jinge90 jinge90 requested a review from v-klochkov April 7, 2022 08:36
@jinge90
Copy link
Contributor Author

jinge90 commented Apr 7, 2022

This PR decorates all functions in SYCL libdevice with "always_inline" which is friendly to underlying runtime to do inline optimization.

@jinge90
Copy link
Contributor Author

jinge90 commented Apr 8, 2022

/summary:run

@jinge90 jinge90 requested a review from xtian-github April 8, 2022 08:45
@jinge90
Copy link
Contributor Author

jinge90 commented Apr 8, 2022

Hi, @xtian-github
This PR adds "attribute((always_inline))" to all libdevice functions. With this patch, we can see "AlwaysInline" is used to decorated all libdevice functions in LLVM IR level. Does this meet underlying runtime's requirement?

Thanks very much.

@xtian-github
Copy link

Hi, @xtian-github This PR adds "attribute((always_inline))" to all libdevice functions. With this patch, we can see "AlwaysInline" is used to decorated all libdevice functions in LLVM IR level. Does this meet underlying runtime's requirement?

Thanks very much.

Yes. Thanks.

Copy link

@xtian-github xtian-github left a comment

Choose a reason for hiding this comment

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

LGTM

@v-klochkov
Copy link
Contributor

v-klochkov commented Apr 8, 2022

This PR decorates all functions in SYCL libdevice with "always_inline" which is friendly to underlying runtime to do inline optimization.

I still have questions about reasoning of this fix. 1) Can "underlying runtime" do inlining without this attribute now?
2) If (1) is Yes, then wouldn't adding this attribute unconditionally to all device funcs increase the code size on device too much?

@xtian-github
Copy link

This PR decorates all functions in SYCL libdevice with "always_inline" which is friendly to underlying runtime to do inline optimization.

I still have questions about reasoning of this fix. 1) Can "underlying runtime" do inlining without this attribute now? 2) If (1) is Yes, then wouldn't adding this attribute unconditionally to all device funcs increase the code size on device too much?

Actually, the current compiler is trying to do "always_inline" for device already, adding this attribute is to add certain guarantee. It does not increase the code size on device much.

@v-klochkov
Copy link
Contributor

v-klochkov commented Apr 8, 2022

This PR decorates all functions in SYCL libdevice with "always_inline" which is friendly to underlying runtime to do inline optimization.

I still have questions about reasoning of this fix. 1) Can "underlying runtime" do inlining without this attribute now? 2) If (1) is Yes, then wouldn't adding this attribute unconditionally to all device funcs increase the code size on device too much?

Actually, the current compiler is trying to do "always_inline" for device already, adding this attribute is to add certain guarantee. It does not increase the code size on device much.

It sounds like the compiler is doing great job already and "is trying to do always_inline for device always". If there are cases where inlining is not done, then there are good reasons for that, right?

Also, is this fix motivated by correctness or performance reasons?

@xtian-github
Copy link

@v-klochkov provide guarantee on performance.

@jinge90
Copy link
Contributor Author

jinge90 commented Apr 12, 2022

Hi, @v-klochkov
All pre-ci tests passed, could you help merge this patch?

Thanks very much.

@v-klochkov v-klochkov merged commit dfc87cc into intel:sycl Apr 12, 2022
@al42and
Copy link
Contributor

al42and commented Apr 12, 2022

Note: there are now numerous warnings in libdevice due to conflicting attributes:

/home/aland/intel-sycl/llvm/libdevice/device_itt.h:78:1: warning: 'always_inline' attribute ignored [-Wignored-attributes]
DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void
^
/home/aland/intel-sycl/llvm/libdevice/device.h:26:25: note: expanded from macro 'DEVICE_EXTERN_C'
#define DEVICE_EXTERN_C DEVICE_EXTERNAL EXTERN_C
                        ^
/home/aland/intel-sycl/llvm/libdevice/device.h:21:54: note: expanded from macro 'DEVICE_EXTERNAL'
  SYCL_EXTERNAL __attribute__((weak)) __attribute__((always_inline))
                                                     ^
/home/aland/intel-sycl/llvm/libdevice/device_itt.h:78:17: note: conflicting attribute is here
DEVICE_EXTERN_C ITT_STUB_ATTRIBUTES void
                ^
/home/aland/intel-sycl/llvm/libdevice/device_itt.h:17:54: note: expanded from macro 'ITT_STUB_ATTRIBUTES'
#define ITT_STUB_ATTRIBUTES __attribute__((noinline, optnone))

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