I am trying to use half2, but I run into an error, namely,
error: class "__half2" has no member "y"
The section of code where the error occurs is as follows:
uint8_t V_ [128]; // some elements (uint8), to save space
float V_C[128]; // storing the diff to use later
half2 *C_ = C.elements; // D halfs stored as half2, to be read
Cvalue = 0.0;
for (d = 0; d < D; d+=2)
{
V_C [d ] = V_[d] - __half2float(C_[d/2].x) ;
V_C [d+1] = V_[d+1] - __half2float(C_[d/2].y) ;
Cvalue += V_C [d] * V_C [d] ;
Cvalue += V_C [d+1] * V_C [d+1];
}
Any help please?
Update: Thank you for your help! I finally used the following...
uint8_t V_ [128] ;
float V_C[128] ;
const half2 *C_ = C.elements;
Cvalue = 0.0;
float2 temp_;
for (d = 0; d < D; d+=2)
{
temp_ = __half22float2(C_[d/2]);
V_C [d ] = V_[d] - temp_.x ;
V_C [d+1] = V_[d+1] - temp_.y ;
Cvalue += V_C [d] * V_C [d] ;
Cvalue += V_C [d+1] * V_C [d+1];
}
I got a slight speedup in my particular application, as loads from global memory was the bottleneck...