Skip to content

[SYCL] Implement forward_progress extension API #13389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 61 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
2cfefb2
Implement forward_progress extension API
lbushi25 Apr 12, 2024
b399539
Fix formatting and warnings
lbushi25 Apr 12, 2024
722b12b
Fix formatting and warnings
lbushi25 Apr 12, 2024
5e8df26
Fix formatting and warnings
lbushi25 Apr 12, 2024
17e6ac2
Fix formatting and warnings
lbushi25 Apr 12, 2024
2152a4e
Formatting
lbushi25 Apr 13, 2024
13d0ff9
Merge branch 'intel:sycl' into ext_forward_progress
lbushi25 Apr 13, 2024
096641b
Merge branch 'intel:sycl' into ext_forward_progress
lbushi25 Apr 15, 2024
cdaf0e6
Formatting
lbushi25 Apr 13, 2024
005a43c
Add new symbols to symbol dump
lbushi25 Apr 15, 2024
d97dccd
Add symbols
lbushi25 Apr 15, 2024
f49ed0d
Add symbols to symbol dump
lbushi25 Apr 15, 2024
a2337bf
Merge branch 'intel:sycl' into ext_forward_progress
lbushi25 Apr 15, 2024
bca9f23
Fix namespace declaration issue
lbushi25 Apr 15, 2024
f125075
Fix namespace issues
lbushi25 Apr 15, 2024
ab760d8
Run clang-format
lbushi25 Apr 15, 2024
8cd12e9
Refactor repeated code
lbushi25 Apr 15, 2024
eb84eda
Refactor repeated code
lbushi25 Apr 15, 2024
7ac944f
Format device_info.hpp
lbushi25 Apr 15, 2024
7736042
Add windows symbols and format
lbushi25 Apr 16, 2024
5d70a62
Formatting
lbushi25 Apr 16, 2024
9063aa7
Refactor tests for readability
lbushi25 Apr 16, 2024
9cbbe8a
Partially implement sycl_ext_oneapi_launch_queries
lbushi25 Apr 16, 2024
00c1f9e
Implement launch queries for forward progress guarantees
lbushi25 Apr 17, 2024
129d28e
Delete sycl/include/sycl/ext/oneapi/kernel_launch_queries.hpp
lbushi25 Apr 17, 2024
5272f6b
Update pi.h
lbushi25 Apr 17, 2024
fce0519
Update kernel.hpp
lbushi25 Apr 17, 2024
6fdae4e
Update kernel.hpp
lbushi25 Apr 17, 2024
22adb8a
Delete sycl/test/kernel_param/forward_progress.cpp
lbushi25 Apr 19, 2024
86af6b3
Refactor device_impl.hpp and device_info.hpp
lbushi25 Apr 19, 2024
cf11c6b
Merge branch 'intel:sycl' into ext_forward_progress
lbushi25 Apr 19, 2024
689db34
Refactor handler.hpp and add tests
lbushi25 Apr 19, 2024
2c90bed
Update handler.hpp
lbushi25 Apr 19, 2024
f50e3de
Update handler.hpp
lbushi25 Apr 19, 2024
a01298e
Merge branch 'sycl' into ext_forward_progress
lbushi25 Apr 19, 2024
505e011
Update device_impl.cpp
lbushi25 Apr 19, 2024
791e872
Update device_impl.cpp
lbushi25 Apr 19, 2024
ff62ae8
Update handler.hpp
lbushi25 Apr 19, 2024
f91f888
Update handler.hpp
lbushi25 Apr 19, 2024
8e78fda
Update handler.hpp
lbushi25 Apr 20, 2024
b9c25a9
Add ABI symbols
lbushi25 Apr 22, 2024
04019d9
Remove static_assert in favor of runtime assert
lbushi25 Apr 22, 2024
264d766
Enable cooperative launch to provide concurrent guarantee
lbushi25 Apr 25, 2024
c62cca8
Resolve conflict
lbushi25 Apr 25, 2024
cddc56d
Fix failing precomit tests and modify ABI symbols
lbushi25 Apr 25, 2024
eaceb69
Fix missing include
lbushi25 Apr 26, 2024
f151c4f
Enable cooperative launch of kernel to provide concurrent forward pro…
lbushi25 Apr 30, 2024
a43ff24
Merge branch 'intel:sycl' into ext_forward_progress
lbushi25 May 2, 2024
711146e
Add comments for better explanation
lbushi25 May 3, 2024
ac28019
Format and change some naming to camelcase
lbushi25 May 3, 2024
c3dfbe5
Update device_info.hpp
lbushi25 May 3, 2024
f0d49a5
Align begin/closure lines
lbushi25 May 3, 2024
43a6d1f
Remove tests to E2E directory
lbushi25 May 6, 2024
ea3e2d2
Fix small type in forward_progress_kernel_parap_L0_gpu.cpp
lbushi25 May 6, 2024
934c5b4
Merge branch 'sycl' into ext_forward_progress
lbushi25 May 8, 2024
f783279
Remove forward_progress include from sycl.hpp
lbushi25 May 9, 2024
6feef0c
Simplify logic for verifying kernel properties in handler class
lbushi25 May 9, 2024
5705730
Include forward_progress.hpp in sycl.hpp to conform with the spec
lbushi25 May 9, 2024
7ede8c3
Run formatter on sycl.hpp
lbushi25 May 9, 2024
c07088a
Update sycl.hpp
lbushi25 May 10, 2024
9d88508
Update sycl.hpp
lbushi25 May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sycl/include/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,12 @@ typedef enum {
// The number of max registers per block (device specific)
PI_EXT_CODEPLAY_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP = 0x20009,
PI_EXT_INTEL_DEVICE_INFO_ESIMD_SUPPORT = 0x2000A,

PI_EXT_ONEAPI_DEVICE_INFO_WORK_GROUP_PROGRESS_AT_ROOT_GROUP_LEVEL = 0x2000B,
PI_EXT_ONEAPI_DEVICE_INFO_SUB_GROUP_PROGRESS_AT_ROOT_GROUP_LEVEL = 0x2000C,
PI_EXT_ONEAPI_DEVICE_INFO_SUB_GROUP_PROGRESS_AT_WORK_GROUP_LEVEL = 0x2000D,
PI_EXT_ONEAPI_DEVICE_INFO_WORK_ITEM_PROGRESS_AT_ROOT_GROUP_LEVEL = 0x2000E,
PI_EXT_ONEAPI_DEVICE_INFO_WORK_ITEM_PROGRESS_AT_WORK_GROUP_LEVEL = 0x2000F,
PI_EXT_ONEAPI_DEVICE_INFO_WORK_ITEM_PROGRESS_AT_SUB_GROUP_LEVEL = 0x20010,
// Bindless images, mipmaps, interop
PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT = 0x20100,
PI_EXT_ONEAPI_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT = 0x20101,
Expand Down
30 changes: 30 additions & 0 deletions sycl/include/sycl/ext/oneapi/experimental/forward_progress.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//==------- forward_progress.hpp - sycl_ext_oneapi_forward_progress -------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#pragma once

namespace sycl {
inline namespace _V1 {
namespace ext {
namespace oneapi {
namespace experimental {

enum class forward_progress_guarantee { concurrent, parallel, weakly_parallel };

enum class execution_scope {
work_item,
sub_group,
work_group,
root_group,
};

} // namespace experimental
} // namespace oneapi
} // namespace ext
} // namespace _V1
} // namespace sycl
100 changes: 91 additions & 9 deletions sycl/include/sycl/ext/oneapi/kernel_properties/properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@

#pragma once

#include <sycl/aspects.hpp> // for aspect
#include <array> // for array
#include <stddef.h> // for size_t
#include <stdint.h> // for uint32_T
#include <sycl/aspects.hpp> // for aspect
#include <sycl/ext/oneapi/experimental/forward_progress.hpp> // for forward_progress_guarantee enum
#include <sycl/ext/oneapi/properties/property.hpp> // for PropKind
#include <sycl/ext/oneapi/properties/property_utils.hpp> // for SizeListToStr
#include <sycl/ext/oneapi/properties/property_value.hpp> // for property_value

#include <array> // for array
#include <stddef.h> // for size_t
#include <stdint.h> // for uint32_t
#include <type_traits> // for true_type
#include <utility> // for declval

#include <type_traits> // for true_type
#include <utility> // for declval
namespace sycl {
inline namespace _V1 {
namespace ext::oneapi::experimental {
Expand Down Expand Up @@ -55,7 +54,8 @@ struct sub_group_size_key
std::integral_constant<uint32_t, Size>>;
};

struct device_has_key : detail::compile_time_property_key<detail::PropKind::DeviceHas> {
struct device_has_key
: detail::compile_time_property_key<detail::PropKind::DeviceHas> {
template <aspect... Aspects>
using value_t = property_value<device_has_key,
std::integral_constant<aspect, Aspects>...>;
Expand Down Expand Up @@ -126,6 +126,88 @@ inline constexpr sub_group_size_key::value_t<Size> sub_group_size;
template <aspect... Aspects>
inline constexpr device_has_key::value_t<Aspects...> device_has;

struct work_group_progress_key
: detail::compile_time_property_key<detail::PropKind::WorkGroupProgress> {
template <forward_progress_guarantee Guarantee,
execution_scope CoordinationScope>
using value_t = property_value<
work_group_progress_key,
std::integral_constant<forward_progress_guarantee, Guarantee>,
std::integral_constant<execution_scope, CoordinationScope>>;
};

struct sub_group_progress_key
: detail::compile_time_property_key<detail::PropKind::SubGroupProgress> {
template <forward_progress_guarantee Guarantee,
execution_scope CoordinationScope>
using value_t = property_value<
sub_group_progress_key,
std::integral_constant<forward_progress_guarantee, Guarantee>,
std::integral_constant<execution_scope, CoordinationScope>>;
};

struct work_item_progress_key
: detail::compile_time_property_key<detail::PropKind::WorkItemProgress> {
template <forward_progress_guarantee Guarantee,
execution_scope CoordinationScope>
using value_t = property_value<
work_item_progress_key,
std::integral_constant<forward_progress_guarantee, Guarantee>,
std::integral_constant<execution_scope, CoordinationScope>>;
};

template <forward_progress_guarantee Guarantee,
execution_scope CoordinationScope>
struct property_value<
work_group_progress_key,
std::integral_constant<forward_progress_guarantee, Guarantee>,
std::integral_constant<execution_scope, CoordinationScope>> {
using key_t = work_group_progress_key;
static constexpr forward_progress_guarantee guarantee = Guarantee;
static constexpr execution_scope coordinationScope = CoordinationScope;
};

template <forward_progress_guarantee Guarantee,
execution_scope CoordinationScope>
struct property_value<
sub_group_progress_key,
std::integral_constant<forward_progress_guarantee, Guarantee>,
std::integral_constant<execution_scope, CoordinationScope>> {
using key_t = work_group_progress_key;
static constexpr forward_progress_guarantee guarantee = Guarantee;
static constexpr execution_scope coordinationScope = CoordinationScope;
};

template <forward_progress_guarantee Guarantee,
execution_scope CoordinationScope>
struct property_value<
work_item_progress_key,
std::integral_constant<forward_progress_guarantee, Guarantee>,
std::integral_constant<execution_scope, CoordinationScope>> {
using key_t = work_group_progress_key;
static constexpr forward_progress_guarantee guarantee = Guarantee;
static constexpr execution_scope coordinationScope = CoordinationScope;
};

template <forward_progress_guarantee Guarantee,
execution_scope CoordinationScope>
inline constexpr work_group_progress_key::value_t<Guarantee, CoordinationScope>
work_group_progress;

template <forward_progress_guarantee Guarantee,
execution_scope CoordinationScope>
inline constexpr sub_group_progress_key::value_t<Guarantee, CoordinationScope>
sub_group_progress;

template <forward_progress_guarantee Guarantee,
execution_scope CoordinationScope>
inline constexpr work_item_progress_key::value_t<Guarantee, CoordinationScope>
work_item_progress;

template <> struct is_property_key<work_group_progress_key> : std::true_type {};
template <> struct is_property_key<sub_group_progress_key> : std::true_type {};
template <> struct is_property_key<work_item_progress_key> : std::true_type {};

namespace detail {
template <size_t Dim0, size_t... Dims>
struct PropertyMetaInfo<work_group_size_key::value_t<Dim0, Dims...>> {
Expand Down
5 changes: 4 additions & 1 deletion sycl/include/sycl/ext/oneapi/properties/property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ enum PropKind : uint32_t {
ContiguousMemory = 59,
FullGroup = 60,
Naive = 61,
WorkGroupProgress = 62,
SubGroupProgress = 63,
WorkItemProgress = 64,
// PropKindSize must always be the last value.
PropKindSize = 62,
PropKindSize = 65,
};

struct property_key_base_tag {};
Expand Down
35 changes: 35 additions & 0 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,11 @@ class __SYCL_EXPORT handler {
}
}

void verifyDeviceHasProgressGuarantee(
sycl::ext::oneapi::experimental::forward_progress_guarantee guarantee,
sycl::ext::oneapi::experimental::execution_scope threadScope,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: CamelCase as for other parameters

sycl::ext::oneapi::experimental::execution_scope coordinationScope);

/// Process kernel properties.
///
/// Stores information about kernel properties into the handler.
Expand Down Expand Up @@ -973,6 +978,36 @@ class __SYCL_EXPORT handler {
constexpr bool UsesRootSync = PropertiesT::template has_property<
sycl::ext::oneapi::experimental::use_root_sync_key>();
setKernelIsCooperative(UsesRootSync);
if constexpr (PropertiesT::template has_property<
sycl::ext::oneapi::experimental::
work_group_progress_key>()) {
auto prop = Props.template get_property<
sycl::ext::oneapi::experimental::work_group_progress_key>();
verifyDeviceHasProgressGuarantee(
prop.guarantee,
sycl::ext::oneapi::experimental::execution_scope::work_group,
prop.coordinationScope);
}
if constexpr (PropertiesT::template has_property<
sycl::ext::oneapi::experimental::
sub_group_progress_key>()) {
auto prop = Props.template get_property<
sycl::ext::oneapi::experimental::sub_group_progress_key>();
verifyDeviceHasProgressGuarantee(
prop.guarantee,
sycl::ext::oneapi::experimental::execution_scope::sub_group,
prop.coordinationScope);
}
if constexpr (PropertiesT::template has_property<
sycl::ext::oneapi::experimental::
work_item_progress_key>()) {
auto prop = Props.template get_property<
sycl::ext::oneapi::experimental::work_item_progress_key>();
verifyDeviceHasProgressGuarantee(
prop.guarantee,
sycl::ext::oneapi::experimental::execution_scope::work_item,
prop.coordinationScope);
}
}

/// Checks whether it is possible to copy the source shape to the destination
Expand Down
39 changes: 39 additions & 0 deletions sycl/include/sycl/info/ext_oneapi_device_traits.def
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@ __SYCL_PARAM_TRAITS_SPEC(ext::oneapi::experimental,device, max_global_work_group
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(ext::oneapi::experimental,device, max_work_groups<1>, id<1>, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_1D)
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(ext::oneapi::experimental,device, max_work_groups<2>, id<2>, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_2D)
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(ext::oneapi::experimental,device, max_work_groups<3>, id<3>, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D)

// Forward progress guarantees
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(
ext::oneapi::experimental, device,
work_group_progress_capabilities<
ext::oneapi::experimental::execution_scope::root_group>,
std::vector<ext::oneapi::experimental::forward_progress_guarantee>,
PI_EXT_ONEAPI_DEVICE_INFO_WORK_GROUP_PROGRESS_AT_ROOT_GROUP_LEVEL)
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(
ext::oneapi::experimental, device,
sub_group_progress_capabilities<
ext::oneapi::experimental::execution_scope::root_group>,
std::vector<ext::oneapi::experimental::forward_progress_guarantee>,
PI_EXT_ONEAPI_DEVICE_INFO_SUB_GROUP_PROGRESS_AT_ROOT_GROUP_LEVEL)
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(
ext::oneapi::experimental, device,
sub_group_progress_capabilities<
ext::oneapi::experimental::execution_scope::work_group>,
std::vector<ext::oneapi::experimental::forward_progress_guarantee>,
PI_EXT_ONEAPI_DEVICE_INFO_SUB_GROUP_PROGRESS_AT_WORK_GROUP_LEVEL)
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(
ext::oneapi::experimental, device,
work_item_progress_capabilities<
ext::oneapi::experimental::execution_scope::root_group>,
std::vector<ext::oneapi::experimental::forward_progress_guarantee>,
PI_EXT_ONEAPI_DEVICE_INFO_WORK_ITEM_PROGRESS_AT_ROOT_GROUP_LEVEL)
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(
ext::oneapi::experimental, device,
work_item_progress_capabilities<
ext::oneapi::experimental::execution_scope::work_group>,
std::vector<ext::oneapi::experimental::forward_progress_guarantee>,
PI_EXT_ONEAPI_DEVICE_INFO_WORK_ITEM_PROGRESS_AT_WORK_GROUP_LEVEL)
__SYCL_PARAM_TRAITS_TEMPLATE_SPEC(
ext::oneapi::experimental, device,
work_item_progress_capabilities<
ext::oneapi::experimental::execution_scope::sub_group>,
std::vector<ext::oneapi::experimental::forward_progress_guarantee>,
PI_EXT_ONEAPI_DEVICE_INFO_WORK_ITEM_PROGRESS_AT_SUB_GROUP_LEVEL)

__SYCL_PARAM_TRAITS_SPEC(ext::oneapi::experimental, device, architecture,
ext::oneapi::experimental::architecture,
PI_EXT_ONEAPI_DEVICE_INFO_IP_VERSION)
Expand Down
8 changes: 8 additions & 0 deletions sycl/include/sycl/info/info_desc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <sycl/aspects.hpp>
#include <sycl/detail/type_traits.hpp>
#include <sycl/ext/oneapi/experimental/device_architecture.hpp>
#include <sycl/ext/oneapi/experimental/forward_progress.hpp>
#include <sycl/ext/oneapi/matrix/query-types.hpp>

#include <sycl/range.hpp>
Expand Down Expand Up @@ -195,6 +196,13 @@ template <typename T, T param> struct compatibility_param_traits {};

namespace ext::oneapi::experimental::info::device {
template <int Dimensions> struct max_work_groups;
template <ext::oneapi::experimental::execution_scope CoordinationScope>
struct work_group_progress_capabilities;
template <ext::oneapi::experimental::execution_scope CoordinationScope>
struct sub_group_progress_capabilities;
template <ext::oneapi::experimental::execution_scope CoordinationScope>
struct work_item_progress_capabilities;

} // namespace ext::oneapi::experimental::info::device
#include <sycl/info/ext_codeplay_device_traits.def>
#include <sycl/info/ext_intel_device_traits.def>
Expand Down
7 changes: 3 additions & 4 deletions sycl/include/sycl/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#pragma once

#include <cstddef> // for size_t
#include <memory> // for shared_ptr, hash, opera...
#include <sycl/backend_types.hpp> // for backend, backend_return_t
#include <sycl/context.hpp> // for context
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
Expand All @@ -21,10 +23,7 @@
#include <sycl/device.hpp> // for device
#include <sycl/kernel_bundle_enums.hpp> // for bundle_state
#include <sycl/range.hpp> // for range

#include <cstddef> // for size_t
#include <memory> // for shared_ptr, hash, opera...
#include <variant> // for hash
#include <variant> // for hash

namespace sycl {
inline namespace _V1 {
Expand Down
1 change: 1 addition & 0 deletions sycl/include/sycl/sycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#include <sycl/ext/oneapi/experimental/cuda/barrier.hpp>
#include <sycl/ext/oneapi/experimental/enqueue_functions.hpp>
#include <sycl/ext/oneapi/experimental/fixed_size_group.hpp>
#include <sycl/ext/oneapi/experimental/forward_progress.hpp>
#include <sycl/ext/oneapi/experimental/group_load_store.hpp>
#include <sycl/ext/oneapi/experimental/opportunistic_group.hpp>
#include <sycl/ext/oneapi/experimental/prefetch.hpp>
Expand Down
Loading