beehive-lab / TornadoVM

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

[fix][spirv] Reset LocalWorkSize when the device is changed #346

Closed jjfumero closed 5 months ago

jjfumero commented 5 months ago

Description

This PR solves the problem of getting the wrong local work group sizes when the device is changed from the CPU using the OpenCL backend to the GPU using the SPIR-V backend.

Problem description

The problem was that, in the SPIR-V backend, once the number of blocks is computed, is then stored in the TaskMetaData object. However, while the global work size for the same task will not change, there is no guarantee that the local work group size is the same. This patch solves the issue by resetting the local work size only when the device is updated.

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?

The use case for this is the task-migration in Client/Server setup:

https://github.com/jjfumero/tornadovm-examples?tab=readme-ov-file#live-task-migration-client-server-app

## Run Server in one terminal
./runServer.sh

## Client in another terminal
./runClient.sh  ## Change device during runtime 

## Note: the application selects the backend 0:0 (default backend)

# type different <backend:deviceNumber> version from the client. 
# Examples:
# 0:1 
# 1:0 
## etc