cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

i_alex2004
Journeyman III

How to use mangled name of templated kernel, specified in custom namespace?

The problem is: when I use Static C++ OpenCL kernel extension I give mangled names to variants of templated kernel, e.g:


template<typename T>

__kernel void vec_add(__global T *A, __global T *B,  __global T *C)

{

   int idx = get_global_id(o);

   C[idx] = A[idx] + B[idx];

}


template __attribute__((mangled_name(vec_add_int)))

__kernel void vec_add(__global int * A, __global int * B, __global int * C);

}

But if I place it into a cstom namespace as shown below:


namespace my_vec_add_namespace {

template<typename T>

__kernel void vec_add(__global T *A, __global T *B,  __global T *C)

{

   int idx = get_global_id(o);

   C[idx] = A[idx] + B[idx];

}


template __attribute__((mangled_name(vec_add_int)))

__kernel void vec_add(__global int * A, __global int * B, __global int * C);

}

The compiler doesn't see "vec_add_int" kernel during online compilation.

How to use it properly?

0 Likes
3 Replies
jtrudeau
Staff

I'm pursuing with a couple of compiler engineers, to see if this is supported. Didn't want you to think you were being ignored, but I don't have an answer yet. Apologies for the delay, I was out for a little bit.

jtrudeau
Staff

I don't think I'm going to get a definitive answer. But I do same some information.

1: This looks like an unsupported use case within the static C++ extension

2: The recommendation is to avoid using this extension if possible, in general.

This is legacy code and not updated to cover changes in OpenCL (e.g. OpenCL 2.0 features). I'll make a personal prediction (just based on experience) that at some point it will be officially deprecated as the language changes further. To the best of my knowledge there are no official plans or roadmap to do so, but I've seen this kind of thing happen often.

For example, OpenCL 2.1 is coming. Per the Khronos site... will have "New C++ kernel language based on C++14 for significantly enhanced programmer productivity and performance portability with clean, re-usable code"

OpenCL - The open standard for parallel programming of heterogeneous systems

Well that sounds a bit like marketing to me, but just to make the point that the landscape is changing, and this extension is not.

Thank you a lot for this information. It doesn't really matter for me which extension to use, so if there will be a new one, I guess my C++ code will work with it anyway. Maybe I'm missing something, but for now static C++ extension is the only one working with C++?

0 Likes