Fast Recompile for FPGA
- Passing the-reuse-exe=<exe_name>flag to instruct the compiler to attempt to reuse the existing FPGA device image.
- Separating the host and device code into separate files. When a code change applies only to host-only files, the FPGA device image is not regenerated.
- Separating the device code using the compiler option-fsycl-device-code-split.
# Initial compilation dpcpp -fintelfpga -Xshardware <files.cpp> -o out.fpga
# Subsequent recompilation dpcpp <files.cpp> -o out.fpga -reuse-exe=out.fpga -Xshardware -fintelfpga
- If theout.fpgafile does not exist, the-reuse-exeflag is ignored and the FPGA device image is regenerated. This is always the case the first time you compile a project.
- If theout.fpgafile is found, the compiler verifies no change that affect the FPGA device code is made since the last compilation. If no change is detected in the device code, the compiler then reuses the existing FPGA device image and recompiles only the host code. The recompilation process takes a few minutes to complete.
- If theout.fpgafile is found, but the compiler cannot prove that the FPGA device code will yield a result identical to the last compilation, a warning is printed and the FPGA device code is fully recompiled. Since the compiler checks must be conservative, spurious recompilations can sometimes occur when using the-reuse-exeflag.
Using the Device Link Method
# normal compile command dpcpp -fintelfpga -Xshardware main.cpp kernel.cpp -o link.fpga
# device link command dpcpp -fintelfpga -fsycl-link=image <input files> [options]
- Compile the device code.dpcpp -fintelfpga -Xshardware -fsycl-link=image kernel.cpp -o dev_image.aInput files must include all files that contain the device code. This step might take several hours to complete.
- Compile the host code.dpcpp -fintelfpga main.cpp -c -o host.oInput files should include all source files that contain only the host code. These files must not contain any source code that executes on the device but may contain setup and tear-down code, for example, parsing command line options and reporting results. This step takes seconds to complete.
- Create the device link.dpcpp -fintelfpga host.o dev_image.a -o fast_recompile.fpgaThis step takes seconds to complete. The input should include one or more host object files (.o) and exactly one device image file (.a). When linking a static library (.afile), always include the static library after its use. Otherwise, the library's functions are discarded. For additional information about static library linking, refer to Library order in static linking.
- : This is the default mode and same asauto-fsycl-device-code-splitwithout any value. The compiler uses a heuristic to select the best way of splitting device code.
- : Creates a single module for all kernels.off
- : Creates a separate device code module for each SYCL kernel. Each device code module contains a kernel and all its dependencies, such as called functions and used variables.per_kernel
- : Creates a separate device code module for each source (translation unit). Each device code module contains a bunch of kernels grouped on per-source basis and all their dependencies, such as all used variables and called functions, including theper_sourceSYCL_EXTERNALmacro-marked functions from other translation units.
Which Mechanism to Use?
- The compiler must spend time partially recompiling and then analyzing the device code to ensure that it is unchanged. This takes several minutes for larger designs. Compiling separate files does not incur this extra time.
- You might occasionally encounter afalse positivewhere the compiler incorrectly believes that it must recompile your device code. In a single source file, the device and host code are coupled, so certain changes to the host code can change the compiler's view of the device code. The compiler always behaves conservatively and triggers a full recompilation if it cannot prove that reusing the previous FPGA binary is safe. Compiling separate files eliminates this possibility.