@@ -28,7 +28,14 @@ program_impl::program_impl(ContextImplPtr Context)
28
28
29
29
program_impl::program_impl (ContextImplPtr Context,
30
30
vector_class<device> DeviceList)
31
- : MContext(Context), MDevices(DeviceList) {}
31
+ : MContext(Context), MDevices(DeviceList) {
32
+ if (Context->getDevices ().size () > 1 ) {
33
+ throw feature_not_supported (
34
+ " multiple devices within a context are not supported with "
35
+ " sycl::program and sycl::kernel" ,
36
+ PI_INVALID_OPERATION);
37
+ }
38
+ }
32
39
33
40
program_impl::program_impl (
34
41
vector_class<shared_ptr_class<program_impl>> ProgramList,
@@ -51,6 +58,12 @@ program_impl::program_impl(
51
58
}
52
59
53
60
MContext = ProgramList[0 ]->MContext ;
61
+ if (MContext->getDevices ().size () > 1 ) {
62
+ throw feature_not_supported (
63
+ " multiple devices within a context are not supported with "
64
+ " sycl::program and sycl::kernel" ,
65
+ PI_INVALID_OPERATION);
66
+ }
54
67
MDevices = ProgramList[0 ]->MDevices ;
55
68
vector_class<device> DevicesSorted;
56
69
if (!is_host ()) {
@@ -105,6 +118,13 @@ program_impl::program_impl(ContextImplPtr Context,
105
118
RT::PiProgram Program)
106
119
: MProgram(Program), MContext(Context), MLinkable(true ) {
107
120
121
+ if (Context->getDevices ().size () > 1 ) {
122
+ throw feature_not_supported (
123
+ " multiple devices within a context are not supported with "
124
+ " sycl::program and sycl::kernel" ,
125
+ PI_INVALID_OPERATION);
126
+ }
127
+
108
128
const detail::plugin &Plugin = getPlugin ();
109
129
if (MProgram == nullptr ) {
110
130
assert (InteropProgram &&
@@ -233,7 +253,7 @@ void program_impl::build_with_kernel_name(string_class KernelName,
233
253
if (is_cacheable_with_options (BuildOptions)) {
234
254
MProgramAndKernelCachingAllowed = true ;
235
255
MProgram = ProgramManager::getInstance ().getBuiltPIProgram (
236
- Module, get_context (), KernelName, this ,
256
+ Module, get_context (), get_devices ()[ 0 ], KernelName, this ,
237
257
/* JITCompilationIsRequired=*/ (!BuildOptions.empty ()));
238
258
const detail::plugin &Plugin = getPlugin ();
239
259
Plugin.call <PiApiKind::piProgramRetain>(MProgram);
@@ -356,7 +376,7 @@ void program_impl::build(const string_class &Options) {
356
376
check_device_feature_support<info::device::is_compiler_available>(MDevices);
357
377
vector_class<RT::PiDevice> Devices (get_pi_devices ());
358
378
const detail::plugin &Plugin = getPlugin ();
359
- ProgramManager::getInstance ().flushSpecConstants (*this );
379
+ ProgramManager::getInstance ().flushSpecConstants (*this , get_pi_devices ()[ 0 ] );
360
380
RT::PiResult Err = Plugin.call_nocheck <PiApiKind::piProgramBuild>(
361
381
MProgram, Devices.size (), Devices.data (), Options.c_str (), nullptr ,
362
382
nullptr );
@@ -404,7 +424,8 @@ RT::PiKernel program_impl::get_pi_kernel(const string_class &KernelName) const {
404
424
if (is_cacheable ()) {
405
425
std::tie (Kernel, std::ignore) =
406
426
ProgramManager::getInstance ().getOrCreateKernel (
407
- MProgramModuleHandle, get_context (), KernelName, this );
427
+ MProgramModuleHandle, get_context (), get_devices ()[0 ], KernelName,
428
+ this );
408
429
getPlugin ().call <PiApiKind::piKernelRetain>(Kernel);
409
430
} else {
410
431
const detail::plugin &Plugin = getPlugin ();
@@ -453,9 +474,10 @@ void program_impl::create_pi_program_with_kernel_name(
453
474
bool JITCompilationIsRequired) {
454
475
assert (!MProgram && " This program already has an encapsulated PI program" );
455
476
ProgramManager &PM = ProgramManager::getInstance ();
477
+ const device FirstDevice = get_devices ()[0 ];
456
478
RTDeviceBinaryImage &Img = PM.getDeviceImage (
457
- Module, KernelName, get_context (), JITCompilationIsRequired);
458
- MProgram = PM.createPIProgram (Img, get_context ());
479
+ Module, KernelName, get_context (), FirstDevice, JITCompilationIsRequired);
480
+ MProgram = PM.createPIProgram (Img, get_context (), FirstDevice );
459
481
}
460
482
461
483
template <>
0 commit comments