Closed mairooni closed 7 months ago
Unit-test are passing for SPIR-V and PTX. For OpenCL, depending on the device, this passes.
In my case, using RTX 2060 and the NVIDIA Drivers 510.54 do not pass.
I included a function that checks if FP16 is supported. However, since on my machine I do not have this capability but I can pass the tests for OpenCL, we decided with @jjfumero to keep the printing of the OpenCL pragma for the time being, regardless of whether it is supported, until we figure out why this is happening.
Yes, we can query the capability. The pragma can always be generated. We need to investigate how to run OpenCL FP16 on modern NVIDIA GPUs.
Ok, lets merge it then and we can iterate for a fix in codegen when they add the extension in the driver
It appears a new conflict. @mairooni, can you take a look?
Description
This PR provides support for half-float types, i.e. float values represented by 16 bits instead of 32. Since Java does not currently offer a half-float type, in this implementation it is represented by a new class,
HalfFloat
. TheHalfFloat
class offers two constructors. The first receives a float value, which is internally converted to float-16, using theFloat.floatToFloat16
function. The second directly receives a short value, which represents a half-float. TheHalfFloat
class exposes a set of operations that can be performed between half-float values, specifically addition, subtraction, multiplication, and division.Finally, a new off-heap array type for half-float values (
HalfFloatArray
class) has been included.Backend/s tested
Mark the backends affected by this PR.
OS tested
Mark the OS where this PR is tested.
Did you check on FPGAs?
If it is applicable, check your changes on FPGAs.
How to test the new patch?
Tests have been added for the following scenarios:
1) Initialization of a new
HalfFloat
instance in the kernel:tornado-test -V uk.ac.manchester.tornado.unittests.arrays.TestArrays#testHalfFloatInitialization
2) Addition of two HalfFloatArrays:tornado-test -V uk.ac.manchester.tornado.unittests.arrays.TestArrays#testVectorAdditionHalfFloat
3) Subtraction of two HalfFloatArrays:tornado-test -V uk.ac.manchester.tornado.unittests.arrays.TestArrays#testVectorSubtractionHalfFloat
4) Multiplication of two HalfFloatArrays:tornado-test -V uk.ac.manchester.tornado.unittests.arrays.TestArrays#testVectorMultiplicationHalfFloat
5) Division between two HalfFloatArrays:tornado-test -V uk.ac.manchester.tornado.unittests.arrays.TestArrays#testVectorDivisionHalfFloat
6) Test thefromElements
andfromArray
functions of theHalfFloatArray
class:tornado-test -V uk.ac.manchester.tornado.unittests.api.TestAPI#testSegmentsHalfFloats
7) Test thefromSegment
function of theHalfFloatArray
class:tornado-test -V uk.ac.manchester.tornado.unittests.api.TestAPI#testBuildWithSegmentsHalfFloat