3

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++?

Sooora
  • 171
  • 9
  • 1
    The type you'll be looking for is `__fp16` which is available when compiling with the `-mfp16-format`. See also [GCC Half precision](https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html). In the linked question pay attention to the answer of @phuclv – Pixelchemist Mar 10 '20 at 22:08
  • 1
    @Pixelchemist But __fp16 is storage format only. and I want to use the arithmetic format. – Sooora Mar 11 '20 at 08:53

0 Answers0