();
std::stringbinaryFile = xcl::find_binary_file(device_name, argv[1]);
cl::Program::Binaries bins = xcl::import_binary_file(binaryFile);
devices.resize(1);
cl::Program program(context, devices, bins);
```
The workflow here can be summed up as follows:
1. Discover and number the Xilinx devices in the system. In this case we can assume device 0 is the targeted card, but in a multi-accelerator card system you will have to specify them.
2. Initialize the OpenCL context and command queues.
3. Load the binary file targeting our Alveo board. In these examples we pass the file name on the command line, but this can be hard-coded or otherwise handled on an application-specific basis.
4. Program the FPGA.
Line 44 is where the programming operation is actually triggered. During the programming phase the runtime
checks the current Alveo card configuration. If it is already programmed, we can return after loading the
device metadata from the xclbin. But if not, let's program the device now.
## Running the Application
With the XRT initialized, run the application by running the following command from the build directory:
`./00_load_kernels alveo_examples`
The program will output a message similar to this:
```
-- Example 0: Loading the FPGA Binary --
Loading XCLBin to program the Alveo board:
Found Platform
Platform Name: Xilinx
XCLBIN File Name: alveo_examples
INFO: Importing ./alveo_examples.xclbin
Loading: ?./alveo_examples.xclbin?
FPGA programmed, example complete!
-- Key execution times --
OpenCL Initialization : 1624.634 ms
```
Note that our FPGA took 1.6 seconds to initialize. Be aware of this kernel load time; it includes disk I/O, PCIe latency, configuration overhead, and a number of other operations. Usually you will want to configure the FPGA during your application's startup time, or even pre-configure it. Let's run the application again with the bitstream already loaded:
```
-- Key execution times --
OpenCL Initialization : 262.374 ms
```
0.26 seconds is much better than 1.6 seconds! We still have to read the file from disk, parse it, and ensure the xclbin loaded into the FPGA is correct, but the overall initialization time is significantly lower.
## Extra Exercises
Some things to try to build on this experiment:
1. Use the **xbutil** utility to query the board. Can you see which .xclbin file is loaded?
2. Again using **xbutil**, which kernel(s) are present in the FPGA? Do you see a difference before and after t
the FPGA is programmed?
## Key Takeaways
- FPGA configuration is an expensive operation. Ideally, initialize the FPGA long before it's needed. This
can be done in a separate thread, during other initialization tasks in your application, or even at system
boot time for dedicated systems.
- Once the FPGA is loaded, subsequent loads are substantially faster.
- Now that we can load images into the FPGA, let's run something!
Read [**Example 1:** Simple Memory Allocation](./01-simple-memory-allocation.md)
Copyright© 2019-2021 Xilinx