1#include <clc/clc.h> 2 3_CLC_OVERLOAD _CLC_DEF float dot(float p0, float p1) { 4 return p0*p1; 5} 6 7_CLC_OVERLOAD _CLC_DEF float dot(float2 p0, float2 p1) { 8 return p0.x*p1.x + p0.y*p1.y; 9} 10 11_CLC_OVERLOAD _CLC_DEF float dot(float3 p0, float3 p1) { 12 return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z; 13} 14 15_CLC_OVERLOAD _CLC_DEF float dot(float4 p0, float4 p1) { 16 return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z + p0.w*p1.w; 17} 18 19#ifdef cl_khr_fp64 20 21#pragma OPENCL EXTENSION cl_khr_fp64 : enable 22 23_CLC_OVERLOAD _CLC_DEF double dot(double p0, double p1) { 24 return p0*p1; 25} 26 27_CLC_OVERLOAD _CLC_DEF double dot(double2 p0, double2 p1) { 28 return p0.x*p1.x + p0.y*p1.y; 29} 30 31_CLC_OVERLOAD _CLC_DEF double dot(double3 p0, double3 p1) { 32 return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z; 33} 34 35_CLC_OVERLOAD _CLC_DEF double dot(double4 p0, double4 p1) { 36 return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z + p0.w*p1.w; 37} 38 39#endif 40 41#ifdef cl_khr_fp16 42 43#pragma OPENCL EXTENSION cl_khr_fp16 : enable 44 45_CLC_OVERLOAD _CLC_DEF half dot(half p0, half p1) { 46 return p0*p1; 47} 48 49_CLC_OVERLOAD _CLC_DEF half dot(half2 p0, half2 p1) { 50 return p0.x*p1.x + p0.y*p1.y; 51} 52 53_CLC_OVERLOAD _CLC_DEF half dot(half3 p0, half3 p1) { 54 return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z; 55} 56 57_CLC_OVERLOAD _CLC_DEF half dot(half4 p0, half4 p1) { 58 return p0.x*p1.x + p0.y*p1.y + p0.z*p1.z + p0.w*p1.w; 59} 60 61#endif 62