beehive-lab / TornadoVM

TornadoVM: A practical and efficient heterogeneous programming framework for managed languages
https://www.tornadovm.org
Apache License 2.0
1.19k stars 113 forks source link

[bug] FPGA emulation mode for Intel FPGA via oneAPI Base Toolkit #260

Closed stratika closed 1 year ago

stratika commented 1 year ago

Describe the bug

I have installed the oneAPI Base Toolkit on my machine (Ubuntu 22.10) and I managed to get the emulated FPGA device. I tried to run on it after configuring the FPGA configuration file in TornadoVM but it results in error. The error is because in the OCLCodeCache the HLS command is created assuming the format of the older HLS compiler aoc, while now it uses the aocl-ioc64. For example:

The wrong command is:

aocl-ioc64 <directory-to-OpenCL-file>/computeDFT.cl -board=fpga_fast_emu -o <directory-to-bitstream-file>/computeDFT

while it should be:

aocl-ioc64 --input=<directory-to-OpenCL-file>/computeDFT.cl --device=fpga_fast_emu --cmd=build --ir=<directory-to-bitstream-file>/computeDFT.aocx

How To Reproduce

To reproduce, you will have to install oneAPI Base Toolkit on a machine. I did this by following these steps:

  1. Download the Intel oneAPI Base Toolkit (I tried version 2023.1.0):
    $ wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/7deeaac4-f605-4bcf-a81b-ea7531577c61/l_BaseKit_p_2023.1.0.46401.sh
    $ sudo sh ./l_BaseKit_p_2023.1.0.46401.sh
  2. Create an alias to bashrc:
    $ echo 'alias oneapi="source /opt/intel/oneapi/setvars.sh"' >> ~/.bashrc
    $ clinfo

    You should see all devices, including CPU, GPU, FPGAs (emulation mode).

Now, assuming you have built the latest develop branch of TornadoVM:

  1. Configure your FPGA configuration file (in directory <mydir>/intel-fpga.conf with the following content:

    # Configure the fields for FPGA compilation & execution
    # [device]
    DEVICE_NAME = fpga_fast_emu
    # [compiler]
    COMPILER = aocl-ioc64
    # [options]
    #FLAGS = -v -report # Configure the compilation flags
    DIRECTORY_BITSTREAM = fpga-source-comp/ # Specify the directory
  2. Run an example, such as DFT. In the following command the device indexed by 0:3 is the FPGA emulation device:

    tornado --threadInfo --debug --jvm="-Ds0.t0.device=0:3 -Dtornado.fpga.conf.file=<mydir>/intel-fpga.conf" -m tornado.examples/uk.ac.manchester.tornado.examples.dynamic.DFTMT 1024 tornado 1

This throws the following error which is related to the HLS compilation:

ode generator Failed
    tornado.runtime@0.15.2-dev/uk.ac.manchester.tornado.runtime.TornadoVM.executeLaunch(TornadoVM.java:534)
    tornado.runtime@0.15.2-dev/uk.ac.manchester.tornado.runtime.TornadoVM.execute(TornadoVM.java:763)
    tornado.runtime@0.15.2-dev/uk.ac.manchester.tornado.runtime.TornadoVM.execute(TornadoVM.java:217)
    tornado.runtime@0.15.2-dev/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskGraph.scheduleInner(TornadoTaskGraph.java:798)
    tornado.runtime@0.15.2-dev/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskGraph.schedule(TornadoTaskGraph.java:1213)
    tornado.api@0.15.2-dev/uk.ac.manchester.tornado.api.TaskGraph.execute(TaskGraph.java:782)
    tornado.api@0.15.2-dev/uk.ac.manchester.tornado.api.ImmutableTaskGraph.execute(ImmutableTaskGraph.java:73)
    java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    tornado.api@0.15.2-dev/uk.ac.manchester.tornado.api.TornadoExecutionPlan$TornadoExecutor.execute(TornadoExecutionPlan.java:307)
    tornado.api@0.15.2-dev/uk.ac.manchester.tornado.api.TornadoExecutionPlan.execute(TornadoExecutionPlan.java:126)
    tornado.examples@0.15.2-dev/uk.ac.manchester.tornado.examples.dynamic.DFTMT.main(DFTMT.java:187)

Expected behavior

A clear and concise description of what you expected to happen.

Computing system setup (please complete the following information):


stratika commented 1 year ago

This bug is now fixed in the latest develop. I will close the issue.