Skip to content

Commit c7f7674

Browse files
[SYCL] Allow using interop program constructor with multi-device context (#3160)
Since programs created with the interoperability constructor have to be already compiled or linked, they don't run into the same limitations as those created internally by the runtime. In addition, enforce this state requirement by throwing an invalid_object_error if the native program is neither compiled nor linked as required by SYCL 1.2.1 specification.
1 parent c042f9e commit c7f7674

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

sycl/source/detail/program_impl.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,6 @@ program_impl::program_impl(ContextImplPtr Context,
123123
pi_native_handle InteropProgram,
124124
RT::PiProgram Program)
125125
: MProgram(Program), MContext(Context), MLinkable(true) {
126-
127-
if (Context->getDevices().size() > 1) {
128-
throw feature_not_supported(
129-
"multiple devices within a context are not supported with "
130-
"sycl::program and sycl::kernel",
131-
PI_INVALID_OPERATION);
132-
}
133-
134126
const detail::plugin &Plugin = getPlugin();
135127
if (MProgram == nullptr) {
136128
assert(InteropProgram &&
@@ -172,6 +164,12 @@ program_impl::program_impl(ContextImplPtr Context,
172164
Plugin.call<PiApiKind::piProgramGetBuildInfo>(
173165
MProgram, Device, CL_PROGRAM_BINARY_TYPE, sizeof(cl_program_binary_type),
174166
&BinaryType, nullptr);
167+
if (BinaryType == CL_PROGRAM_BINARY_TYPE_NONE) {
168+
throw invalid_object_error(
169+
"The native program passed to the program constructor has to be either "
170+
"compiled or linked",
171+
PI_INVALID_PROGRAM);
172+
}
175173
size_t Size = 0;
176174
Plugin.call<PiApiKind::piProgramGetBuildInfo>(
177175
MProgram, Device, CL_PROGRAM_BUILD_OPTIONS, 0, nullptr, &Size);
@@ -182,7 +180,7 @@ program_impl::program_impl(ContextImplPtr Context,
182180
string_class Options(OptionsVector.begin(), OptionsVector.end());
183181
switch (BinaryType) {
184182
case CL_PROGRAM_BINARY_TYPE_NONE:
185-
MState = program_state::none;
183+
assert(false);
186184
break;
187185
case CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT:
188186
MState = program_state::compiled;

0 commit comments

Comments
 (0)