Skip to content

Commit 7e6db77

Browse files
aejjehintbowenxue-intelsteffenlarsen
authored
[SYCL] Re-apply task sequence changes (#14750)
This change re-apply the task sequence changes from PR #12453 that were reverted in #14359 now that the spec has been approved and the back-end implementation is ready. The spec is also moved from proposed to experimental. --------- Co-authored-by: bowenxue-intel <[email protected]> Co-authored-by: Steffen Larsen <[email protected]>
1 parent ebb3b4a commit 7e6db77

33 files changed

+1218
-35
lines changed

clang/lib/CodeGen/CodeGenTypes.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,11 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
711711
"__spv::__spirv_CooperativeMatrixKHR") {
712712
ResultType = ConvertSPVCooperativeMatrixType(RD);
713713
break;
714+
} else if (RD && RD->getQualifiedNameAsString() ==
715+
"__spv::__spirv_TaskSequenceINTEL") {
716+
ResultType = llvm::TargetExtType::get(getLLVMContext(),
717+
"spirv.TaskSequenceINTEL");
718+
break;
714719
}
715720
}
716721
}

clang/lib/Driver/ToolChains/Clang.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -10537,7 +10537,8 @@ static void getTripleBasedSPIRVTransOpts(Compilation &C,
1053710537
",+SPV_INTEL_fpga_invocation_pipelining_attributes"
1053810538
",+SPV_INTEL_fpga_latency_control"
1053910539
",+SPV_KHR_shader_clock"
10540-
",+SPV_INTEL_bindless_images";
10540+
",+SPV_INTEL_bindless_images"
10541+
",+SPV_INTEL_task_sequence";
1054110542
ExtArg = ExtArg + DefaultExtArg + INTELExtArg;
1054210543
if (C.getDriver().IsFPGAHWMode())
1054310544
// Enable several extensions on FPGA H/W exclusively
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
2+
3+
// Test that SPIR-V codegen generates the expected LLVM struct name for the
4+
// TaskSequenceINTEL type
5+
6+
namespace __spv {
7+
struct __spirv_TaskSequenceINTEL;
8+
} // namespace __spv
9+
10+
// CHECK: @_Z4func{{.*}}(target("spirv.TaskSequenceINTEL")
11+
void func(__spv::__spirv_TaskSequenceINTEL *task_seq) {}

clang/test/Driver/sycl-spirv-ext-old-model.c

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
// CHECK-DEFAULT-SAME:,+SPV_INTEL_fpga_latency_control
5252
// CHECK-DEFAULT-SAME:,+SPV_KHR_shader_clock
5353
// CHECK-DEFAULT-SAME:,+SPV_INTEL_bindless_images
54+
// CHECK-DEFAULT-SAME:,+SPV_INTEL_task_sequence
5455
// CHECK-DEFAULT-SAME:,+SPV_INTEL_token_type
5556
// CHECK-DEFAULT-SAME:,+SPV_INTEL_bfloat16_conversion
5657
// CHECK-DEFAULT-SAME:,+SPV_INTEL_joint_matrix
@@ -83,6 +84,7 @@
8384
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_fpga_buffer_location
8485
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_fpga_argument_interfaces
8586
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_fpga_latency_control
87+
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_task_sequence
8688
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_usm_storage_classes
8789
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_runtime_aligned
8890
// CHECK-FPGA-HW-SAME:,+SPV_INTEL_fpga_cluster_attributes,+SPV_INTEL_loop_fuse
@@ -114,6 +116,7 @@
114116
// CHECK-CPU-SAME:,+SPV_INTEL_fpga_argument_interfaces
115117
// CHECK-CPU-SAME:,+SPV_INTEL_fpga_invocation_pipelining_attributes
116118
// CHECK-CPU-SAME:,+SPV_INTEL_fpga_latency_control
119+
// CHECK-CPU-SAME:,+SPV_INTEL_task_sequence
117120
// CHECK-CPU-SAME:,+SPV_INTEL_token_type
118121
// CHECK-CPU-SAME:,+SPV_INTEL_bfloat16_conversion
119122
// CHECK-CPU-SAME:,+SPV_INTEL_joint_matrix

llvm/include/llvm/SYCLLowerIR/DeviceConfigFile.td

+5-3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def AspectExt_oneapi_private_alloca : Aspect<"ext_oneapi_private_alloca">;
8383
def AspectExt_oneapi_queue_profiling_tag : Aspect<"ext_oneapi_queue_profiling_tag">;
8484
def AspectExt_oneapi_virtual_mem : Aspect<"ext_oneapi_virtual_mem">;
8585
def AspectExt_oneapi_cuda_cluster_group : Aspect<"ext_oneapi_cuda_cluster_group">;
86+
def AspectExt_intel_fpga_task_sequence : Aspect<"ext_intel_fpga_task_sequence">;
8687
// Deprecated aspects
8788
def AspectInt64_base_atomics : Aspect<"int64_base_atomics">;
8889
def AspectInt64_extended_atomics : Aspect<"int64_extended_atomics">;
@@ -141,9 +142,10 @@ def : TargetInfo<"__TestAspectList",
141142
AspectExt_oneapi_bindless_sampled_image_fetch_2d_usm, AspectExt_oneapi_bindless_sampled_image_fetch_2d,
142143
AspectExt_intel_esimd,
143144
AspectExt_oneapi_ballot_group, AspectExt_oneapi_fixed_size_group, AspectExt_oneapi_opportunistic_group,
144-
AspectExt_oneapi_tangle_group, AspectExt_intel_matrix, AspectExt_oneapi_is_composite, AspectExt_oneapi_is_component,
145-
AspectExt_oneapi_graph, AspectExt_oneapi_limited_graph,
146-
AspectExt_oneapi_private_alloca, AspectExt_oneapi_queue_profiling_tag, AspectExt_oneapi_virtual_mem, AspectExt_oneapi_cuda_cluster_group],
145+
AspectExt_oneapi_tangle_group, AspectExt_intel_matrix, AspectExt_oneapi_is_composite, AspectExt_oneapi_is_component,
146+
AspectExt_oneapi_graph, AspectExt_oneapi_limited_graph, AspectExt_oneapi_private_alloca,
147+
AspectExt_oneapi_queue_profiling_tag, AspectExt_oneapi_virtual_mem, AspectExt_oneapi_cuda_cluster_group,
148+
AspectExt_intel_fpga_task_sequence],
147149
[]>;
148150
// This definition serves the only purpose of testing whether the deprecated aspect list defined in here and in SYCL RT
149151
// match.

llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) {
416416

417417
if (AttrKindStr == "sycl-streaming-interface") {
418418
// generate either:
419+
// !ip_interface !N
419420
// !N = !{!"streaming"} or
420421
// !N = !{!"streaming", !"stall_free_return"}
421422
SmallVector<Metadata *, 2> MD;
@@ -428,6 +429,7 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) {
428429

429430
if (AttrKindStr == "sycl-register-map-interface") {
430431
// generate either:
432+
// !ip_interface !N
431433
// !N = !{!"csr"} or
432434
// !N = !{!"csr", !"wait_for_done_write"}
433435
SmallVector<Metadata *, 2> MD;
@@ -438,6 +440,20 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) {
438440
MDNode::get(Ctx, MD));
439441
}
440442

443+
if (AttrKindStr == "sycl-fpga-cluster") {
444+
// generate either:
445+
// !stall_free !N
446+
// !N = !{i32 1} or
447+
// !stall_enable !N
448+
// !N = !{i32 1}
449+
std::string ClusterType =
450+
getAttributeAsInteger<uint32_t>(Attr) ? "stall_enable" : "stall_free";
451+
Metadata *ClusterMDArgs[] = {
452+
ConstantAsMetadata::get(ConstantInt::get(Type::getInt32Ty(Ctx), 1))};
453+
return std::pair<std::string, MDNode *>(ClusterType,
454+
MDNode::get(Ctx, ClusterMDArgs));
455+
}
456+
441457
if ((AttrKindStr == SYCL_REGISTER_ALLOC_MODE_ATTR ||
442458
AttrKindStr == SYCL_GRF_SIZE_ATTR) &&
443459
!llvm::esimd::isESIMD(F)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
; Check conversion of sycl-fpga-cluster attribute
2+
; RUN: opt -passes="compile-time-properties" %s -S -o - | FileCheck %s --check-prefix CHECK-IR
3+
4+
; CHECK-IR-DAG: @stallFree() #0 {{.*}}!stall_free [[MD_TRUE:![0-9]+]] {
5+
; Function Attrs: convergent norecurse
6+
define weak_odr dso_local spir_kernel void @stallFree() #0 {
7+
entry:
8+
ret void
9+
}
10+
11+
; CHECK-IR-DAG: @stallEnable() #1 {{.*}}!stall_enable [[MD_TRUE:![0-9]+]] {
12+
; Function Attrs: convergent norecurse
13+
define weak_odr dso_local spir_kernel void @stallEnable() #1 {
14+
entry:
15+
ret void
16+
}
17+
18+
attributes #0 = { convergent norecurse "frame-pointer"="all" "sycl-fpga-cluster"="0" }
19+
attributes #1 = { convergent norecurse "frame-pointer"="all" "sycl-fpga-cluster"="1" }
20+
21+
!opencl.spir.version = !{!0, !0, !0, !0, !0, !0, !0, !0, !0, !0, !0}
22+
!spirv.Source = !{!1, !1, !1, !1, !1, !1, !1, !1, !1, !1, !1}
23+
!llvm.ident = !{!2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2}
24+
!llvm.module.flags = !{!3, !4}
25+
26+
!0 = !{i32 1, i32 2}
27+
!1 = !{i32 4, i32 100000}
28+
!2 = !{!"clang version 13.0.0 (https://github.com/intel/llvm)"}
29+
!3 = !{i32 1, !"wchar_size", i32 4}
30+
!4 = !{i32 7, !"frame-pointer", i32 2}
31+
32+
; Confirm the decorations for the functions
33+
; CHECK-IR-DAG: [[MD_TRUE]] = !{i32 1}

sycl/include/CL/__spirv/spirv_ops.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,25 @@ extern __DPCPP_SYCL_EXTERNAL
13181318
std::enable_if_t<std::is_integral_v<to> && std::is_unsigned_v<to>, to>
13191319
__spirv_ConvertPtrToU(from val) noexcept;
13201320

1321+
template <typename RetT, typename... ArgsT>
1322+
extern __DPCPP_SYCL_EXTERNAL __spv::__spirv_TaskSequenceINTEL *
1323+
__spirv_TaskSequenceCreateINTEL(RetT (*f)(ArgsT...), int Pipelined = -1,
1324+
int ClusterMode = -1,
1325+
unsigned int ResponseCapacity = 0,
1326+
unsigned int InvocationCapacity = 0) noexcept;
1327+
1328+
template <typename... ArgsT>
1329+
extern __DPCPP_SYCL_EXTERNAL void
1330+
__spirv_TaskSequenceAsyncINTEL(__spv::__spirv_TaskSequenceINTEL *TaskSequence,
1331+
ArgsT... Args) noexcept;
1332+
1333+
template <typename RetT>
1334+
extern __DPCPP_SYCL_EXTERNAL RetT __spirv_TaskSequenceGetINTEL(
1335+
__spv::__spirv_TaskSequenceINTEL *TaskSequence) noexcept;
1336+
1337+
extern __DPCPP_SYCL_EXTERNAL void __spirv_TaskSequenceReleaseINTEL(
1338+
__spv::__spirv_TaskSequenceINTEL *TaskSequence) noexcept;
1339+
13211340
#else // if !__SYCL_DEVICE_ONLY__
13221341

13231342
template <typename dataT>

sycl/include/CL/__spirv/spirv_types.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ template <typename T, std::size_t R, std::size_t C, MatrixLayout L,
123123
MatrixUse U = MatrixUse::MatrixA>
124124
struct __spirv_JointMatrixINTEL;
125125

126+
struct __spirv_TaskSequenceINTEL;
127+
126128
} // namespace __spv
127129

128130
#ifdef __SYCL_DEVICE_ONLY__

sycl/include/sycl/device_aspect_macros.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@
303303
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_graph__ 0
304304
#endif
305305

306+
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_intel_fpga_task_sequence__
307+
// __SYCL_ASPECT(ext_intel_fpga_task_sequence, 62)
308+
#define __SYCL_ALL_DEVICES_HAVE_ext_intel_fpga_task_sequence__ 0
309+
#endif
310+
306311
#ifndef __SYCL_ALL_DEVICES_HAVE_ext_oneapi_limited_graph__
307312
// __SYCL_ASPECT(ext_oneapi_limited_graph, 63)
308313
#define __SYCL_ALL_DEVICES_HAVE_ext_oneapi_limited_graph__ 0
@@ -680,6 +685,11 @@
680685
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_graph__ 0
681686
#endif
682687

688+
#ifndef __SYCL_ANY_DEVICE_HAS_ext_intel_fpga_task_sequence__
689+
// __SYCL_ASPECT(ext_intel_fpga_task_sequence__, 62)
690+
#define __SYCL_ANY_DEVICE_HAS_ext_intel_fpga_task_sequence__ 0
691+
#endif
692+
683693
#ifndef __SYCL_ANY_DEVICE_HAS_ext_oneapi_limited_graph__
684694
// __SYCL_ASPECT(ext_oneapi_limited_graph, 63)
685695
#define __SYCL_ANY_DEVICE_HAS_ext_oneapi_limited_graph__ 0

sycl/include/sycl/ext/intel/experimental/fpga_kernel_properties.hpp

+56-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//==----- fpga_kernel_properties.hpp - SYCL properties associated with FPGA
2-
// kernel properties ---==//
1+
//===--------------------- fpga_kernel_properties.hpp ---------------------===//
2+
// SYCL properties associated with FPGA kernel properties
33
//
44
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
55
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,11 +12,15 @@
1212
#include <sycl/ext/oneapi/properties/property.hpp>
1313
#include <sycl/ext/oneapi/properties/property_value.hpp>
1414

15+
#include <cstdint>
16+
#include <type_traits>
17+
1518
namespace sycl {
1619
inline namespace _V1 {
1720
namespace ext::intel::experimental {
1821

1922
template <typename T, typename PropertyListT> class fpga_kernel_attribute;
23+
template <auto &f, typename PropertyListT> class task_sequence;
2024

2125
enum class streaming_interface_options_enum : uint16_t {
2226
accept_downstream_stall,
@@ -28,6 +32,11 @@ enum class register_map_interface_options_enum : uint16_t {
2832
wait_for_done_write,
2933
};
3034

35+
enum class fpga_cluster_options_enum : std::uint16_t {
36+
stall_free,
37+
stall_enable
38+
};
39+
3140
struct streaming_interface_key
3241
: oneapi::experimental::detail::compile_time_property_key<
3342
oneapi::experimental::detail::PropKind::StreamingInterface> {
@@ -54,6 +63,15 @@ struct pipelined_key : oneapi::experimental::detail::compile_time_property_key<
5463
std::integral_constant<int, pipeline_directive_or_initiation_interval>>;
5564
};
5665

66+
struct fpga_cluster_key
67+
: oneapi::experimental::detail::compile_time_property_key<
68+
oneapi::experimental::detail::PropKind::FPGACluster> {
69+
template <fpga_cluster_options_enum option>
70+
using value_t = ext::oneapi::experimental::property_value<
71+
fpga_cluster_key,
72+
std::integral_constant<fpga_cluster_options_enum, option>>;
73+
};
74+
5775
template <streaming_interface_options_enum option =
5876
streaming_interface_options_enum::accept_downstream_stall>
5977
inline constexpr streaming_interface_key::value_t<option> streaming_interface;
@@ -84,6 +102,18 @@ inline constexpr pipelined_key::value_t<
84102
pipeline_directive_or_initiation_interval>
85103
pipelined;
86104

105+
template <fpga_cluster_options_enum option =
106+
fpga_cluster_options_enum::stall_free>
107+
inline constexpr fpga_cluster_key::value_t<option> fpga_cluster;
108+
109+
inline constexpr fpga_cluster_key::value_t<
110+
fpga_cluster_options_enum::stall_free>
111+
stall_free_clusters;
112+
113+
inline constexpr fpga_cluster_key::value_t<
114+
fpga_cluster_options_enum::stall_enable>
115+
stall_enable_clusters;
116+
87117
} // namespace ext::intel::experimental
88118

89119
namespace ext::oneapi::experimental {
@@ -103,6 +133,22 @@ struct is_property_key_of<
103133
intel::experimental::fpga_kernel_attribute<T, PropertyListT>>
104134
: std::true_type {};
105135

136+
template <typename T, typename PropertyListT>
137+
struct is_property_key_of<
138+
intel::experimental::fpga_cluster_key,
139+
intel::experimental::fpga_kernel_attribute<T, PropertyListT>>
140+
: std::true_type {};
141+
142+
template <auto &f, typename PropertyListT>
143+
struct is_property_key_of<intel::experimental::pipelined_key,
144+
intel::experimental::task_sequence<f, PropertyListT>>
145+
: std::true_type {};
146+
147+
template <auto &f, typename PropertyListT>
148+
struct is_property_key_of<intel::experimental::fpga_cluster_key,
149+
intel::experimental::task_sequence<f, PropertyListT>>
150+
: std::true_type {};
151+
106152
namespace detail {
107153
template <intel::experimental::streaming_interface_options_enum option>
108154
struct HasCompileTimeEffect<
@@ -133,6 +179,14 @@ struct PropertyMetaInfo<intel::experimental::pipelined_key::value_t<Value>> {
133179
static constexpr int value = Value;
134180
};
135181

182+
template <intel::experimental::fpga_cluster_options_enum ClusterType>
183+
struct PropertyMetaInfo<
184+
intel::experimental::fpga_cluster_key::value_t<ClusterType>> {
185+
static constexpr const char *name = "sycl-fpga-cluster";
186+
static constexpr intel::experimental::fpga_cluster_options_enum value =
187+
ClusterType;
188+
};
189+
136190
} // namespace detail
137191
} // namespace ext::oneapi::experimental
138192
} // namespace _V1

0 commit comments

Comments
 (0)