Skip to content

Commit 2a42cf8

Browse files
Change back to pass error message in exception(codeToError)
1 parent b40bd29 commit 2a42cf8

File tree

4 files changed

+71
-40
lines changed

4 files changed

+71
-40
lines changed

sycl/source/backend.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ static const PluginPtr &getPlugin(backend Backend) {
3939
return pi::getPlugin<backend::ext_oneapi_cuda>();
4040
default:
4141
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
42-
"getPlugin: Unsupported backend");
42+
"getPlugin: Unsupported backend " +
43+
detail::codeToString(PI_ERROR_INVALID_OPERATION));
4344
}
4445
}
4546

@@ -197,7 +198,8 @@ make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext,
197198
case (PI_PROGRAM_BINARY_TYPE_LIBRARY):
198199
if (State == bundle_state::input)
199200
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
200-
"Program and kernel_bundle state mismatch");
201+
"Program and kernel_bundle state mismatch " +
202+
PI_ERROR_INVALID_VALUE);
201203
if (State == bundle_state::executable)
202204
Plugin->call<errc::build, PiApiKind::piProgramLink>(
203205
ContextImpl->getHandleRef(), 1, &Dev, nullptr, 1, &PiProgram,
@@ -206,7 +208,8 @@ make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext,
206208
case (PI_PROGRAM_BINARY_TYPE_EXECUTABLE):
207209
if (State == bundle_state::input || State == bundle_state::object)
208210
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
209-
"Program and kernel_bundle state mismatch");
211+
"Program and kernel_bundle state mismatch " +
212+
detail::codeToString(PI_ERROR_INVALID_VALUE));
210213
break;
211214
}
212215
}
@@ -262,7 +265,8 @@ kernel make_kernel(const context &TargetContext,
262265
if (KernelBundleImpl->size() != 1)
263266
throw sycl::exception(
264267
sycl::make_error_code(sycl::errc::runtime),
265-
"make_kernel: kernel_bundle must have single program image");
268+
"make_kernel: kernel_bundle must have single program image " +
269+
detail::codeToString(PI_ERROR_INVALID_PROGRAM));
266270

267271
const device_image<bundle_state::executable> &DeviceImage =
268272
*KernelBundle.begin();

sycl/source/detail/allowlist.cpp

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
7676
"SYCL_DEVICE_ALLOWLIST has incorrect format. For "
7777
"details, please refer to "
7878
"https://github.com/intel/llvm/blob/sycl/sycl/"
79-
"doc/EnvironmentVariables.md");
79+
"doc/EnvironmentVariables.md " +
80+
codeToString(PI_ERROR_INVALID_VALUE));
8081

8182
const std::string &DeprecatedKeyNameDeviceName = DeviceNameKeyName;
8283
const std::string &DeprecatedKeyNamePlatformName = PlatformNameKeyName;
@@ -100,7 +101,8 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
100101
"Unrecognized key in SYCL_DEVICE_ALLOWLIST. For details, please "
101102
"refer to "
102103
"https://github.com/intel/llvm/blob/sycl/sycl/doc/"
103-
"EnvironmentVariables.md");
104+
"EnvironmentVariables.md " +
105+
codeToString(PI_ERROR_INVALID_VALUE));
104106
}
105107

106108
if (Key == DeprecatedKeyNameDeviceName) {
@@ -155,7 +157,8 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
155157
" is not valid in "
156158
"SYCL_DEVICE_ALLOWLIST. For details, please refer to "
157159
"https://github.com/intel/llvm/blob/sycl/sycl/doc/"
158-
"EnvironmentVariables.md");
160+
"EnvironmentVariables.md " +
161+
codeToString(PI_ERROR_INVALID_VALUE));
159162
}
160163
};
161164

@@ -175,7 +178,8 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
175178
"SYCL_DEVICE_ALLOWLIST. It should have the hex format. For "
176179
"details, please refer to "
177180
"https://github.com/intel/llvm/blob/sycl/sycl/doc/"
178-
"EnvironmentVariables.md");
181+
"EnvironmentVariables.md " +
182+
codeToString(PI_ERROR_INVALID_VALUE));
179183
}
180184
}
181185
}
@@ -187,11 +191,12 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
187191
// TODO: can be changed to string_view::starts_with after switching
188192
// DPC++ RT to C++20
189193
if (Prefix != AllowListRaw.substr(ValueStart, Prefix.length())) {
190-
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
191-
"Key " + Key +
192-
" of SYCL_DEVICE_ALLOWLIST should have "
193-
"value which starts with " +
194-
Prefix);
194+
throw sycl::exception(
195+
sycl::errc::runtime,
196+
"Key " + Key +
197+
" of SYCL_DEVICE_ALLOWLIST should have "
198+
"value which starts with " +
199+
Prefix + " " + detail::codeToString(PI_ERROR_INVALID_VALUE));
195200
}
196201
// cut off prefix from the value
197202
ValueStart += Prefix.length();
@@ -205,11 +210,13 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
205210
// if it is the last iteration and next 2 symbols are not a postfix,
206211
// throw exception
207212
if (ValueEnd == AllowListRaw.length() - Postfix.length())
208-
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
209-
"Key " + Key +
210-
" of SYCL_DEVICE_ALLOWLIST should have "
211-
"value which ends with " +
212-
Postfix);
213+
throw sycl::exception(
214+
sycl::make_error_code(sycl::errc::runtime),
215+
"Key " + Key +
216+
" of SYCL_DEVICE_ALLOWLIST should have "
217+
"value which ends with " +
218+
Postfix + " " +
219+
detail::codeToString(PI_ERROR_INVALID_VALUE));
213220
}
214221
size_t NextExpectedDelimiterPos = ValueEnd + Postfix.length();
215222
// if it is not the end of the string, check that symbol next to a
@@ -224,7 +231,8 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
224231
std::to_string(NextExpectedDelimiterPos) + ": " +
225232
AllowListRaw[NextExpectedDelimiterPos] +
226233
". Should be either " + DelimiterBtwItemsInDeviceDesc +
227-
" or " + DelimiterBtwDeviceDescs);
234+
" or " + DelimiterBtwDeviceDescs +
235+
codeToString(PI_ERROR_INVALID_VALUE));
228236

229237
if (AllowListRaw[NextExpectedDelimiterPos] == DelimiterBtwDeviceDescs)
230238
ShouldAllocateNewDeviceDescMap = true;
@@ -240,9 +248,11 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) {
240248
// add key and value to the map
241249
DeviceDescMap.emplace(Key, Value);
242250
} else
243-
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime), "Re-definition of key " + Key +
244-
" is not allowed in "
245-
"SYCL_DEVICE_ALLOWLIST");
251+
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
252+
"Re-definition of key " + Key +
253+
" is not allowed in "
254+
"SYCL_DEVICE_ALLOWLIST " +
255+
codeToString(PI_ERROR_INVALID_VALUE));
246256

247257
KeyStart = ValueEnd;
248258
if (KeyStart != std::string::npos)

sycl/source/detail/event_impl.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext)
129129
if (MContext->is_host()) {
130130
throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
131131
"The syclContext must match the OpenCL context "
132-
"associated with the clEvent.");
132+
"associated with the clEvent. " +
133+
codeToString(PI_ERROR_INVALID_CONTEXT));
133134
}
134135

135136
RT::PiContext TempContext;
@@ -139,13 +140,14 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext)
139140
if (MContext->getHandleRef() != TempContext) {
140141
throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
141142
"The syclContext must match the OpenCL context "
142-
"associated with the clEvent.");
143+
"associated with the clEvent. " +
144+
codeToString(PI_ERROR_INVALID_CONTEXT));
143145
}
144146
}
145147

146148
event_impl::event_impl(const QueueImplPtr &Queue)
147-
: MQueue{Queue}, MIsProfilingEnabled{Queue->is_host() ||
148-
Queue->MIsProfilingEnabled},
149+
: MQueue{Queue},
150+
MIsProfilingEnabled{Queue->is_host() || Queue->MIsProfilingEnabled},
149151
MLimitedProfiling{MIsProfilingEnabled && Queue->isProfilingLimited()} {
150152
this->setContextImpl(Queue->getContextImplPtr());
151153

@@ -155,7 +157,9 @@ event_impl::event_impl(const QueueImplPtr &Queue)
155157
if (Queue->has_property<property::queue::enable_profiling>()) {
156158
MHostProfilingInfo.reset(new HostProfilingInfo());
157159
if (!MHostProfilingInfo)
158-
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime), "Out of host memory");
160+
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
161+
"Out of host memory " +
162+
codeToString(PI_ERROR_OUT_OF_HOST_MEMORY));
159163
}
160164
return;
161165
}
@@ -285,8 +289,10 @@ event_impl::get_profiling_info<info::event_profiling::command_start>() {
285289
return 0;
286290
}
287291
if (!MHostProfilingInfo)
288-
throw sycl::exception(0, sycl::errc::invalid,
289-
"Profiling info is not available.");
292+
throw sycl::exception(
293+
sycl::make_error_code(sycl::errc::invalid),
294+
"Profiling info is not available. " +
295+
codeToString(PI_ERROR_PROFILING_INFO_NOT_AVAILABLE));
290296
return MHostProfilingInfo->getStartTime();
291297
}
292298

@@ -300,8 +306,10 @@ uint64_t event_impl::get_profiling_info<info::event_profiling::command_end>() {
300306
return 0;
301307
}
302308
if (!MHostProfilingInfo)
303-
throw sycl::exception(sycl::make_error_code(sycl::errc::invalid),
304-
"Profiling info is not available.");
309+
throw sycl::exception(
310+
sycl::make_error_code(sycl::errc::invalid),
311+
"Profiling info is not available. " +
312+
codeToString(PI_ERROR_PROFILING_INFO_NOT_AVAILABLE));
305313
return MHostProfilingInfo->getEndTime();
306314
}
307315

sycl/source/detail/scheduler/commands.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,8 @@ AllocaCommandBase *ExecCGCommand::getAllocaForReq(Requirement *Req) {
15271527
return Dep.MAllocaCmd;
15281528
}
15291529
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
1530-
"Alloca for command not found");
1530+
"Alloca for command not found " +
1531+
codeToString(PI_ERROR_INVALID_OPERATION));
15311532
}
15321533

15331534
std::vector<std::shared_ptr<const void>>
@@ -2233,7 +2234,8 @@ static pi_result SetKernelParamsAndLaunch(
22332234
throw sycl::exception(
22342235
sycl::make_error_code(sycl::errc::feature_not_supported),
22352236
"SYCL2020 specialization constants are not yet supported on host "
2236-
"device");
2237+
"device " +
2238+
codeToString(PI_ERROR_INVALID_OPERATION));
22372239
}
22382240
assert(DeviceImageImpl != nullptr);
22392241
RT::PiMem SpecConstsBuffer = DeviceImageImpl->get_spec_const_buffer_ref();
@@ -2246,7 +2248,8 @@ static pi_result SetKernelParamsAndLaunch(
22462248
}
22472249
case kernel_param_kind_t::kind_invalid:
22482250
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
2249-
"Invalid kernel param kind");
2251+
"Invalid kernel param kind " +
2252+
codeToString(PI_ERROR_INVALID_VALUE));
22502253
break;
22512254
}
22522255
};
@@ -2494,7 +2497,8 @@ pi_int32 ExecCGCommand::enqueueImp() {
24942497

24952498
case CG::CGTYPE::UpdateHost: {
24962499
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
2497-
"Update host should be handled by the Scheduler.");
2500+
"Update host should be handled by the Scheduler. " +
2501+
codeToString(PI_ERROR_INVALID_VALUE));
24982502
}
24992503
case CG::CGTYPE::CopyAccToPtr: {
25002504
CGCopy *Copy = (CGCopy *)MCommandGroup.get();
@@ -2633,12 +2637,14 @@ pi_int32 ExecCGCommand::enqueueImp() {
26332637
switch (Error) {
26342638
case PI_ERROR_INVALID_OPERATION:
26352639
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
2636-
"Device doesn't support run_on_host_intel tasks.");
2640+
"Device doesn't support run_on_host_intel tasks. " +
2641+
Error);
26372642
case PI_SUCCESS:
26382643
return Error;
26392644
default:
26402645
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
2641-
"Enqueueing run_on_host_intel task has failed.");
2646+
"Enqueueing run_on_host_intel task has failed. " +
2647+
Error);
26422648
}
26432649
}
26442650
case CG::CGTYPE::Kernel: {
@@ -2797,7 +2803,8 @@ pi_int32 ExecCGCommand::enqueueImp() {
27972803
}
27982804
default:
27992805
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
2800-
"Unsupported arg type");
2806+
"Unsupported arg type " +
2807+
codeToString(PI_ERROR_INVALID_VALUE));
28012808
}
28022809
}
28032810

@@ -2827,7 +2834,8 @@ pi_int32 ExecCGCommand::enqueueImp() {
28272834

28282835
throw sycl::exception(
28292836
sycl::make_error_code(sycl::errc::runtime),
2830-
"Can't get memory object due to no allocation available");
2837+
"Can't get memory object due to no allocation available " +
2838+
codeToString(PI_ERROR_INVALID_MEM_OBJECT));
28312839
};
28322840
std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv);
28332841
std::sort(std::begin(ReqToMem), std::end(ReqToMem));
@@ -2906,7 +2914,8 @@ pi_int32 ExecCGCommand::enqueueImp() {
29062914
}
29072915
case CG::CGTYPE::None:
29082916
throw sycl::exception(sycl::make_error_code(sycl::errc::runtime),
2909-
"CG type not implemented.");
2917+
"CG type not implemented. " +
2918+
codeToString(PI_ERROR_INVALID_OPERATION));
29102919
}
29112920
return PI_ERROR_INVALID_OPERATION;
29122921
}

0 commit comments

Comments
 (0)