Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 16, 2024

Conversation

jjfumero
Copy link
Member

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.

  • OpenCL
  • PTX
  • SPIRV

OS tested

Mark the OS where this PR is tested.

  • Linux
  • OSx
  • Windows

Did you check on FPGAs?

If it is applicable, check your changes on FPGAs.

  • Yes
  • No

How to test the new patch?

Compile and run for all backends:

tornado-test --printKernel -V uk.ac.manchester.tornado.unittests.vectortypes.TestFloats

Copy link
Collaborator

@mairooni mairooni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrii0lomakin
Copy link
Contributor

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
Copy link
Member Author

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
Copy link
Contributor

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


for (int x = 0; x < b.getLength(); x++) {
a.set(x, new Float16(x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x));
b.set(x, new Int16(0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a suggestion for the initialization of the tested vectors. I would suggest to use different values for each field of the vectors, in order to ensure that indexing is correct and we do not have any accidental matches. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this particular case it will have the same effect, because other tests already check with different values, but we can add random values instead.

@jjfumero
Copy link
Member Author

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.

Copy link
Collaborator

@stratika stratika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I tested also on Apple M1. LGTM.

@jjfumero jjfumero merged commit 3cac211 into beehive-lab:develop May 16, 2024
2 checks passed
@jjfumero jjfumero deleted the feat/vectors/mixedtypes branch May 16, 2024 12:45
@jjfumero jjfumero changed the title Vector types for Float<With> with Int<Width> supported at the API-level Vector types for Float<Width> with Int<Width> supported at the API-level May 27, 2024
jjfumero added a commit to jjfumero/TornadoVM that referenced this pull request May 28, 2024
Improvements
~~~~~~~~~~~~~~~~~~

- beehive-lab#402 <beehive-lab#402>: Support for TornadoNativeArrays from FFI buffers.
- beehive-lab#403 <beehive-lab#403>: Clean-up and refactoring for the code analysis of the loop-interchange.
- beehive-lab#405 <beehive-lab#405>: Disable Loop-Interchange for CPU offloading..
- beehive-lab#407 <beehive-lab#407>: Debugging OpenCL Kernels builds improved.
- beehive-lab#410 <beehive-lab#410>: CPU block scheduler disabled by default and option to switch between different thread-schedulers added.
- beehive-lab#418 <beehive-lab#418>: TornadoOptions and TornadoLogger improved.
- beehive-lab#423 <beehive-lab#423>: MxM using ns instead of ms to report performance.
- beehive-lab#425 <beehive-lab#425>: Vector types for ``Float<Width>`` and ``Int<Width>`` supported.
- beehive-lab#429 <beehive-lab#429>: Documentation of the installation process updated and improved.
- beehive-lab#432 <beehive-lab#432>: Support for SPIR-V code generation and dispatcher using the TornadoVM OpenCL runtime.

Compatibility
~~~~~~~~~~~~~~~~~~

- beehive-lab#409 <beehive-lab#409>: Guidelines to build the documentation.
- beehive-lab#411 <beehive-lab#411>: Windows installer improved.
- beehive-lab#412 <beehive-lab#412>: Python installer improved to check download all Python dependencies before the main installer.
- beehive-lab#413 <beehive-lab#413>: Improved documentation for installing all configurations of backends and OS.
- beehive-lab#424 <beehive-lab#424>: Use Generic GPU Scheduler for some older NVIDIA Drivers for the OpenCL runtime.
- beehive-lab#430 <beehive-lab#430>: Improved the installer by checking  that the TornadoVM environment is loaded upfront.

Bug Fixes
~~~~~~~~~~~~~~~~~~

- beehive-lab#400 <beehive-lab#400>: Fix batch computation when the global thread indexes are used to compute the outputs.
- beehive-lab#414 <beehive-lab#414>: Recover Test-Field unit-tests using Panama types.
- beehive-lab#415 <beehive-lab#415>: Check style errors fixed.
- beehive-lab#416 <beehive-lab#416>: FPGA execution with multiple tasks in a task-graph fixed.
- beehive-lab#417 <beehive-lab#417>: Lazy-copy out fixed for Java fields.
- beehive-lab#420 <beehive-lab#420>: Fix Mandelbrot example.
- beehive-lab#421 <beehive-lab#421>: OpenCL 2D thread-scheduler fixed for NVIDIA GPUs.
- beehive-lab#422 <beehive-lab#422>: Compilation for NVIDIA Jetson Nano fixed.
- beehive-lab#426 <beehive-lab#426>: Fix Logger for all backends.
- beehive-lab#428 <beehive-lab#428>: Math cos/sin operations supported for vector types.
- beehive-lab#431 <beehive-lab#431>: Jenkins files fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants