Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

MKL_F16 type

zjin-lcf
Beginner
488 Views

Can you please explain if MKL_F16 is equivalent to the 16-bit floating-point type (i.e. half) ?

 

Running the example does not produce the expected output for MKL_F16.  

 

https://github.com/zjin-lcf/HeCBench/tree/master/src/blas-gemm-omp

 

Thanks

 

 

0 Kudos
1 Solution
Andrew_Barker
Employee
356 Views

The MKL_F16 datatype is defined in the public header mkl_types.h to be the same as "unsigned short" (we do some conversions internally) so when you are setting the initial matrix and alpha, beta you are not getting the numbers you expect.

The simplest way to fix this in your linked example is probably to use _Float16 as your working type:

run_gemm_example<_Float16>(m, k, n, repeat);

and then cast the pointers to MKL_F16 in the actual gemm call:

 hgemm("N", "N", &n, &m, &k, (MKL_F16*) &alpha, (MKL_F16*) b, &n, (MKL_F16*) a, &k, (MKL_F16*) &beta, (MKL_F16*) c, &n);

 

View solution in original post

0 Kudos
1 Reply
Andrew_Barker
Employee
357 Views

The MKL_F16 datatype is defined in the public header mkl_types.h to be the same as "unsigned short" (we do some conversions internally) so when you are setting the initial matrix and alpha, beta you are not getting the numbers you expect.

The simplest way to fix this in your linked example is probably to use _Float16 as your working type:

run_gemm_example<_Float16>(m, k, n, repeat);

and then cast the pointers to MKL_F16 in the actual gemm call:

 hgemm("N", "N", &n, &m, &k, (MKL_F16*) &alpha, (MKL_F16*) b, &n, (MKL_F16*) a, &k, (MKL_F16*) &beta, (MKL_F16*) c, &n);

 

0 Kudos
Reply