-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL] Do not build device code for sub-devices #5240
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
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cd9818b
[SYCL][NFC] Call getCacheItemPath only if cache is enabled
bader 04e3869
[SYCL][NFC] Don't include sycl.hpp from headers
bader ba29bbe
[SYCL][NFC] Factor out empty kernel creation boilerplate
bader f5b380b
[SYCL] Do not build device code for sub-devices.
bader 5a3587e
Apply clang-format
bader 28b7f80
Fix issues caught by pre-commit CI.
bader 61e09bd
[NFC] Fix a few typos in the comments
bader d5b93f0
Merge remote-tracking branch 'intel/sycl' into optimize-build
bader a1e483a
Improved build results caching for GPU devices.
bader 7ac48ae
Improve GPU caching.
bader d0f2861
Revert "Improve GPU caching."
bader 231a1a3
Revert "Improved build results caching for GPU devices."
bader 8f2d9c4
Merge remote-tracking branch 'intel/sycl' into optimize-build
bader d44e27f
Fix formatting.
bader 6e310b0
Add device query for checking if device architecture is homogeneous
bader ce299cd
Merge remote-tracking branch 'intel/sycl' into optimize-build
bader e6ca4f9
Address code review feedback
bader bf57926
Added a FIXME comment.
bader d062d77
Merge remote-tracking branch 'intel/sycl' into optimize-build
bader 0e650ea
Update sycl/source/detail/program_manager/program_manager.cpp
bader d1cc7aa
Move comment to Level Zero plug-in.
bader File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <CL/sycl/program.hpp> | ||
#include <detail/kernel_bundle_impl.hpp> | ||
|
||
#include <helpers/CommonRedefinitions.hpp> | ||
#include <helpers/PiImage.hpp> | ||
#include <helpers/PiMock.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <helpers/TestKernel.hpp> | ||
|
||
static pi_device rootDevice; | ||
static pi_device piSubDev1 = (pi_device)0x1; | ||
static pi_device piSubDev2 = (pi_device)0x2; | ||
|
||
namespace { | ||
pi_result redefinedDeviceGetInfo(pi_device device, pi_device_info param_name, | ||
size_t param_value_size, void *param_value, | ||
size_t *param_value_size_ret) { | ||
if (param_name == PI_DEVICE_INFO_PARTITION_PROPERTIES) { | ||
if (!param_value) { | ||
*param_value_size_ret = 2 * sizeof(pi_device_partition_property); | ||
} else { | ||
((pi_device_partition_property *)param_value)[0] = | ||
PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; | ||
((pi_device_partition_property *)param_value)[1] = | ||
PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; | ||
} | ||
} | ||
if (param_name == PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN) { | ||
if (!param_value) { | ||
*param_value_size_ret = sizeof(pi_device_affinity_domain); | ||
} else { | ||
((pi_device_affinity_domain *)param_value)[0] = | ||
PI_DEVICE_AFFINITY_DOMAIN_NUMA | | ||
PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE; | ||
} | ||
} | ||
if (param_name == PI_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES) { | ||
((pi_uint32 *)param_value)[0] = 2; | ||
} | ||
if (param_name == PI_DEVICE_INFO_PARENT_DEVICE) { | ||
if (device == piSubDev1 || device == piSubDev2) | ||
((pi_device *)param_value)[0] = rootDevice; | ||
else | ||
((pi_device *)param_value)[0] = nullptr; | ||
} | ||
return PI_SUCCESS; | ||
} | ||
|
||
pi_result redefinedDevicePartition( | ||
pi_device Device, const pi_device_partition_property *Properties, | ||
pi_uint32 NumDevices, pi_device *OutDevices, pi_uint32 *OutNumDevices) { | ||
if (OutNumDevices) | ||
*OutNumDevices = 2; | ||
if (OutDevices) { | ||
OutDevices[0] = {}; | ||
OutDevices[1] = {}; | ||
} | ||
return PI_SUCCESS; | ||
} | ||
|
||
pi_result redefinedDeviceRetain(pi_device c) { return PI_SUCCESS; } | ||
|
||
pi_result redefinedDeviceRelease(pi_device c) { return PI_SUCCESS; } | ||
|
||
pi_result redefinedProgramBuild( | ||
pi_program prog, pi_uint32, const pi_device *, const char *, | ||
void (*pfn_notify)(pi_program program, void *user_data), void *user_data) { | ||
static int m = 0; | ||
m++; | ||
// if called more than once return an error | ||
if (m > 1) | ||
return PI_ERROR_UNKNOWN; | ||
|
||
return PI_SUCCESS; | ||
} | ||
|
||
pi_result redefinedContextCreate(const pi_context_properties *Properties, | ||
pi_uint32 NumDevices, const pi_device *Devices, | ||
void (*PFnNotify)(const char *ErrInfo, | ||
const void *PrivateInfo, | ||
size_t CB, void *UserData), | ||
void *UserData, pi_context *RetContext) { | ||
return PI_SUCCESS; | ||
} | ||
} // anonymous namespace | ||
|
||
// Check that program is built once for all sub-devices | ||
// FIXME: mock 3 devices (one root device + two sub-devices) within a single | ||
// context. | ||
TEST(SubDevices, DISABLED_BuildProgramForSubdevices) { | ||
sycl::platform Plt{sycl::default_selector()}; | ||
// Host devices do not support sub-devices | ||
if (Plt.is_host() || Plt.get_backend() == sycl::backend::ext_oneapi_cuda || | ||
Plt.get_backend() == sycl::backend::ext_oneapi_hip) { | ||
std::cerr << "Test is not supported on " | ||
<< Plt.get_info<sycl::info::platform::name>() << ", skipping\n"; | ||
GTEST_SKIP(); // test is not supported on selected platform. | ||
} | ||
|
||
// Setup Mock APIs | ||
sycl::unittest::PiMock Mock{Plt}; | ||
setupDefaultMockAPIs(Mock); | ||
Mock.redefine<sycl::detail::PiApiKind::piDeviceGetInfo>( | ||
redefinedDeviceGetInfo); | ||
Mock.redefine<sycl::detail::PiApiKind::piDevicePartition>( | ||
redefinedDevicePartition); | ||
Mock.redefine<sycl::detail::PiApiKind::piDeviceRetain>(redefinedDeviceRetain); | ||
Mock.redefine<sycl::detail::PiApiKind::piDeviceRelease>( | ||
redefinedDeviceRelease); | ||
Mock.redefine<sycl::detail::PiApiKind::piProgramBuild>(redefinedProgramBuild); | ||
Mock.redefine<sycl::detail::PiApiKind::piContextCreate>( | ||
redefinedContextCreate); | ||
|
||
// Create 2 sub-devices and use first platform device as a root device | ||
const sycl::device device = Plt.get_devices()[0]; | ||
// Initialize root device | ||
rootDevice = sycl::detail::getSyclObjImpl(device)->getHandleRef(); | ||
// Initialize sub-devices | ||
auto PltImpl = sycl::detail::getSyclObjImpl(Plt); | ||
auto subDev1 = | ||
std::make_shared<sycl::detail::device_impl>(piSubDev1, PltImpl); | ||
auto subDev2 = | ||
std::make_shared<sycl::detail::device_impl>(piSubDev2, PltImpl); | ||
sycl::context Ctx{ | ||
{device, sycl::detail::createSyclObjFromImpl<sycl::device>(subDev1), | ||
sycl::detail::createSyclObjFromImpl<sycl::device>(subDev2)}}; | ||
|
||
// Create device binary description structures for getBuiltPIProgram API. | ||
auto devBin = Img.convertToNativeType(); | ||
pi_device_binaries_struct devBinStruct{PI_DEVICE_BINARIES_VERSION, 1, | ||
&devBin}; | ||
sycl::detail::ProgramManager::getInstance().addImages(&devBinStruct); | ||
|
||
// Build program via getBuiltPIProgram API | ||
sycl::detail::ProgramManager::getInstance().getBuiltPIProgram( | ||
sycl::detail::OSUtil::getOSModuleHandle(&devBin), | ||
sycl::detail::getSyclObjImpl(Ctx), subDev1, | ||
sycl::detail::KernelInfo<TestKernel>::getName()); | ||
// This call should re-use built binary from the cache. If piProgramBuild is | ||
// called again, the test will fail as second call of redefinedProgramBuild | ||
sycl::detail::ProgramManager::getInstance().getBuiltPIProgram( | ||
sycl::detail::OSUtil::getOSModuleHandle(&devBin), | ||
sycl::detail::getSyclObjImpl(Ctx), subDev2, | ||
sycl::detail::KernelInfo<TestKernel>::getName()); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.