Skip to content

Commit 1be7568

Browse files
committed
Fail a bit earlier and more consistently
Signed-off-by: Julian Oppermann <[email protected]>
1 parent 62d223b commit 1be7568

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

sycl/source/detail/kernel_bundle_impl.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,8 @@ class kernel_bundle_impl {
761761
}
762762

763763
DeviceGlobalMapEntry *get_device_global_entry(const std::string &Name) {
764-
if (MLanguage != syclex::source_language::sycl_jit || MPrefix.empty()) {
764+
if (MKernelNames.empty() ||
765+
MLanguage != syclex::source_language::sycl_jit) {
765766
throw sycl::exception(make_error_code(errc::invalid),
766767
"Querying device globals by name is only available "
767768
"in kernel_bundles successfully built from "
@@ -806,7 +807,7 @@ class kernel_bundle_impl {
806807

807808
public:
808809
bool ext_oneapi_has_kernel(const std::string &Name) {
809-
return is_kernel_name(adjust_kernel_name(Name));
810+
return !MKernelNames.empty() && is_kernel_name(adjust_kernel_name(Name));
810811
}
811812

812813
kernel
@@ -880,19 +881,21 @@ class kernel_bundle_impl {
880881
}
881882

882883
bool ext_oneapi_has_device_global(const std::string &Name) {
883-
std::string MangledName = mangle_device_global_name(Name);
884-
return std::find(MDeviceGlobalNames.begin(), MDeviceGlobalNames.end(),
885-
MangledName) != MDeviceGlobalNames.end();
884+
return !MDeviceGlobalNames.empty() &&
885+
std::find(MDeviceGlobalNames.begin(), MDeviceGlobalNames.end(),
886+
mangle_device_global_name(Name)) !=
887+
MDeviceGlobalNames.end();
886888
}
887889

888890
void *ext_oneapi_get_device_global_address(const std::string &Name,
889891
const device &Dev) {
892+
DeviceGlobalMapEntry *Entry = get_device_global_entry(Name);
893+
890894
if (std::find(MDevices.begin(), MDevices.end(), Dev) == MDevices.end()) {
891895
throw sycl::exception(make_error_code(errc::invalid),
892896
"kernel_bundle not built for device");
893897
}
894898

895-
DeviceGlobalMapEntry *Entry = get_device_global_entry(Name);
896899
if (Entry->MIsDeviceImageScopeDecorated) {
897900
throw sycl::exception(make_error_code(errc::invalid),
898901
"Cannot query USM pointer for device global with "

0 commit comments

Comments
 (0)