Scheduler

Generates test scheduler assembly code for coordinating test execution. Manages test sequencing, randomization, and synchronization across single or multiple harts. Supports barriers, mutexes, and both sequential and parallel execution modes.

Scheduler Privilege Mode

The scheduler always runs in Machine mode (M-mode). This ensures consistent behavior regardless of the test’s privilege mode and allows the scheduler to:

  • Set up trap handlers for any privilege mode

  • Switch test execution to the target privilege mode (M, S, U, or VU) via mret

  • Handle test completion and dispatch the next test

API

The Scheduler code is generated by the riescue.dtest_framework.runtime.scheduler.Scheduler class. It generates a few public routines that can be called by other Runtime components.

scheduler__init:

scheduler__dispatch:

scheduler__execute_test:

scheduler__finished:

scheduler__init

Initializes the scheduler. This is called once at the start of the test by the Loader and runs the test_setup routine.

scheduler__dispatch

Loads a0 with the next test address. This is called after the end of each discrete test.

scheduler__execute_test

Executes the test. This is called after the test is loaded into a0 by the scheduler__dispatch routine. It jumps to the test address in a0.

scheduler__finished

Final routine of the scheduler. This is called at the end of the test and runs the test_cleanup routine and returns to the EOT

Hart Context

The scheduler assumes that the Hart Context is set into the tp register before scheduler__init and scheduler_dispatch. Schedulers can use Variables registered in the Hart Context for scheduling. This helps to avoid referencing the hartid and calculating offsets for hart-local variables.

When executing the test, scheduler__execute_test will need to save the Hart Context before jumping to the test.

Whent the test has finished correctly, scheduler__finished should not stash the Hart Context so that the EOT can make use of it.

This flow is described in the diagram below:

../../_images/hart_context.png

Scheduler Modes:

The scheduler supports different modes for scheduling tests: - single hart (DefaultScheduler): tests are scheduled for repeat_times number of times - Parallel MP (ParallelScheduler): All harts run different tests in parallel with no sync before running - Simulataneous MP (SimultaneousScheduler): All harts run the same test in parallel, with a sync barrier before starting the test - Linux mode (LinuxScheduler): Tests are scheduled for repeat_times number of times, with runtime randomization

DefaultScheduler

This is the default scheduler mode used for single hart tests. Tests are scheduled for repeat_times number of times.

ParallelScheduler

This is a multiprocessor mode that schedules tests so that no two tests are ran at the same time by different harts. Tests for this scheduler can be written indepedently as the harts will never be runnign the same test.

There’s a couple scheduling modes for this scheduler, configured with parallel_scheduling_mode:

  • ROUND_ROBIN: All tests are ran repeat_times number of times, but each hart has an independent set of tests to run.

  • EXHAUSTIVE: All harts run all tests repeat_times number of times.

SimultaneousScheduler

is a special mode that is used to schedule tests for repeat_times number of times, with runtime randomization.

LinuxScheduler

Linux is a special mode that is used to schedule tests for repeat_times number of times, with runtime randomization.

Configuration

  • force_alignment: Align all instructions on 8-byte boundary

  • num_cpus: Number of harts for multiprocessor mode

  • priv_mode: Privilege mode for test execution

  • repeat_times: Number of times to repeat each test (-1 for Linux mode runtime randomization)

  • linux_mode: Enable Linux scheduler mode with runtime randomization

  • parallel_scheduling_mode: Scheduling mode for parallel MP (ROUND_ROBIN or EXHAUSTIVE)