beehive-lab / TornadoVM

TornadoVM: A practical and efficient heterogeneous programming framework for managed languages
https://www.tornadovm.org
Apache License 2.0
1.16k stars 109 forks source link

Vector types for Float<Width> with Int<Width> supported at the API-level #425

Closed jjfumero closed 2 months ago

jjfumero commented 2 months ago

Description

This PR adds Float vector operations to be operate with Int vector types. Due to OpenCL/SPIR-V restrictions, the actual operation in native code can't be done using explicit vector types. But still it is possible to operate by accessing the individual fields of the vector.

Problem description

Example could not use vector operations because of mismatch types.

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?

Compile and run for all backends:

tornado-test --printKernel -V uk.ac.manchester.tornado.unittests.vectortypes.TestFloats
andrii0lomakin commented 2 months ago

Hi guys. Would be good also provide documentation updates.

Docs are scarce as of now and you need to guess features by inspecting the code. Not the best way for quick immersion into the project.

jjfumero commented 2 months ago

Hi @laa , thanks for your feedback. Sure, the main reason is that TornadoVM is evolving really fast now and it is driven by the 5 EU projects we are working on. But I do agree with you that the documentation can be improved.

Is there anything specific you would like to to cover first? Myself, I am preparing new tutorials on vector types, if that helps.

andrii0lomakin commented 2 months ago

@jjfumero thank you :-) That is exactly what I wanted :-)

jjfumero commented 2 months ago

In general, we should work to improve the APIs for vectors. There is no other way to initialize a vector 16 with random numbers than this at the moment:

arrayOfFloat16.set(i, new Float16(r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat(), //
                    r.nextFloat()));

The original design is given by the OpenCL/SPIR-V interfaces, but for Java we need to improve it. That's for a separate PR.