beehive-lab / TornadoVM

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

Enable MTMD behaviour on device selection as part of the TornadoVM `TaskGraph` API #311

Closed mikepapadim closed 7 months ago

mikepapadim commented 8 months ago

Description

This is @jjfumero work on enabling MTMD behaviour through the Taskgraph API.

This PR enables device selection as part of the API instead of command line arguments which is currently supported. It allows to run multiple tasks on multiple devices, single or multi-threaded as part of the standard ExecutionPlan in TornadoVM. It introduces the withConcurrentDevices and withoutConcurrentDevices calls as an extension to the original withDevice API call.

Example usage with concurrent execution:

TornadoDevice device0 = TornadoRuntime.getTornadoRuntime().getDriver(0).getDevice(0);
TornadoDevice device1 = TornadoRuntime.getTornadoRuntime().getDriver(0).getDevice(1);

 // Extension for multi-device: This will run one task after the other in  parallel
  executionPlan.withConcurrentDevices() //
          .withDevice("graph.task0", device0) //
          .withDevice("graph.task1", device1);

  // Blocking call
  executionPlan.execute();

Example usage with serial execution:

TornadoDevice device0 = TornadoRuntime.getTornadoRuntime().getDriver(0).getDevice(0);
TornadoDevice device1 = TornadoRuntime.getTornadoRuntime().getDriver(0).getDevice(1);

// Extension for multi-device: This will run one task after the other in parallel
executionPlan.withoutConcurrentDevices() //
        .withDevice("graph.task0", device0) //
        .withDevice("graph.task1", device1);

// Blocking call
executionPlan.execute();

Note: Previous behaviour available from the command line:

 tornado-test -V --fullDebug --debug --printBytecodes 
--jvm=
           -Ds0.t0.device=0:0 
           -Ds0.t1.device=1:0 
           -Ds0.t2.device=2:0  
uk.ac.manchester.tornado.unittests.vm.concurrency.TestConcurrentBackends

Backend/s tested

Mark the backends affected by this PR.

OS tested

Mark the OS where this PR is tested.

How to test the new patch?

make
tornado-test -V --printBytecode --threadInfo uk.ac.manchester.tornado.unittests.vm.concurrency.TestParallelTaskGraph

mikepapadim commented 7 months ago

LGTM. @mikepapadim , just revert the Backend priority values to the previous state.

This is fixed now