fp16 support in cuda thrust
<p>I am not able to found anything about the fp16 support in thrust cuda template library.
Even the roadmap page has nothing about it:
<a href="https://github.com/thrust/thrust/wiki/Roadmap" rel="nofollow">https://github.com/thrust/thrust/wiki/Roadmap</a></p>

<p>But I assume somebody has probably figured out how to overcome this problem, since the fp16 support in cuda is around for more than 6 month.</p>

<p>As of today, I heavily rely on thrust in my code, and templated nearly every class I use in order to ease fp16 integration, unfortunately, absolutely nothing works out of the box for half type even this simple sample code:</p>

<pre><code>//STL
#include &lt;iostream&gt;
#include &lt;cstdlib&gt;

//Cuda
#include &lt;cuda_runtime_api.h&gt;
#include &lt;thrust/device_vector.h&gt;
#include &lt;thrust/reduce.h&gt;
#include &lt;cuda_fp16.h&gt;
#define T half //work when float is used

int main(int argc, char* argv[])
{
        thrust::device_vector&lt;T&gt; a(10,1.0f);
        float t = thrust::reduce( a.cbegin(),a.cend(),(float)0);
        std::cout&lt;&lt;"test = "&lt;&lt;t&lt;&lt;std::endl;
        return EXIT_SUCCESS;
}
</code></pre>

<p>This code cannot compile because it seems that there is no implicit conversion from float to half or half to float. However, it seems that there are <a href="http://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH__INTRINSIC__CAST.html#group__CUDA__MATH__INTRINSIC__CAST" rel="nofollow">intrinsics</a> in cuda that allow for an explicit conversion.</p>

<p>Why can't I simply overload the half and float constructor in some header file in cuda, to add the previous intrinsic like that :</p>

<pre><code>float::float( half a )
{
  return  __half2float( a ) ;
}

half::half( float a )
{
  return  __float2half( a ) ;
}
</code></pre>

<p>My question may seem basic but I don't understand why I haven't found much documentation about it.</p>

<p>Thank you in advance</p>