Skip to content

Commit 9bef890

Browse files
authored
[SYCL][FPGA] Support Intel FPGA simulator device selector (intel#6715)
Create **fpga_simulator_selector** to be used to select the FPGA simulator device. This assumes that the user has compiled their program with -Xssimulation (as well as -fintelfpga) to prepare for the simulator. An object of class fpga_simulator_selector must be constructed early in the execution of the host program in order to make the simulator available at runtime. The current implementation has the effect that if an object of class sycl::ext::intel::fpga_simulator_selector is defined, FPGA hardware devices selected using sycl::ext::intel::fpga_selector will select simulator devices. This will be documented in the release notes and the specification. We expect this behaviour to be eliminated in the future.
1 parent 65c3ea2 commit 9bef890

File tree

4 files changed

+138
-42
lines changed

4 files changed

+138
-42
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
= sycl_ext_intel_fpga_device_selector
2+
3+
:source-highlighter: coderay
4+
:coderay-linenums-mode: table
5+
6+
// This section needs to be after the document title.
7+
:doctype: book
8+
:toc2:
9+
:toc: left
10+
:encoding: utf-8
11+
:lang: en
12+
:dpcpp: pass:[DPC++]
13+
14+
// Set the default source code type in this document to C++,
15+
// for syntax highlighting purposes. This is needed because
16+
// docbook uses c++ and html5 uses cpp.
17+
:language: {basebackend@docbook:c++:cpp}
18+
19+
20+
== Notice
21+
22+
[%hardbreaks]
23+
Copyright (C) 2022-2022 Intel Corporation. All rights reserved.
24+
25+
Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks
26+
of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by
27+
permission by Khronos.
28+
29+
30+
== Contact
31+
32+
To report problems with this extension, please open a new issue at:
33+
34+
https://github.com/intel/llvm/issues
35+
36+
37+
== Dependencies
38+
39+
This extension is written against the SYCL 2020 revision 5 specification. All
40+
references below to the "core SYCL specification" or to section numbers in the
41+
SYCL specification refer to that revision.
42+
43+
== Status
44+
45+
This extension is implemented and fully supported by {dpcpp}.
46+
47+
[NOTE]
48+
====
49+
This extension is currently implemented in {dpcpp} only for FPGA devices.
50+
In the {dpcpp} implementation, the application must be built with
51+
"-Xshardware" in order to use an FPGA hardware device.
52+
In the {dpcpp} implementation, the application must be built with
53+
"-Xssimulation" in order to use an FPGA simulator device.
54+
====
55+
56+
57+
== Overview
58+
59+
This extension provides selectors to choose between FPGA hardware devices, FPGA
60+
simulator devices, and FPGA emulator devices. The current implementation is
61+
based on the platform name. This is useful in the most common case when the
62+
user has one FPGA board installed in their system (one device per platform).
63+
64+
To use these selectors, add
65+
....
66+
#include <sycl/ext/intel/fpga_device_selector.hpp>
67+
....
68+
to your source code.
69+
70+
71+
== Specification
72+
73+
=== Feature test macro
74+
75+
This extension provides a feature-test macro as described in the core SYCL
76+
specification. An implementation supporting this extension must predefine the
77+
macro `SYCL_EXT_INTEL_FPGA_DEVICE_SELECTOR` to one of the values defined in the table
78+
below. Applications can test for the existence of this macro to determine if
79+
the implementation supports this feature, or applications can test the macro's
80+
value to determine which of the extension's features the implementation
81+
supports.
82+
83+
[%header,cols="1,5"]
84+
|===
85+
|Value
86+
|Description
87+
88+
|1
89+
|Initial version of this extension. Base features are supported.
90+
91+
|2
92+
|fpga_simulator_selector added.
93+
|===
94+
95+
=== Select FPGA hardware device
96+
....
97+
// select FPGA hardware device
98+
sycl::queue deviceQueue{sycl::ext::intel::fpga_selector{}};
99+
....
100+
101+
=== Select FPGA simulator device
102+
....
103+
// select FPGA simulator device
104+
sycl::queue deviceQueue{sycl::ext::intel::fpga_simulator_selector{}};
105+
....
106+
107+
[NOTE]
108+
====
109+
Added in version 2 of this extension.
110+
====
111+
112+
=== Select FPGA emulator device
113+
....
114+
// select FPGA emulator device
115+
sycl::queue deviceQueue{sycl::ext::intel::fpga_emulator_selector{}};
116+
....
117+
118+
== Implementation notes
119+
120+
The current implementation has a restriction on the use of
121+
`fpga_simulator_selector`. If an object of `fpga_simulator_selector` is
122+
defined in the application, FPGA hardware devices selected using
123+
`fpga_selector` will select a simulator device. This behaviour is expected to
124+
be eliminated in the future.
125+

sycl/doc/extensions/supported/sycl_ext_intel_fpga_device_selector.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

sycl/include/sycl/ext/intel/fpga_device_selector.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ class fpga_emulator_selector : public platform_selector {
5656
fpga_emulator_selector() : platform_selector(EMULATION_PLATFORM_NAME) {}
5757
};
5858

59+
class fpga_simulator_selector : public fpga_selector {
60+
public:
61+
fpga_simulator_selector() {
62+
// Tell the runtime to use a simulator device rather than hardware
63+
#ifdef _WIN32
64+
_putenv_s("CL_CONTEXT_MPSIM_DEVICE_INTELFPGA", "1");
65+
#else
66+
setenv("CL_CONTEXT_MPSIM_DEVICE_INTELFPGA", "1", 0);
67+
#endif
68+
}
69+
};
70+
5971
} // namespace intel
6072
} // namespace ext
6173

sycl/include/sycl/feature_test.hpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ __SYCL_INLINE_VER_NAMESPACE(_V1) {
6262
#define SYCL_EXT_INTEL_EXTENDED_ATOMICS 1
6363
#endif
6464
#endif
65-
#define SYCL_EXT_INTEL_FPGA_DEVICE_SELECTOR 1
65+
#define SYCL_EXT_INTEL_FPGA_DEVICE_SELECTOR 2
6666
#define SYCL_EXT_INTEL_FPGA_LSU 1
6767
#define SYCL_EXT_INTEL_FPGA_REG 1
6868
#define SYCL_EXT_INTEL_KERNEL_ARGS_RESTRICT 1

0 commit comments

Comments
 (0)