Why does cuda_fp16.h/hpp require nv/target ? What does that file do?

I’m trying to build some code involving half-precision floating point types, so I’m including cuda_fp16.hpp. Since CUDA 12.0, that file seems to include nv/target - a rather weird file that doesn’t seem very related to half-precision floats.

What’s the deal with this file, and why is its inclusion required?

nv/target is the modern way to conditionally enable code on specific architectures.

@striker159 :

  1. Can you link to someplace which elaborates on that?
  2. So, why would I want that to be included via cuda_fp16.hpp rather than directly by me?

I do not know if there is some official document about it but nvidia libraries on github are in the progess of incorporating it for quite a while. for example,

In your case, it is used to switch between host implementation and device implementation, for example in __double2half

But the thing is, it doesn’t seem like cuda_fp16.hpp is really dependent on stuff from nv/target. So this is again somewhat mysterious.

On a semi-related note:

Add libcu++ dependency; initial round of NV_IF_TARGET ports.

That seems rather misguided. libcu++ is supposed to be a complete alternative C++ standard library. I would not want to drag all of it in just to use some kernel from CUB.

Eventually, Thrust, cub and libcu++ will be one big library anyways.