Skip to content
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

Document Vitis build targets #19

Open
vmayoral opened this issue Oct 21, 2021 · 0 comments
Open

Document Vitis build targets #19

vmayoral opened this issue Oct 21, 2021 · 0 comments

Comments

@vmayoral
Copy link
Contributor

vmayoral commented Oct 21, 2021

Add to the documentation a subsection (possibily within the Features section) that speaks about the different build targets that are available in KRS.

A first community answer was given at https://discourse.ros.org/t/simplifying-ros-2-embedded-flows-with-colcon-extensions/22761/3. Use this as a reference. Leaving below source code in Markdown in case it's useful in the future:

source code (Markdown)
The best example I know to get started is [this one](https://xilinx.github.io/KRS/sphinx/build/html/docs/examples/1_hello_xilinx.html#launch-hello-xilinx-example-in-an-emulated-kv260). I would recommend, nevertheless, to look at all those examples in order, as they were built so that people could dive into this incrementally:

0. [ROS 2 publisher](https://xilinx.github.io/KRS/sphinx/build/html/docs/examples/0_ros2_publisher.html)
1. [Hello Xilinx](https://xilinx.github.io/KRS/sphinx/build/html/docs/examples/1_hello_xilinx.html) (here's the first intro to the use of emulation for hardware)
2. [HLS in ROS 2](https://xilinx.github.io/KRS/sphinx/build/html/docs/examples/2_hls_ros2.html)
3. [Offloading a ROS 2 publisher](https://xilinx.github.io/KRS/sphinx/build/html/docs/examples/3_offloading_ros2_publisher.html)
4. [Accelerated ROS 2 publisher](https://xilinx.github.io/KRS/sphinx/build/html/docs/examples/4_accelerated_ros2_publisher.html)
5. [Faster ROS 2 publisher](https://xilinx.github.io/KRS/sphinx/build/html/docs/examples/5_faster_ros2_publisher.html)

You can run all the examples in emulation, instead of with the real hardware. Note that Xilinx offers three build targets for its Vitis compiler (`v++`), the first two leverage emulation (QEMU):

* **Software Emulation** ( `sw_emu` ): The kernel code is compiled to run on the host processor. This allows iterative algorithm refinement through fast build-and-run loops. This target is useful for identifying syntax errors, performing source-level debugging of the kernel code running together with application, and verifying the behavior of the system. *Simply put, a transformation which runs all the code in an emulated processor matching the K26 SOM, as if there wasn’t any accelerator* .
* **Hardware Emulation** ( `hw_emu` ) - The kernel code is compiled into a hardware model (RTL), which is run in a dedicated simulator. This build-and-run loop takes longer but provides a detailed, cycle-accurate view of kernel activity. This target is useful for testing the functionality of the logic that will go in the FPGA and getting initial performance estimates. *In other words, a simulation within an emulation. The FPGA is simulated and runs inside of an emulation (QEMU), sitting together to emulated processors and allowing to get performance estimations faster* .
* **Hardware** ( `hw` ) - The kernel code is compiled into a hardware model (RTL) and then implemented on the FPGA, resulting in a binary that will run on the actual FPGA.

Note the `emulation` verb above allows you to do this directly from the colcon extensions contributed:

```bash
colcon acceleration emulation -h
usage: colcon acceleration emulation [-h] [--no-install] [--mixin-files [FILE [FILE ...]]]
                                     [--mixin [mixin1 [mixin2 ...]]]
                                     [emulation_type] [install_dir]

Manage emulation capabilities.
Vitis offers two emulation targets for development, debugging and validation purposes.

positional arguments:
  emulation_type        Emulation of board with either PL software simulation ("sw_emu" key) or
                        PL software emulation ("hw_emu" key).
  install_dir           relative path to the workspace directory to deploy in emulation
                        (typically 'install-*').

optional arguments:
  -h, --help            show this help message and exit
  --no-install          Do not copy install_dir (or default) to second partition

Mixin predefined sets of command line parameters:
  --mixin-files [FILE [FILE ...]]
                        Additional files providing mixins
  --mixin [mixin1 [mixin2 ...]]
                        No mixins are available for this verb

In other words, you can do something like:

colcon acceleration emulation sw_emu  # for sw_emu
# or
colcon acceleration emulation hw_emu  # for hw_emu

Of course, for kernels to be run in this emulated environments, you need to build them with the right flags. This is simplified and integrated into the ament extensions proposed. You can configure this directly in the kernel definition within the CMakeLists.txt of each ROS 2 package. See this example.

If after all of this, you still want to dive deeper, then the following resources will be helpful:


</details>
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

No branches or pull requests

1 participant