cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
329 Views
Registered: ‎10-18-2019

Does the vitis C++ kernel allow a return value

Jump to solution

I want to know if the acceleration kernel top function allows for a return value and how to use xilinx XRT to get this return value. 

0 Kudos
1 Solution

Accepted Solutions
kmorris
Xilinx Employee
Xilinx Employee
169 Views
Registered: ‎01-11-2011

Thanks for clarifying your scenario. While the host code can have return values, the OpenCL kernels are void functions meaning they can't have return values, and therefore need the data passed through its arguments. You will need to modify your kernel to send the processed data via another argument instead of using a return value.

-------------------------------------------------------------------------
Please don’t forget to reply, kudo, and accept as solution!
-------------------------------------------------------------------------

View solution in original post

0 Kudos
3 Replies
kmorris
Xilinx Employee
Xilinx Employee
252 Views
Registered: ‎01-11-2011

I am not sure of a situation where XRT needs to read the return value but it should be up to the user host code to read back the return value of the kernel and then process it, so any return value should be acceptable.

-------------------------------------------------------------------------
Please don’t forget to reply, kudo, and accept as solution!
-------------------------------------------------------------------------
197 Views
Registered: ‎10-18-2019

Thanks for replying. Specifically,I have a c++ kernel prototype like this :

 

/**
 *@brief c++ kernel top function with a returned valur
 *@param[in] m00_axi
 *@param[in] m01_axi
 *@param[in] scalar_0
 */
float Function ( volatile float* m00_axi ,volatile float* m01_axi , uint32_t scalar_0 )
{
	// read data , processing , get result
	float score = ...;
	// return result

	return score;
}

 

 

I have added this kernel to Vitis project, and I am writing host code referring to the vadd example. Vitis uses OpenCL as the software interface, so I use cl: Buffer to allocate the cache used by the accelerator, and configure all the parameters like below.

 

int narg=0;
krnl_Function .setArg(narg++,buffer_m00_axi );
krnl_Function .setArg(narg++,buffer_m00_axi );
krnl_Function .setArg(narg++,scalar_0 );

 

As shown in the Function above , the returned score is not in the parameter list of the function, how do I get the return value using OpenCL API, or OpenCL only support the return value of the top-level function is void ?

0 Kudos
kmorris
Xilinx Employee
Xilinx Employee
170 Views
Registered: ‎01-11-2011

Thanks for clarifying your scenario. While the host code can have return values, the OpenCL kernels are void functions meaning they can't have return values, and therefore need the data passed through its arguments. You will need to modify your kernel to send the processed data via another argument instead of using a return value.

-------------------------------------------------------------------------
Please don’t forget to reply, kudo, and accept as solution!
-------------------------------------------------------------------------

View solution in original post

0 Kudos