Skip to content

Commit 8acf36e

Browse files
MrSidimsromanovvlad
authored andcommitted
[SYCL][FPGA] Add device query for pipe feature support
Pipe feature is enabled under SYCL_INTEL_data_flow_pipes extension, to decide if a device support it we query for device type (should be accelerator, later FPGA) and vendor string should be "Intel(R) Corporation". Signed-off-by: Dmitry Sidorov <[email protected]>
1 parent c93b7b0 commit 8acf36e

File tree

6 files changed

+74
-1
lines changed

6 files changed

+74
-1
lines changed

sycl/include/CL/sycl/detail/device_info.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,27 @@ struct get_device_info<vector_class<size_t>,
289289
}
290290
};
291291

292+
// Specialization for kernel to kernel pipes.
293+
// Here we step away from OpenCL, since there is no appropriate cl_device_info
294+
// enum for global pipes feature.
295+
template <>
296+
struct get_device_info<bool, info::device::kernel_kernel_pipe_support> {
297+
static bool _(RT::PiDevice dev) {
298+
// We claim, that all Intel FPGA devices support kernel to kernel pipe
299+
// feature (at least at the scope of SYCL_INTEL_data_flow_pipes extension).
300+
platform plt = get_device_info<platform, info::device::platform>::_(dev);
301+
string_class platform_name = plt.get_info<info::platform::name>();
302+
if (platform_name == "Intel(R) FPGA Emulation Platform for OpenCL(TM)" ||
303+
platform_name == "Intel(R) FPGA SDK for OpenCL(TM)")
304+
return true;
305+
306+
// TODO: a better way is to query for supported SPIR-V capabilities when
307+
// it's started to be possible. Also, if a device's backend supports
308+
// SPIR-V 1.1 (where Pipe Storage feature was defined), than it supports
309+
// the feature as well.
310+
return false;
311+
}
312+
};
292313

293314
// SYCL host device information
294315

sycl/include/CL/sycl/info/device_traits.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ PARAM_TRAITS_SPEC(device, reference_count, pi_uint32)
7979
PARAM_TRAITS_SPEC(device, max_num_sub_groups, pi_uint32)
8080
PARAM_TRAITS_SPEC(device, sub_group_independent_forward_progress, bool)
8181
PARAM_TRAITS_SPEC(device, sub_group_sizes, vector_class<size_t>)
82+
PARAM_TRAITS_SPEC(device, kernel_kernel_pipe_support, bool)

sycl/include/CL/sycl/info/info_desc.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ enum class device : cl_device_info {
121121
sub_group_independent_forward_progress =
122122
CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS,
123123
sub_group_sizes = CL_DEVICE_SUB_GROUP_SIZES_INTEL,
124-
partition_type_property
124+
partition_type_property,
125+
kernel_kernel_pipe_support
125126
};
126127

127128
enum class device_type : pi_uint64 {

sycl/source/detail/device_info.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ bool get_device_info_host<
496496
throw runtime_error("Sub-group feature is not supported on HOST device.");
497497
}
498498

499+
template <>
500+
bool get_device_info_host<info::device::kernel_kernel_pipe_support>() {
501+
return false;
502+
}
503+
499504
} // namespace detail
500505
} // namespace sycl
501506
} // namespace cl

sycl/test/fpga_tests/fpga_pipes.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// RUN: %clangxx -fsycl %s -o %t.out
2+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
3+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
24
// RUN: %ACC_RUN_PLACEHOLDER %t.out
35
//==------------- fpga_pipes.cpp - SYCL FPGA pipes test --------------------==//
46
//
@@ -292,6 +294,13 @@ int test_array_th_bl_pipe(cl::sycl::queue Queue) {
292294
int main() {
293295
cl::sycl::queue Queue;
294296

297+
if (!Queue.get_device()
298+
.get_info<cl::sycl::info::device::kernel_kernel_pipe_support>()) {
299+
std::cout << "SYCL_INTEL_data_flow_pipes not supported, skipping"
300+
<< std::endl;
301+
return 0;
302+
}
303+
295304
// Non-blocking pipes
296305
int Result = test_simple_nb_pipe<some_nb_pipe, /*test number*/ 1>(Queue);
297306
Result &= test_simple_nb_pipe<some::nb_pipe, /*test number*/ 2>(Queue);

sycl/test/fpga_tests/pipes_info.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// RUN: %clangxx -fsycl %s -o %t.out
2+
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
3+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
4+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
5+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
6+
//==--------- pipes_info.cpp - SYCL device pipe info test --*- C++ -*-------==//
7+
//
8+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9+
// See https://llvm.org/LICENSE.txt for license information.
10+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#include <CL/sycl.hpp>
15+
16+
int main() {
17+
cl::sycl::queue Queue;
18+
cl::sycl::device Device = Queue.get_device();
19+
cl::sycl::platform Platform = Device.get_platform();
20+
21+
// Query if the device supports kernel to kernel pipe feature
22+
bool IsSupported =
23+
Device.get_info<cl::sycl::info::device::kernel_kernel_pipe_support>();
24+
25+
// Query for platform string. We expect only Intel FPGA platforms to support
26+
// SYCL_INTEL_data_flow_pipes extension.
27+
std::string platform_name =
28+
Platform.get_info<cl::sycl::info::platform::name>();
29+
bool SupposedToBeSupported =
30+
(platform_name == "Intel(R) FPGA Emulation Platform for OpenCL(TM)" ||
31+
platform_name == "Intel(R) FPGA SDK for OpenCL(TM)")
32+
? true
33+
: false;
34+
35+
return (SupposedToBeSupported != IsSupported);
36+
}

0 commit comments

Comments
 (0)