Kernels with Namespaces - 2021.2 English

Vitis Model Composer User Guide (UG1483)

Document ID
UG1483
Release Date
2021-10-22
Version
2021.2 English

Model Composer supports importing kernels declared in a namespace. For both templatized and non-templatized kernels you need to qualify the kernel function with the namespace.

Consider the following examples where the non-templatized kernel function is qualified with the namespace ns1 and templatized kernel function is qualified with the namespace ns2.

Kernel.h

namespace ns1 {
void myFunc_1(input_stream<int32> * restrict i1,
            output_stream<int32> * restrict o1);
} // namespace ns1

templateKernel.h

namespace ns2 {
template<typename T,int size>
void myFunc_2(input_stream<int32> * restrict i1,
            output_stream<int32> * restrict o1);
} // namespace ns2

To import the above functions using the AIE Kernel and AIE Template Kernel blocks, the Kernel functio' parameter in the GUI block parameters should be updated as follows:

Kernel Function
ns1::myFunc_1 (Non -templatized function)
Kernel Function
ns2::myFunc _2 (Templatized function)

If you have a class kernel declared in a namespace, then only the kernel class field should be qualified, and not the kernel function.

For example, consider the following kernel class which is qualified with the namespace ns3.

class_kernel.h

namespace ns3 {
#include "adf.h"
  
class simple_class
{
private:
    int16 val;
    int16 numSamples;
  
public:
    simple_class();
 
    void func_q(input_window_int16* in, output_window_int16* out);
      
    static void registerKernelClass()
    {      
        REGISTER_FUNCTION(simple_class::func_q);
    }
};
} // namespace ns3

To Import the kernel function func_q as a block, the Kernel Class and Kernel function parameters in the AIE Class Kernel block should be updated as follows:

Kernel class
ns3::simple_class
Kernel function
s
func_q