Skip to content

Commit

Permalink
Minor fixes to device selection / kernel invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr committed Jan 5, 2024
1 parent 99f6de4 commit b74370d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/simsycl/sycl/device.hh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class device final : public detail::reference_type<device, detail::device_state>


template<aspect Aspect>
struct any_device_has : std::false_type {};
struct any_device_has : std::true_type {};

template<aspect Aspect>
struct all_devices_have : std::false_type {};
Expand Down
30 changes: 24 additions & 6 deletions include/simsycl/sycl/handler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ class handler {
//----- Backend interoperability interface

template<typename T>
void set_arg(int arg_index, T &&arg);
void set_arg(int arg_index, T &&arg) {
(void)arg_index;
(void)arg;
SIMSYCL_CHECK(!"SimSYCL does not have built-in or backend interop kernels, calling set_arg is undefined");
}

template<typename... Ts>
void set_args(Ts &&...args);
void set_args(Ts &&...args) {
((void)args, ...);
SIMSYCL_CHECK(!"SimSYCL does not have built-in or backend interop kernels, calling set_args is undefined");
}

//------ Host tasks

Expand All @@ -65,7 +72,7 @@ class handler {

template<typename KernelName = simsycl::detail::unnamed_kernel, typename KernelType>
void single_task(const KernelType &kernel_func) {
kernel_func();
detail::execute_single_task<KernelName>(kernel_func);
}

template<typename KernelName = simsycl::detail::unnamed_kernel, typename... Rest>
Expand Down Expand Up @@ -104,13 +111,24 @@ class handler {
m_device, num_work_groups, {work_group_size}, m_local_memory, kernel_func);
}

void single_task(const kernel &kernel_object);
void single_task(const kernel &kernel_object) {
(void)kernel_object;
throw sycl::exception(sycl::errc::invalid, "SYCL does not allow invoking user kernels via kernel object APIs");
}

template<int Dimensions>
void parallel_for(range<Dimensions> num_work_items, const kernel &kernel_object);
void parallel_for(range<Dimensions> num_work_items, const kernel &kernel_object) {
(void)num_work_items;
(void)kernel_object;
throw sycl::exception(sycl::errc::invalid, "SYCL does not allow invoking user kernels via kernel object APIs");
}

template<int Dimensions>
void parallel_for(nd_range<Dimensions> nd_range, const kernel &kernel_object);
void parallel_for(nd_range<Dimensions> nd_range, const kernel &kernel_object) {
(void)nd_range;
(void)kernel_object;
throw sycl::exception(sycl::errc::invalid, "SYCL does not allow invoking user kernels via kernel object APIs");
}

//------ USM functions

Expand Down
2 changes: 2 additions & 0 deletions src/simsycl/device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ SIMSYCL_DETAIL_DEPRECATED_IN_SYCL bool device::has_extension(const std::string &

std::vector<device> device::get_devices(info::device_type type) {
auto &devices = detail::get_devices();
if (type == info::device_type::all) return devices;

std::vector<device> result;
std::copy_if(devices.begin(), devices.end(), std::back_inserter(result),
[type](const device &dev) { return dev.get_info<info::device::device_type>() == type; });
Expand Down

0 comments on commit b74370d

Please sign in to comment.