Pausing the host program can be accomplished through the
use of a pause, or wait step in the code, such as the wait_for_enter
function used in the
RTL Kernel example on
GitHub. The function is defined in the src/host.cpp
code as follows:
void wait_for_enter(const std::string &msg) {
std::cout << msg << std::endl;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
The wait_for_enter
function is used in the main
function as follows:
....
std::string binaryFile = xcl::find_binary_file(device_name,"vadd");
cl::Program::Binaries bins = xcl::import_binary_file(binaryFile);
devices.resize(1);
cl::Program program(context, devices, bins);
cl::Kernel krnl_vadd(program,"krnl_vadd_rtl");
wait_for_enter("\nPress ENTER to continue after setting up ILA trigger...");
//Allocate Buffer in Global Memory
std::vector<cl::Memory> inBufVec, outBufVec;
cl::Buffer buffer_r1(context,CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY,
vector_size_bytes, source_input1.data());
...
//Copy input data to device global memory
q.enqueueMigrateMemObjects(inBufVec,0/* 0 means from host*/);
//Set the Kernel Arguments
...
//Launch the Kernel
q.enqueueTask(krnl_vadd);
The use of the wait_for_enter
function pauses the host program to
give you time to set up the required ILA triggers and prepare to
capture data from the kernel. After the Vivado hardware manager is set up and configured,
press Enter
to continue running the
application.
- For C++ host code, add a pause after the
creation of the
cl::Kernel
object, as shown in the example above. - For C-language host code, add a pause after the
clCreateKernel()
function call: