Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

Are templates in OpenCL Kernels supported somehow

I am installing Caffe but want to use FPGA acceleration instead of GPU. However, I get an error when compiling.

I am assuming that Altera's aoc doesn't handle templates (yet).

Anyway around this? templates coming soon? already there but "template __attribute"

template <class T>

__kernel void BNLLForward(const int n, __global const T* in, __global T* out) {

int index = get_global_id(0);

if (index < n) {

out[index] = in[index] > 0 ? in[index] + log(1. + exp(-in[index])) : log(1. + exp(in[index]));

}

}

template __attribute__((mangled_name(BNLLForward_float))) __kernel void BNLLForward(const int n, __global const float* in, __global float* out);

template __attribute__((mangled_name(BNLLForward_double))) __kernel void BNLLForward(const int n, __global const double* in, __global double* out);

========yields the following errors==========

/home/poz/altera/Caffe/OpenCL-caffe-stable/src/caffe/ocl/bnll_layer.cl:29:1: error: unknown type name 'template'

template <class T>

^

/home/poz/altera/Caffe/OpenCL-caffe-stable/src/caffe/ocl/bnll_layer.cl:37:1: error: unknown type name 'template'

template __attribute__((mangled_name(BNLLForward_double))) __kernel void BNLLForward(const int n, __global const double* in, __global double* out);

^

Thanks in advance (I hope)

Dan..
No RepliesBe the first to reply