8000 [SYCL] Fixed bug regarding device caching by kholland-intel · Pull Request #2566 · intel/llvm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[SYCL] Fixed bug regarding device caching #2566

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
Oct 15, 2020

Conversation

kholland-intel
Copy link
Contributor
@kholland-intel kholland-intel commented Sep 29, 2020

Created a new function, populateDeviceCacheIfNeeded, so that cached devices could be
shared across both piDevicesGet and piextDeviceCreateWithNativeHandle. This
new function will check/fill and return cached devices.

Renamed getOrCreatePlatforms to getPlatformCache, and refactored the function so
that it limits level zero driver calls and removes redundant code.

Called getOrMakePlatformImpl() from make_platform() so that the PlatformImpl
cache is accessible to platforms that are created using a native handle.

Called getOrMakeDeviceImpl() from make_device() so that the DeviceImpl cache is
accessible to devices that are created using a native handle.

Also, added an E2E test for these changes.

Created a new function, getOrCreateDevice, so that cached devices could be
shared across both piDevicesGet and piextDeviceCreateWithNativeHandle. This
new function will check/fill and return cached devices.
Created a new function, populateDeviceCacheIfNeeded, so that cached devices could be
shared across both piDevicesGet and piextDeviceCreateWithNativeHandle. This
new function will check/fill and return cached devices.

Renamed getOrCreatePlatforms to getPlatformCache, and refactored the function so
that it limits level zero driver calls and removes redundant code.
@kholland-intel
Copy link
Contributor Author

Mentioning @gmlueck for comments/code-review.

@gmlueck
Copy link
Contributor
gmlueck commented Oct 1, 2020

I think it would also be good to add errors checks to the calls to piextDeviceCreateWithNativeHandle() and piextPlatformCreateWithNativeHandle(). Probably, they should throw an exception if there is an error.

@kholland-intel
Copy link
Contributor Author

I think it would also be good to add errors checks to the calls to piextDeviceCreateWithNativeHandle() and piextPlatformCreateWithNativeHandle(). Probably, they should throw an exception if there is an error.

Currently, error checking is already occurring through the plugin::call interface. PI function calls (in this case 'piextDeviceCreateWithNativeHandle()' and 'piextPlatformCreateWithNativeHandle()') are passed into plugin::call as an argument and invoked from here. The result of the PI call is recorded and is passed into a function called checkPiResult() which will throw an exception if the result is not a PI_SUCCESS.

Created a new function, populateDeviceCacheIfNeeded, so that cached devices could be
shared across both piDevicesGet and piextDeviceCreateWithNativeHandle. This
new function will check/fill and return cached devices.

Renamed getOrCreatePlatforms to getPlatformCache, and refactored the function so
that it limits level zero driver calls and removes redundant code.

Also, added an E2E test for these changes.
@kholland-intel kholland-intel requested a review from a team as a code owner October 7, 2020 22:04
Created a new function, populateDeviceCacheIfNeeded, so that cached devices could be
shared across both piDevicesGet and piextDeviceCreateWithNativeHandle. This
new function will check/fill and return cached devices.

Renamed getOrCreatePlatforms to getPlatformCache, and refactored the function so
that it limits level zero driver calls and removes redundant code.

Called getOrMakePlatformImpl() from make_platform() so that the PlatformImpl
cache is accessible to platforms that are created using a native handle.

Called getOrMakeDeviceImpl() from make_device() so that the DeviceImpl cache is
accessible to devices that are created using a native handle.

Also, added an E2E test for these changes.
Made make_platform() and make_device() friends of the platform and device class,
respectively.
@kholland-intel
Copy link
Contributor Author

@smaslov-intel @romanovvlad Do you have any comments on these changes?
Also, I want to point out that I did not attempt to change any similar issue that may exist for the opencl backend. I know that there is a similar bug where make_device and make_platform does not have access to the cache of device_impl and platform_impl objects on opencl.

Added check for Level Zero Drivers/Devices to cache_test.cpp

Removed line changes from platform and device constructors.
Removed direct reference to level_zero namespace from generic SYCL headers
(device and platform headers).
romanovvlad
romanovvlad previously approved these changes Oct 14, 2020
Copy link
Contributor
@romanovvlad romanovvlad left a comment

Choose a reason for hiding this comment

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

Ok with me.

Created a new function, populateDeviceCacheIfNeeded, so that cached devices could be
shared across both piDevicesGet and piextDeviceCreateWithNativeHandle. This
new function will check/fill and return cached devices.

Removed the function getOrCreatePlatforms.

Refactored PiPlatformsGet to limit the number Level Zero driver calls.

Called PiPlatformsGet from piextPlatformCreateWithNativeHandle so that the
latter has access to the platform cache maintained in the former.

Called getOrMakePlatformImpl from make_platform so that the PlatformImpl cache
is accessible to platforms that are created using a native handle.

Called getOrMakeDeviceImpl from make_device so that the DeviceImpl cache is
accessible to devices that are created using a native handle.

Also, added an E2E test for these changes.
Removed unnecessary lambda function from PiPlatformsGet.
smaslov-intel
smaslov-intel previously approved these changes Oct 15, 2020
Copy link
Contributor
@smaslov-intel smaslov-intel left a comment

Choose a reason for hiding this comment

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

LGTM

Fixed typo in comments.

Co-authored-by: smaslov-intel <48694368+smaslov-intel@users.noreply.github.com>
@romanovvlad romanovvlad merged commit ce29b77 into intel:sycl Oct 15, 2020
kbenzie pushed a commit to kbenzie/intel-llvm that referenced this pull request Feb 17, 2025
ShadowMemory should increment/decrement device handle
Chenyang-L pushed a commit that referenced this pull request Feb 18, 2025
ShadowMemory should increment/decrement device handle
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
0