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

[spirv] flag to be able to run with prev. versions of SPIR-V 1.2 #527

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

jjfumero
Copy link
Member

@jjfumero jjfumero commented Aug 9, 2024

Description

This PR adds a flag to indicate TornadoVM to use a device with SPIR-V < 1.2.
By default is 1.2, and this is the minimum required, as OpenCL Intel and Level Zero implementations requires this version of SPIR-V. However, there are other implementation (e.g., Codeplay) which supports 1.0.

Since not all the kernels will pass (e.g., not FP16), This must be explicitly enabled by the user.

The new flag: -Dtornado.spirv.version=1.2

Problem description

n/ a.

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?

Using the OneAPI Construction Kit to dispatch SPIR-V code on the CPU:

Without the new flag, we can't see the SPIR-V device for CPU from Compute Aorta:

tornado  --devices

Number of Tornado drivers: 2
Driver: SPIR-V
  Total number of SPIR-V devices  : 2
  Tornado device=0:0  (DEFAULT)
	SPIRV -- SPIRV OCL - Intel(R) HD Graphics 630
		Global Memory Size: 28.9 GB
		Local Memory Size: 64.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [256]
		Max WorkGroup Configuration: [256, 256, 256]
		Device OpenCL C version: OpenCL C 1.2

  Tornado device=0:1
	SPIRV -- SPIRV LevelZero - Intel(R) HD Graphics 630
		Global Memory Size: 28.9 GB
		Local Memory Size: 64.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [256]
		Max WorkGroup Configuration: [256, 256, 256]
		Device OpenCL C version:  (LEVEL ZERO) 1.3

Driver: OpenCL
  Total number of OpenCL devices  : 3
  Tornado device=1:0
	OPENCL --  [NVIDIA CUDA] -- NVIDIA GeForce GTX 1050
		Global Memory Size: 3.9 GB
		Local Memory Size: 48.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [1024]
		Max WorkGroup Configuration: [1024, 1024, 64]
		Device OpenCL C version: OpenCL C 1.2

  Tornado device=1:1
	OPENCL --  [Intel(R) OpenCL Graphics] -- Intel(R) HD Graphics 630
		Global Memory Size: 28.9 GB
		Local Memory Size: 64.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [256]
		Max WorkGroup Configuration: [256, 256, 256]
		Device OpenCL C version: OpenCL C 1.2

  Tornado device=1:2
	OPENCL --  [ComputeAorta] -- ComputeAorta x86_64
		Global Memory Size: 7.8 GB
		Local Memory Size: 32.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [1024]
		Max WorkGroup Configuration: [1024, 1024, 1024]
		Device OpenCL C version: OpenCL C 1.2 Clang 18.1.8

With the flag:

tornado --jvm="-Dtornado.spirv.version=1.0" --devices
WARNING: Using incubator modules: jdk.incubator.vector

Number of Tornado drivers: 2
Driver: SPIR-V
  Total number of SPIR-V devices  : 3
  Tornado device=0:0  (DEFAULT)
	SPIRV -- SPIRV OCL - Intel(R) HD Graphics 630
		Global Memory Size: 28.9 GB
		Local Memory Size: 64.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [256]
		Max WorkGroup Configuration: [256, 256, 256]
		Device OpenCL C version: OpenCL C 1.2

  Tornado device=0:1                                                                    <<<<<<<<<<<< 
	SPIRV -- SPIRV OCL - ComputeAorta x86_64
		Global Memory Size: 7.8 GB
		Local Memory Size: 32.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [1024]
		Max WorkGroup Configuration: [1024, 1024, 1024]
		Device OpenCL C version: OpenCL C 1.2 Clang 18.1.8

  Tornado device=0:2
	SPIRV -- SPIRV LevelZero - Intel(R) HD Graphics 630
		Global Memory Size: 28.9 GB
		Local Memory Size: 64.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [256]
		Max WorkGroup Configuration: [256, 256, 256]
		Device OpenCL C version:  (LEVEL ZERO) 1.3

Driver: OpenCL
  Total number of OpenCL devices  : 3
  Tornado device=1:0
	OPENCL --  [NVIDIA CUDA] -- NVIDIA GeForce GTX 1050
		Global Memory Size: 3.9 GB
		Local Memory Size: 48.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [1024]
		Max WorkGroup Configuration: [1024, 1024, 64]
		Device OpenCL C version: OpenCL C 1.2

  Tornado device=1:1
	OPENCL --  [Intel(R) OpenCL Graphics] -- Intel(R) HD Graphics 630
		Global Memory Size: 28.9 GB
		Local Memory Size: 64.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [256]
		Max WorkGroup Configuration: [256, 256, 256]
		Device OpenCL C version: OpenCL C 1.2

  Tornado device=1:2
	OPENCL --  [ComputeAorta] -- ComputeAorta x86_64
		Global Memory Size: 7.8 GB
		Local Memory Size: 32.0 KB
		Workgroup Dimensions: 3
		Total Number of Block Threads: [1024]
		Max WorkGroup Configuration: [1024, 1024, 1024]
		Device OpenCL C version: OpenCL C 1.2 Clang 18.1.8

@jjfumero jjfumero added the spirv label Aug 9, 2024
@jjfumero jjfumero self-assigned this Aug 9, 2024
Copy link
Member

@mikepapadim mikepapadim left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

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.

Added a suggestion for the documentation part. LGTM

docs/source/spirv-backend.rst Outdated Show resolved Hide resolved
@jjfumero jjfumero merged commit 35e7e55 into beehive-lab:develop Aug 12, 2024
2 checks passed
@jjfumero jjfumero deleted the feat/spirv/support branch August 12, 2024 07:12
jjfumero added a commit to jjfumero/TornadoVM that referenced this pull request Aug 30, 2024
Improvements
~~~~~~~~~~~~~~~~~~

- beehive-lab#468: Cleanup Abstract Metadata Class.
- beehive-lab#473: Add maven plugin to build TornadoVM source for the releases.
- beehive-lab#474: Refactor `<X>TornadoDevice` to place common methods in the `TornadoXPUInterface`.
- beehive-lab#482: Help messages improve when an out-of-memory exception is raised.
- beehive-lab#484: Double-type for the trigonometric functions added in the `TornadoMath` class.
- beehive-lab#487: Prebuilt API simplified.
- beehive-lab#494: Add test to trigger unsupported features related to direct use of Memory Segments.
- beehive-lab#509: Add a quick pass configuration to skip the heavy tests during active development.
- beehive-lab#532: Improve thread scheduler to support RISC-V Accelerators from Codeplay.
- beehive-lab#533: Support for scalar values to be passed via lambda expressions as tasks.
- beehive-lab#538: `README` file updated.
- beehive-lab#539: Refactor core classes and add new API methods to pass compilation flags to the low-level driver compilers (OpenCL, PTX and Level Zero).
- beehive-lab#542: Tagged LevelZero JNI and Beehive Toolkit dependencies added in the build and installer.

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

- beehive-lab#465: Support for JDK 22 and GraalVM 24.0.2.
- beehive-lab#486: Temurin for Windows added in the list of supported JDKs.
- beehive-lab#525: Revert usage of String Templates in preparation for JDK 23.
- beehive-lab#527: SPIR-V version parameter added. TornadoVM may run previous SPIR-V versions (e.g., ComputeAorta from Codeplay).
- beehive-lab#513: LevelZero JNI Library updated to v0.1.4.

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

- beehive-lab#470: README documentation fixed.
- beehive-lab#478: Fix the test names that are present in the white list.
- beehive-lab#488: FP64 Kind for radian operations and the PTX backend fixed.
- beehive-lab#493: Tests Whitelist for PTX backend fixed.
- beehive-lab#502: Fix barrier type in the documentation regarding programmability of reductions.
- beehive-lab#514: Installer script fixed.
- beehive-lab#540: Fix  issue with clean-up execution IDs function.
- beehive-lab#541: Fix Data Accessors for the prebuilt API.
- beehive-lab#543: Fix checkstyle condition and FP16 error message improved.
jjfumero added a commit to jjfumero/TornadoVM that referenced this pull request Aug 30, 2024
Improvements
~~~~~~~~~~~~~~~~~~

- beehive-lab#468: Cleanup Abstract Metadata Class.
- beehive-lab#473: Add maven plugin to build TornadoVM source for the releases.
- beehive-lab#474: Refactor `<X>TornadoDevice` to place common methods in the `TornadoXPUInterface`.
- beehive-lab#482: Help messages improved when an out-of-memory exception is raised.
- beehive-lab#484: Double-type for the trigonometric functions added in the `TornadoMath` class.
- beehive-lab#487: Prebuilt API simplified.
- beehive-lab#494: Add test to trigger unsupported features related to direct use of Memory Segments.
- beehive-lab#509: Add a quick pass configuration to skip the heavy tests during active development.
- beehive-lab#532: Improve thread scheduler to support RISC-V Accelerators from Codeplay.
- beehive-lab#533: Support for scalar values to be passed via lambda expressions as tasks.
- beehive-lab#538: `README` file updated.
- beehive-lab#539: Refactor core classes and add new API methods to pass compilation flags to the low-level driver compilers (OpenCL, PTX and Level Zero).
- beehive-lab#542: Tagged LevelZero JNI and Beehive Toolkit dependencies added in the build and installer.

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

- beehive-lab#465: Support for JDK 22 and GraalVM 24.0.2.
- beehive-lab#486: Temurin for Windows added in the list of supported JDKs.
- beehive-lab#525: Revert usage of String Templates in preparation for JDK 23.
- beehive-lab#527: SPIR-V version parameter added. TornadoVM may run previous SPIR-V versions (e.g., ComputeAorta from Codeplay).
- beehive-lab#513: LevelZero JNI Library updated to v0.1.4.

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

- beehive-lab#470: README documentation fixed.
- beehive-lab#478: Fix the test names that are present in the white list.
- beehive-lab#488: FP64 Kind for radian operations and the PTX backend fixed.
- beehive-lab#493: Tests Whitelist for PTX backend fixed.
- beehive-lab#502: Fix barrier type in the documentation regarding programmability of reductions.
- beehive-lab#514: Installer script fixed.
- beehive-lab#540: Fix  issue with clean-up execution IDs function.
- beehive-lab#541: Fix Data Accessors for the prebuilt API.
- beehive-lab#543: Fix checkstyle condition and FP16 error message improved.

minor change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

3 participants