Skip to content

Commit d141b1d

Browse files
committed
Clean implementation of fpga_simulator_selector
Document fpga_simulator_selector in official documentation. Bump the version to 2.
1 parent bc368a1 commit d141b1d

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

sycl/doc/extensions/supported/sycl_ext_intel_fpga_device_selector.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# FPGA selector
22

33
Intel FPGA users can use header file: `#include<sycl/ext/intel/fpga_device_selector.hpp>` to simplify their code
4-
when they want to specify FPGA hardware device or FPGA emulation device.
4+
when they want to specify FPGA hardware device, FPGA simulator device or FPGA emulation device.
55

66
## Implementation
77

@@ -17,6 +17,15 @@ sycl::queue deviceQueue{sycl::ext::intel::fpga_selector{}};
1717
...
1818
```
1919
20+
## Usage: select FPGA simulator device
21+
```c++
22+
#include <sycl/ext/intel/fpga_device_selector.hpp>
23+
...
24+
// force FPGA simulator device
25+
sycl::queue deviceQueue{sycl::ext::intel::fpga_simulator_selector{}};
26+
...
27+
```
28+
2029
## Usage: select FPGA emulator device
2130
```c++
2231
#include <sycl/ext/intel/fpga_device_selector.hpp>
@@ -39,3 +48,4 @@ extension
3948
|Value |Description|
4049
|:---- |:---------:|
4150
|1 |Initial extension version. Base features are supported.|
51+
|2 |fpga_simulator_selector added.|

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ class platform_selector : public device_selector {
3434
const platform &pf = device.get_platform();
3535
const std::string &platform_name = pf.get_info<info::platform::name>();
3636
if (platform_name == device_platform_name) {
37-
const std::string name = device.get_info<sycl::info::device::name>();
38-
// Prefer hardware devices over simulator ones.
39-
if (name.find("SimulatorDevice") != std::string::npos)
40-
return 9000;
4137
return 10000;
4238
}
4339
return -1;
@@ -61,16 +57,12 @@ class fpga_emulator_selector : public platform_selector {
6157

6258
class fpga_simulator_selector : public fpga_selector {
6359
public:
64-
fpga_simulator_selector(unsigned int numDevices = 1) {
65-
// Tell the runtime to start a simulator device
66-
// Notes:
67-
// This replaces any hardware devices present
68-
// Currently only 1 simulator device is supported
69-
auto devices = std::to_string(numDevices);
60+
fpga_simulator_selector() {
61+
// Tell the runtime to use a simulator device rather than hardware
7062
#ifdef _WIN32
71-
_putenv_s("CL_CONTEXT_MPSIM_DEVICE_INTELFPGA", devices.c_str());
63+
_putenv_s("CL_CONTEXT_MPSIM_DEVICE_INTELFPGA", "1");
7264
#else
73-
setenv("CL_CONTEXT_MPSIM_DEVICE_INTELFPGA", devices.c_str(), 0);
65+
setenv("CL_CONTEXT_MPSIM_DEVICE_INTELFPGA", "1", 0);
7466
#endif
7567
}
7668
};

sycl/include/sycl/feature_test.hpp.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ __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+
#ifndef SYCL_EXT_INTEL_FPGA_DEVICE_SELECTOR
66+
#define SYCL_EXT_INTEL_FPGA_DEVICE_SELECTOR 2
67+
#endif
6668
#define SYCL_EXT_INTEL_FPGA_LSU 1
6769
#define SYCL_EXT_INTEL_FPGA_REG 1
6870
#define SYCL_EXT_INTEL_KERNEL_ARGS_RESTRICT 1

0 commit comments

Comments
 (0)