How Can I use operator overload when using nvrtc for JIT compiling?

hi guys, i had a question about jit compiling in cuda.
how can i use operator overload when using nvrtc?? i used like this but it’s wrong:

std::string source =     "  \n\
__device__ __inline__ float4 operator+(const float4& a, const float4& b){...} // defination here is illegal.  \n\

extern “C” global \n
void add(float4 *x, float4 *y, float4 *out) \n
{ \n
size_t tid = threadIdx.x; \n
float4 dst; \n
dst = x[tid] + y[tid]; // WRONG: float4 + float4 not supported.\n
out[tid] = dst; \n
} \n";

nvrtc compilation doesn’t include many of the automatic “includes” that you get with nvcc.

float4 is not a built-in type in any C-style language. When compiling with nvcc, it is provided via automatic inclusion of vector_types.h (from header files e.g. in /usr/local/cuda/include).

So you don’t get that automatic definition when using nvrtc. I can think of 2 possible approaches:

  1. provide a struct definitinon of float4 in your code

or

  1. use a methodology like jitify to provide includes

As an aside, when posting code here, please use a proper method.

An example proper method is to select the code in the edit window, then click the </> button at the top of the edit window, before saving your edits. My suggestion is to use this instead of placing a > at the beginning of each line (which is used to indicate an excerpted quotation).

If you would still like help, please provide a complete example demonstrating what you have done already.