Skip to content

[SYCL] Link SYCL device libraries by default. #2400

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 18 commits into from
Sep 15, 2020

Conversation

jinge90
Copy link
Contributor

@jinge90 jinge90 commented Sep 1, 2020

As not all backends have supported spv file online link, we decided to
disable fallback spv libraries online link at this time. Instead, all
wrapper and fallback .o files will be linked offline. When all backends
support spv online link, we will switch to online link for jit compilation
transparently.

Signed-off-by: gejin [email protected]

@jinge90 jinge90 requested a review from v-klochkov September 1, 2020 07:46
As not all backends have supported spv file online link, we decided to
disable fallback spv libraries online link at this time. Instead, all
wrapper and fallback .o files will be linked offline. When all backends
support spv online link, we will switch to online link for jit compilation
transparently.

Signed-off-by: gejin <[email protected]>
@jinge90 jinge90 requested review from asavonic and vzakhari and removed request for v-klochkov September 1, 2020 07:47
@jinge90
Copy link
Contributor Author

jinge90 commented Sep 1, 2020

Hi, @vzakhari and @mdtoguchi
As we discussed, I extracted the "linking" part from #2277
In this PR, all device libraries including wrapper and fallback device libraries are linked offline by default. I disabled the spv fallback device libraries online link in SYCL runtime.
When all backends support spv online link, we will switch back to online link for jit compilation transparently.

@jinge90
Copy link
Contributor Author

jinge90 commented Sep 1, 2020

/summary:run

Signed-off-by: gejin <[email protected]>
@jinge90
Copy link
Contributor Author

jinge90 commented Sep 3, 2020

Hi, @mdtoguchi
I have added the -f[no-]sycl-device-lib option, could you help me review it?
Thank you very much.

@jinge90
Copy link
Contributor Author

jinge90 commented Sep 3, 2020

/summary:run

vzakhari
vzakhari previously approved these changes Sep 3, 2020
Copy link
Contributor

@vzakhari vzakhari left a comment

Choose a reason for hiding this comment

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

LGTM for devicelib tests.

Copy link
Contributor

@mdtoguchi mdtoguchi left a comment

Choose a reason for hiding this comment

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

Could you add a driver specific test verifying that the various expected device libs are being pulled in for unbundling and use?

@jinge90
Copy link
Contributor Author

jinge90 commented Sep 4, 2020

/summary:run

@jinge90
Copy link
Contributor Author

jinge90 commented Sep 4, 2020

Could you add a driver specific test verifying that the various expected device libs are being pulled in for unbundling and use?

Hi, @mdtoguchi , I have added 2 driver lit tests(Linux + Windows) for "-f[no-]sycl-device-lib" option. Please help review.
Thank you very much.

@jinge90
Copy link
Contributor Author

jinge90 commented Sep 4, 2020

LGTM for devicelib tests.

Hi, @vzakhari , I think we can enable the devicelib lit test for GPU platform since the "AOT" style link should work on all backend including those who haven't supported online spv link. The latest patch has enabled GPU.

@jinge90
Copy link
Contributor Author

jinge90 commented Sep 5, 2020

/summary:run

mdtoguchi
mdtoguchi previously approved these changes Sep 5, 2020
Copy link
Contributor

@mdtoguchi mdtoguchi left a comment

Choose a reason for hiding this comment

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

Driver LGTM

Copy link
Contributor

@mdtoguchi mdtoguchi left a comment

Choose a reason for hiding this comment

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

Thanks - LGTM

@jinge90
Copy link
Contributor Author

jinge90 commented Sep 11, 2020

Hi, @AGindinson ,@intel/llvm-reviewers-runtime and @pvchupin
Could you help review this PR?
Thank you very much.

Copy link
Contributor

@s-kanaev s-kanaev left a comment

Choose a reason for hiding this comment

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

Looks good overall.
Though, I have only a single comment.

Comment on lines -780 to -789
// The Level Zero driver support for online linking currently has bugs, but
// we think the DPC++ runtime support is ready. This environment variable
// gates the runtime support for online linking, so we can try enabling if a
// new driver is released before the next DPC++ release.
static bool EnableLevelZeroLink = std::getenv("SYCL_ENABLE_LEVEL_ZERO_LINK");
if (!EnableLevelZeroLink) {
if (Context->getPlugin().getBackend() == backend::level_zero) {
LinkDeviceLibs = false;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Online linking was disabled for Level Zero only. Now it's disabled for each and every backend. Why is that?
Another solution is to enable it for OpenCL backend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @s-kanaev
There are 2 reasons:

  1. The device library shouldn't depend on one specific backend to work, our final goal is to make device libraries to have same behavior in all backend. So, we switch to offline link for all backends.

  2. Simplifying the usage requires us to make some device libraries to be linked in by default in offline build phase. If we enable devicelib for OCL backend, we must only link "wrapper" obj device libs offline.
    However, to make L0 to work, we must link both "wrapper" and "fallback" libraries offline. Unfortunately, we can't know which backend will be used in offline build, so we have to disable all backends and switch back to "online" link transparently when L0 is ready.
    Thank you very much.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we are reaching the limit of a system if at the end everybody has to align on the intersection of all the features of the back-ends, which converges to the... empty set!
And if the root cause is a political back-end that nobody cares except the people who invented it, I am not super excited about this story jeopardizing all the other back-ends... :-/

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @keryell that special-casing for particular BEs in the generic SYCL runtime is something which should be avoided. The supposed way to avoid this is to extract the diverging piece of code into a separate function and make it part of the PI interface, hiding all specifics inside the plugin. @jinge90 - I'd suggest to add a TODO at least and maybe file an issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this PR removes the code that special-cases the L0 plugin.

Copy link
Contributor

Choose a reason for hiding this comment

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

Upon second look, it seems nothing level zero-specific is in the patch. LinkDeviceLibs have existed before. But still, would be good to have TODO/issue for BE-specific stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @kbobrovs @keryell and @gmlueck
I think all backends including Level zero will support online link, this patch is a temporary solution to make device library to work on all backends with same behaviors. Once all backends are ready, we will switch to "online" link transparently. I will add a "TODO" in another PR.
Thank you very much.

@romanovvlad romanovvlad merged commit 9dd18ca into intel:sycl Sep 15, 2020
alexbatashev pushed a commit to alexbatashev/llvm that referenced this pull request Sep 17, 2020
* upstream/sycl: (405 commits)
  [SYCL] Implement new env var SYCL_DEVICE_FILTER (intel#2239)
  [Driver][SYCL] Make /MD the default for -fsycl (intel#2478)
  [SYCL]: basic support of contexts with multiple devices in Level-Zero (intel#2440)
  [SYCL] Fix LIT regression after 9dd18ca (intel#2481)
  [SYCL][L0] Kernel Destroy in piKernelRelease (intel#2475)
  [SYCL] Emit an aliased function only if it is used (intel#2430)
  [Driver][SYCL] Add defaultlib directive for sycl lib (intel#2464)
  [Driver][SYCL] Improve situations where .exe is added for AOT tools (intel#2467)
  [SYCL][L0]: Check Queue refcnt prior to using members in event wait/release (intel#2471)
  [SYCL] Unroll several loops in __init method accessor class (intel#2449)
  [SYCL][Doc] Add link to use pinned memory spec (intel#2463)
  [SYCL] Link SYCL device libraries by default. (intel#2400)
  Revert "[SYCL] XFAIL test blcoking pulldown"
  Avoid usage of deprecated "VectorType::getNumElements" (intel#737)
  Fix nullptr dereference (intel#741)
  Do not translate arbitrary precision operations without corresponding extensions (intel#714)
  Add Constrained Floating-Point Intrinsics support
  [SYCL] Take into account auxiliary cmake options for Level Zero loader
  [InstCombine] improve fold of pointer differences
  [InstCombine] add ptr difference tests; NFC
  ...
@jinge90 jinge90 deleted the link_devicelib_by_default_in_aot_style branch January 26, 2021 01:21
Chenyang-L pushed a commit that referenced this pull request Feb 18, 2025
Revert "Add new launch property to support work_group_scratch_memory"
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.

8 participants