Skip to content

Commit ba77e3a

Browse files
authored
[SYCL] Report an error for using "sycl::program::create_program_with_source" with Level-Zero/CUDA (#3212)
Level-Zero and CUDA backends do not support create_program_with_source. This is to report an error message from SYCL RT if that is requested. Signed-off-by: rbegam <[email protected]>
1 parent 46e3c64 commit ba77e3a

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ namespace pi {
289289
std::terminate();
290290
}
291291

292+
// Reports error messages
293+
void cuPrint(const char *Message) {
294+
std::cerr << "pi_print: " << Message << std::endl;
295+
}
296+
292297
void assertion(bool Condition, const char *Message) {
293298
if (!Condition)
294299
die(Message);
@@ -2649,8 +2654,9 @@ pi_result cuda_piclProgramCreateWithSource(pi_context context, pi_uint32 count,
26492654
const char **strings,
26502655
const size_t *lengths,
26512656
pi_program *program) {
2652-
cl::sycl::detail::pi::die("cuda_piclProgramCreateWithSource not implemented");
2653-
return {};
2657+
cl::sycl::detail::pi::cuPrint(
2658+
"cuda_piclProgramCreateWithSource not implemented");
2659+
return PI_INVALID_OPERATION;
26542660
}
26552661

26562662
/// Loads the images from a PI program into a CUmodule that can be

sycl/source/detail/program_impl.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,15 @@ void program_impl::create_cl_program_with_source(const string_class &Source) {
358358
const char *Src = Source.c_str();
359359
size_t Size = Source.size();
360360
const detail::plugin &Plugin = getPlugin();
361-
Plugin.call<PiApiKind::piclProgramCreateWithSource>(
362-
MContext->getHandleRef(), 1, &Src, &Size, &MProgram);
361+
RT::PiResult Err =
362+
Plugin.call_nocheck<PiApiKind::piclProgramCreateWithSource>(
363+
MContext->getHandleRef(), 1, &Src, &Size, &MProgram);
364+
365+
if (Err == PI_INVALID_OPERATION) {
366+
throw feature_not_supported(
367+
"program::compile_with_source is not supported by the selected backend",
368+
PI_INVALID_OPERATION);
369+
}
363370
}
364371

365372
void program_impl::compile(const string_class &Options) {

0 commit comments

Comments
 (0)