Skip to content

[SYCL][FPGA] Support Intel FPGA simulator device selector #6715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Sep 15, 2022

Conversation

mendell27
Copy link
Contributor

@mendell27 mendell27 commented Sep 7, 2022

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.

Create fpga_simulator_selector to be used to select the FPGA simulator.
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 emulator and hardware FPGA device selectors will prefer the
emulator/hardware over a simulation device if both have the same device
name.
@mendell27 mendell27 requested a review from a team as a code owner September 7, 2022 13:18
@bader bader changed the title Support Intel FPGA simulator device selector [SYCL] Support Intel FPGA simulator device selector Sep 7, 2022
@mendell27 mendell27 changed the title [SYCL] Support Intel FPGA simulator device selector [SYCL][FPGA] Support Intel FPGA simulator device selector Sep 7, 2022
@mendell27
Copy link
Contributor Author

The failing tests have nothing to do with my change. What can/should I do?

I tried with SetEnvironmentA, and it didn't work for me
Create fpga_simulator_selector to be used to select the FPGA simulator.
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 emulator and hardware FPGA device selectors will prefer the
emulator/hardware over a simulation device if both have the same device
name.
I tried with SetEnvironmentA, and it didn't work for me
At this point, I am okay with the restriction that the simulator device
replaces any hardware ones.  It is unlikely that anyone interested in
using the simulator would also want to use hardware in the same program
At this point, I am okay with the restriction that the simulator device
replaces any hardware ones.  It is unlikely that anyone interested in
using the simulator would also want to use hardware in the same program
@mendell27
Copy link
Contributor Author

I changed my mind. This is now okay to review. We will live with the hardware/simulator restriction as if is unlikely for a user to want both simultaneously.

I have updated to re-use existing code

@mendell27
Copy link
Contributor Author

mendell27 commented Sep 8, 2022

How do I fix a clang-format failure in a clang file that I didn't change? clang/lib/Sema/SemaChecking.cpp

// Currently only 1 simulator device is supported
auto devices = std::to_string(numDevices);
#ifdef _WIN32
_putenv_s("CL_CONTEXT_MPSIM_DEVICE_INTELFPGA", devices.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please provide a link to some documentation for this env var?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is documented in oneAPI and for OpenCL in 11.1.7.2. Simulating Your OpenCL Library in OpenCL

For oneAPI, the intent is to hide this environment variable from the user, as it is very intrusive. OpenCL has a multi-step process for running programs, while oneAPI hides all that. We would prefer it not to be openly documented.

When compiling for OpenCL for simulation, the aoc command explicitly tells the user to set the variable. For oneAPI, aoc does not print this message

@mendell27
Copy link
Contributor Author

Is it possible to resolve this today? We want to get the code sample changes in by CC (Thursday?), so there is a bit of a rush

@bader bader requested a review from romanovvlad September 12, 2022 15:52
Document fpga_simulator_selector in official documentation. Bump the
version to 2.
@mendell27 mendell27 requested a review from a team as a code owner September 12, 2022 20:26
@gmlueck
Copy link
Contributor

gmlueck commented Sep 12, 2022

Do you mind using this PR to update the extension specification to use the official template? I know the existing spec does not follow that template, but this seems like a good opportunity to remove some technical debt.

The specification needs to be updated anyway to make it clear that the new fpga_simulator_selector is added in revision 2 of the spec. This will be easier to do if it follows the template.

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 emulator and hardware FPGA device selectors will prefer the emulator/hardware over a simulation device if both have the same device name.

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. We expect this behaviour to be eliminated in the future.

Some of this information seems like important stuff that the user needs to know. If so, it should be added to the extension specification, perhaps as a NOTE. For example:

[NOTE]
====
In the DPC++ implementation, the application must be built with "-Xssimulation"
in order to use `sycl::ext::intel::fpga_simulator_selector`.
====

Note that the SYCL 2020 style for selectors is to define an object that is the selector, not to define a type that the application has to construct. Do you plan to update this extension to follow that style? Mentioning this now in case you want to migrate to the new style now and then add this new selector only with the new style.

Rewrite as requested.  Document current restrictions with the simulator
selector affecting hardware.
@mendell27
Copy link
Contributor Author

Updated to the current template. I am not going to change to the object format at this time, as the current implementation of the FPGA runtime needs to be enhanced to support having the simulator active at all times first

romanovvlad
romanovvlad previously approved these changes Sep 13, 2022
@mendell27 mendell27 requested a review from gmlueck September 13, 2022 16:48
@mendell27
Copy link
Contributor Author

Build check failures are not related to my changes

@bader bader merged commit 9bef890 into intel:sycl Sep 15, 2022
@mendell27 mendell27 deleted the fpga_simulator_device branch September 15, 2022 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants