Skip to content

Commit 012c793

Browse files
committed
Minor fixes
1 parent 2f11815 commit 012c793

File tree

3 files changed

+47
-29
lines changed

3 files changed

+47
-29
lines changed

sycl/include/sycl/detail/kernel_launch_helper.hpp

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,18 @@ struct KernelWrapper<
256256
}
257257
}; // KernelWrapper struct
258258

259-
// This struct is inherited by sycl::handler.
259+
// This class encapsulates everything related to parsing kernel launch
260+
// properties.
260261
class KernelLaunchPropertyWrapper {
261262
public:
262263
// This struct is used to store kernel launch properties.
263264
// std::optional is used to indicate that the property is not set.
264265
// In some code paths, kernel launch properties are set multiple times
265266
// for the same kernel, that is why using std::optional to avoid overriding
266267
// previously set properties.
268+
// This struct is used to pass kernel launch properties across the ABI
269+
// boundary.
267270
struct KernelLaunchPropertiesT {
268-
269271
struct ScopeForwardProgressProperty {
270272
std::optional<sycl::ext::oneapi::experimental::forward_progress_guarantee>
271273
Guarantee;
@@ -282,28 +284,11 @@ class KernelLaunchPropertyWrapper {
282284
std::array<size_t, 3> MClusterSize = {0, 0, 0};
283285

284286
// Forward progress guarantee properties for work_item, sub_group and
285-
// work_group scopes.
286-
// Indexed by ExecutionScope enum.
287+
// work_group scopes. We need to store them for validation later.
287288
std::array<ScopeForwardProgressProperty, 3> MForwardProgressProperties;
288-
289-
KernelLaunchPropertiesT() = default;
290-
291-
// TODO: Do you even need this?
292-
KernelLaunchPropertiesT(
293-
ur_kernel_cache_config_t _CacheConfig, bool _IsCooperative,
294-
uint32_t _WorkGroupMemorySize, bool _UsesClusterLaunch,
295-
size_t _ClusterDims, std::array<size_t, 3> _ClusterSize,
296-
std::array<ScopeForwardProgressProperty, 3> _ForwardProgressProperties)
297-
: MCacheConfig(_CacheConfig), MIsCooperative(_IsCooperative),
298-
MWorkGroupMemorySize(_WorkGroupMemorySize),
299-
MUsesClusterLaunch(_UsesClusterLaunch), MClusterDims(_ClusterDims),
300-
MClusterSize(_ClusterSize),
301-
MForwardProgressProperties(_ForwardProgressProperties) {}
302-
}; // struct KernelLaunchPropertiesT
289+
};
303290

304291
/// Process runtime kernel properties.
305-
///
306-
/// Stores information about kernel properties into the handler.
307292
template <typename PropertiesT>
308293
static KernelLaunchPropertiesT
309294
processKernelLaunchProperties(PropertiesT Props) {
@@ -423,9 +408,6 @@ class KernelLaunchPropertyWrapper {
423408
}
424409

425410
/// Process kernel properties.
426-
///
427-
/// Stores information about kernel properties into the handler.
428-
///
429411
/// Note: it is important that this function *does not* depend on kernel
430412
/// name or kernel type, because then it will be instantiated for every
431413
/// kernel, even though body of those instantiated functions could be almost

sycl/source/detail/kernel_data.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99
#pragma once
1010

11+
#include <detail/device_impl.hpp>
1112
#include <detail/device_kernel_info.hpp>
1213
#include <detail/graph/dynamic_impl.hpp>
1314
#include <detail/kernel_arg_desc.hpp>
1415
#include <detail/ndrange_desc.hpp>
1516

16-
#include <detail/device_impl.hpp>
17-
1817
#include <sycl/detail/kernel_desc.hpp>
1918
#include <sycl/detail/kernel_launch_helper.hpp>
2019

sycl/source/handler.cpp

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,9 +1758,46 @@ void handler::verifyDeviceHasProgressGuarantee(
17581758
sycl::ext::oneapi::experimental::execution_scope threadScope,
17591759
sycl::ext::oneapi::experimental::execution_scope coordinationScope) {
17601760

1761-
// FIXME!
1762-
detail::KernelLaunchPropertyWrapper::KernelLaunchPropertiesT Kprop;
1763-
setKernelLaunchProperties(Kprop);
1761+
using execution_scope = sycl::ext::oneapi::experimental::execution_scope;
1762+
using forward_progress =
1763+
sycl::ext::oneapi::experimental::forward_progress_guarantee;
1764+
const bool supported = impl->get_device().supportsForwardProgress(
1765+
guarantee, threadScope, coordinationScope);
1766+
if (threadScope == execution_scope::work_group) {
1767+
if (!supported) {
1768+
throw sycl::exception(
1769+
sycl::errc::feature_not_supported,
1770+
"Required progress guarantee for work groups is not "
1771+
"supported by this device.");
1772+
}
1773+
// If we are here, the device supports the guarantee required but there is a
1774+
// caveat in that if the guarantee required is a concurrent guarantee, then
1775+
// we most likely also need to enable cooperative launch of the kernel. That
1776+
// is, although the device supports the required guarantee, some setup work
1777+
// is needed to truly make the device provide that guarantee at runtime.
1778+
// Otherwise, we will get the default guarantee which is weaker than
1779+
// concurrent. Same reasoning applies for sub_group but not for work_item.
1780+
// TODO: Further design work is probably needed to reflect this behavior in
1781+
// Unified Runtime.
1782+
if (guarantee == forward_progress::concurrent)
1783+
setKernelIsCooperative(true);
1784+
} else if (threadScope == execution_scope::sub_group) {
1785+
if (!supported) {
1786+
throw sycl::exception(sycl::errc::feature_not_supported,
1787+
"Required progress guarantee for sub groups is not "
1788+
"supported by this device.");
1789+
}
1790+
// Same reasoning as above.
1791+
if (guarantee == forward_progress::concurrent)
1792+
setKernelIsCooperative(true);
1793+
} else { // threadScope is execution_scope::work_item otherwise undefined
1794+
// behavior
1795+
if (!supported) {
1796+
throw sycl::exception(sycl::errc::feature_not_supported,
1797+
"Required progress guarantee for work items is not "
1798+
"supported by this device.");
1799+
}
1800+
}
17641801
}
17651802
#endif
17661803

0 commit comments

Comments
 (0)