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

[feat] Dynanically enable the profiler after the first execution #334

Closed jjfumero closed 6 months ago

jjfumero commented 6 months ago

Description

It should be possible to enable the profiler after the TornadoVM Execution Plans runs the first iteration. There was an issue with the profiler that was preventing the profiler from being registered if it was not enabled in the first iteration. This commit fixes and enables the profiler at any point during runtime via the execution plan.

Example:

TornadoExecutionPlan executionPlan = new TornadoExecutionPlan(taskGraph.snapshot());
// Runs without the profiler
executionPlan.execute();

// enable the profiler
TornadoExecutionResult executionResult = executionPlan.withProfiler(ProfilerMode.SILENT)
             .execute();

// Query timers from the profiler
executionResult.getProfilerResult().getDeviceKernelTime();

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?

$ make
$ tornado-test -V -f  uk.ac.manchester.tornado.unittests.profiler.TestProfiler