Xilinx / KRS

The Kria Robotics Stack (KRS) is a ROS 2 superset for industry, an integrated set of robot libraries and utilities to accelerate the development, maintenance and commercialization of industrial-grade robotic solutions while using adaptive computing.
https://Xilinx.github.io/KRS/
Other
46 stars 18 forks source link

Document Vitis build targets #19

Open vmayoral opened 2 years ago

vmayoral commented 2 years ago

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) ```bash 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: ```bash 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](https://github.com/ros-acceleration/acceleration_examples/blob/main/accelerated_doublevadd_publisher/CMakeLists.txt#L55-L68). If after all of this, you still want to dive deeper, then the following resources will be helpful: - [KRS' *HowTo and Troubleshooting*](https://xilinx.github.io/KRS/sphinx/build/html/docs/howto.html#) (includes lots of tips about manually emulating things, as opposed to use [colcon-acceleration](https://github.com/ros-acceleration/colcon-acceleration) tooling) - [Xilinx Vitis *"Running Emulation"* documentation page (`v2020.2`)](https://www.xilinx.com/html_docs/xilinx2020_2/vitis_doc/runemulation1.html) - [Xilinx Vitis *"Debugging Applications and Kernels"* documentation page (`v2020.2`)](https://www.xilinx.com/html_docs/xilinx2020_2/vitis_doc/debuggingapplicationskernels.html) - [Xilinx Vitis *"Build Targets"* documentation page (`v2020.2`)](https://www.xilinx.com/html_docs/xilinx2020_2/vitis_doc/buildtargets1.html) ```