Skip to content

Commit 23a6f38

Browse files
[SYCL][FPGA] Add defaults for streaming and register_map fpga_kernel_properties, fix RegisterMap sycl-post-link (#10406)
Add defaults for template parameters for streaming_interface and register_map_interface in fpga_kernel_properties.hpp since current usage gets too verbose, and defaults are allowed and implementation defined. Register map interface also does not match SPIRV expected interface [spec](https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/INTEL/SPV_INTEL_kernel_attributes.asciidoc) and [implementation](KhronosGroup/SPIRV-LLVM-Translator#1774), so update sycl-post-link.
1 parent 5096c20 commit 23a6f38

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,29 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) {
251251
MDNode::get(Ctx, MD));
252252
}
253253

254-
auto getIpInterface = [](const char *Name, LLVMContext &Ctx,
255-
const Attribute &Attr) {
254+
if (AttrKindStr == "sycl-streaming-interface") {
256255
// generate either:
257-
// !N = !{!"<name>"} or
258-
// !N = !{!"<name>", !"stall_free_return"}
256+
// !N = !{!"streaming"} or
257+
// !N = !{!"streaming", !"stall_free_return"}
259258
SmallVector<Metadata *, 2> MD;
260-
MD.push_back(MDString::get(Ctx, Name));
259+
MD.push_back(MDString::get(Ctx, "streaming"));
261260
if (getAttributeAsInteger<uint32_t>(Attr))
262261
MD.push_back(MDString::get(Ctx, "stall_free_return"));
263-
return MDNode::get(Ctx, MD);
264-
};
265-
266-
if (AttrKindStr == "sycl-streaming-interface")
267-
return std::pair<std::string, MDNode *>(
268-
"ip_interface", getIpInterface("streaming", Ctx, Attr));
262+
return std::pair<std::string, MDNode *>("ip_interface",
263+
MDNode::get(Ctx, MD));
264+
}
269265

270-
if (AttrKindStr == "sycl-register-map-interface")
266+
if (AttrKindStr == "sycl-register-map-interface") {
267+
// generate either:
268+
// !N = !{!"csr"} or
269+
// !N = !{!"csr", !"wait_for_done_write"}
270+
SmallVector<Metadata *, 2> MD;
271+
MD.push_back(MDString::get(Ctx, "csr"));
272+
if (getAttributeAsInteger<uint32_t>(Attr))
273+
MD.push_back(MDString::get(Ctx, "wait_for_done_write"));
271274
return std::pair<std::string, MDNode *>("ip_interface",
272-
getIpInterface("csr", Ctx, Attr));
275+
MDNode::get(Ctx, MD));
276+
}
273277

274278
if ((AttrKindStr == SYCL_REGISTER_ALLOC_MODE_ATTR ||
275279
AttrKindStr == SYCL_GRF_SIZE_ATTR) &&
@@ -391,7 +395,7 @@ PreservedAnalyses CompileTimePropertiesPass::run(Module &M,
391395
if (isHostPipeVariable(GV)) {
392396
auto VarName = getGlobalVariableUniqueId(GV);
393397
MDOps.push_back(buildSpirvDecorMetadata(Ctx, SPIRV_HOST_ACCESS_DECOR,
394-
SPIRV_HOST_ACCESS_DEFAULT_VALUE,
398+
SPIRV_HOST_ACCESS_DEFAULT_VALUE,
395399
VarName));
396400
}
397401

llvm/test/SYCLLowerIR/CompileTimePropertiesPass/kernel-attributes/register-map-interface.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
; Check conversion of sycl-register-map-interface attribute
22
; RUN: opt -passes="compile-time-properties" %s -S -o - | FileCheck %s --check-prefix CHECK-IR
33

4-
; CHECK-IR-DAG: @pStreaming() #0 {{.*}}!ip_interface [[REGISTER_MAP:![0-9]+]] {
4+
; CHECK-IR-DAG: @pRegisterMap() #0 {{.*}}!ip_interface [[REGISTER_MAP:![0-9]+]] {
55
; Function Attrs: convergent norecurse
6-
define weak_odr dso_local spir_kernel void @pStreaming() #0 {
6+
define weak_odr dso_local spir_kernel void @pRegisterMap() #0 {
77
entry:
88
ret void
99
}
1010

11-
; CHECK-IR-DAG: @pStallFreeStreaming() #1 {{.*}}!ip_interface [[STALL_FREE_REGISTER_MAP:![0-9]+]] {
11+
; CHECK-IR-DAG: @pWaitRegisterMap() #1 {{.*}}!ip_interface [[WAIT_REGISTER_MAP:![0-9]+]] {
1212
; Function Attrs: convergent norecurse
13-
define weak_odr dso_local spir_kernel void @pStallFreeStreaming() #1 {
13+
define weak_odr dso_local spir_kernel void @pWaitRegisterMap() #1 {
1414
entry:
1515
ret void
1616
}
@@ -31,4 +31,4 @@ attributes #1 = { convergent norecurse "frame-pointer"="all" "sycl-register-map-
3131

3232
; Confirm the decorations for the functions
3333
; CHECK-IR-DAG: [[REGISTER_MAP]] = !{!"csr"}
34-
; CHECK-IR-DAG: [[STALL_FREE_REGISTER_MAP]] = !{!"csr", !"stall_free_return"}
34+
; CHECK-IR-DAG: [[WAIT_REGISTER_MAP]] = !{!"csr", !"wait_for_done_write"}

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ enum class streaming_interface_options_enum : std::uint16_t {
2424
};
2525

2626
enum class register_map_interface_options_enum : std::uint16_t {
27+
do_not_wait_for_done_write,
2728
wait_for_done_write,
28-
do_not_wait_for_done_write
2929
};
3030

3131
struct streaming_interface_key {
@@ -49,7 +49,8 @@ struct pipelined_key {
4949
std::integral_constant<int, pipeline_directive_or_initiation_interval>>;
5050
};
5151

52-
template <streaming_interface_options_enum option>
52+
template <streaming_interface_options_enum option =
53+
streaming_interface_options_enum::accept_downstream_stall>
5354
inline constexpr streaming_interface_key::value_t<option> streaming_interface;
5455

5556
inline constexpr streaming_interface_key::value_t<
@@ -60,7 +61,8 @@ inline constexpr streaming_interface_key::value_t<
6061
streaming_interface_options_enum::remove_downstream_stall>
6162
streaming_interface_remove_downstream_stall;
6263

63-
template <register_map_interface_options_enum option>
64+
template <register_map_interface_options_enum option =
65+
register_map_interface_options_enum::do_not_wait_for_done_write>
6466
inline constexpr register_map_interface_key::value_t<option>
6567
register_map_interface;
6668

@@ -128,12 +130,12 @@ template <>
128130
struct IsCompileTimeProperty<intel::experimental::pipelined_key>
129131
: std::true_type {};
130132

131-
template <intel::experimental::streaming_interface_options_enum Stall>
133+
template <intel::experimental::streaming_interface_options_enum Stall_Free>
132134
struct PropertyMetaInfo<
133-
intel::experimental::streaming_interface_key::value_t<Stall>> {
135+
intel::experimental::streaming_interface_key::value_t<Stall_Free>> {
134136
static constexpr const char *name = "sycl-streaming-interface";
135137
static constexpr intel::experimental::streaming_interface_options_enum value =
136-
Stall;
138+
Stall_Free;
137139
};
138140
template <intel::experimental::register_map_interface_options_enum Wait>
139141
struct PropertyMetaInfo<

0 commit comments

Comments
 (0)