C++ support of _Float16

999 Views Asked by At

I want to do half-precision floating-point computations on Jetson AGX Xavier(with armv8.2 architecture) which supports half-precision floating-point natively. As _Float16 data type is an arithmetic data type for half-precision floating-point, I wrote the following example:

#include <stdio.h>
#include <math.h>


int main()
{

  _Float16 x = 38808.5;
  _Float16 y = 33096;
  _Float16 res;

  res=333.75*y*y*y*y*y*y+4*x*x*(11*4*x*x*y*y-y*y*y*y*y*y-121*y*y*y*y-2.0)   
    +5.5*y*y*y*y*y*y*y*y+2*x/(2*y);

  printf("%e\n", (double)res);
   return 0;
}

Using gcc-7 I can successfully compile and run it but with g++-7 I got the error:

‘_Float16’ was not declared in this scope

According to this reference, it seems the _Float16 is not supported by C++. I was wondering is there any alternative for using _Float16 data type in C++?

0

There are 0 best solutions below