Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption...

32
Motivating preemptive GPU scheduling for real-time systems (...and the need for better models) Roy Spliet ([email protected]) Computer Laboratory University of Cambridge

Transcript of Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption...

Page 1: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Motivating preemptive GPU scheduling for real-timesystems (. . .and the need for better models)

Roy Spliet ([email protected])

Computer LaboratoryUniversity of Cambridge

Page 2: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Contents

Real-time systems

Preemptive task scheduling on GPUs

The need for better models

Conclusion

2 of 22

Page 3: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Real-time systems - Use-case

Figure: c©Bosch

3 of 22

Page 4: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Real-time systems

Primary concern is bound latency.Then we also care about performance, power consumption...

4 of 22

Page 5: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Real-time systems

I WCET: Worst-case execution time.

I WCRT: Worst-case response time.→ WCET + maximum blocking time

t

T2

T1

5 of 22

Page 6: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Real-time systems

I WCET: Worst-case execution time.

I WCRT: Worst-case response time.→ WCET + maximum blocking time

t

T2

T1

Exec. time(T2)

5 of 22

Page 7: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Real-time systems

I WCET: Worst-case execution time.

I WCRT: Worst-case response time.→ WCET + maximum blocking time

t

T2

T1

Exec. time(T2)

Response time(T2)

5 of 22

Page 8: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Real-time systems - sporadic task model

System: set of tasks Ti = {Ci ,Di ,Pi}

Ci : Cost, WCET.

Di : Deadline.

Pi : Period, minimum interval between successive job releases.

Utilisation of a “task set”:

U =n∑

i=0

Ci

Pi

6 of 22

Page 9: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Real-time systems - schedulability

Given a set of tasks {T1..Tn}, a scheduling method (fixed-priority,earliest-deadline first) and its parameters, can all tasks be guaranteedto always make their deadline?

Or: for every task in a task set, is the WCRT smaller than its deadline?

7 of 22

Page 10: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling

Preemption for real-time systems is a trade-off between:

I Lower WCRT for high-priority tasks, and

I Higher context switching overhead.

Can the higher overhead be justified by lower WCRT?

8 of 22

Page 11: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling - experiment

Experiment: determine schedulability of random tasksets underpreemptive vs. non-preemptive scheduling.

Steps:

1. Determine WCRT of non-preemptive context switch.

2. Estimate conservative WCRT of preemptive context switch.

3. Compare schedulability.

9 of 22

Page 12: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling - experiment

Step 1: Determine WCRT of non-preemptive context switch.

I NVIDIA (2009): “The Fermi pipeline is optimized to reduce thecost of an application context switch to below 25 microseconds.”

I But Nouveau cannot change Fermi memory clock.

10 of 22

Page 13: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling - experiment

Step 1: Determine WCRT of non-preemptive context switch.

I NVIDIA (2009): “The Fermi pipeline is optimized to reduce thecost of an application context switch to below 25 microseconds.”

I But Nouveau cannot change Fermi memory clock.

10 of 22

Page 14: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling - experiment

Step 1: Determine WCRT of non-preemptive context switch.

I Variety of Kepler GPUs (2012-2014) with different:I Context size,I Maximum memory bandwidth.

I Same conditions:I Nouveau: max clockspeed,I Samples: 20,000,000/run,I Resolution: 1600x1200,I Workload: 1024x768 OpenArena windowed timedemo.

I (Intrusive measurement, max. observed overhead 224ns.)

11 of 22

Page 15: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling - results

NVIDIA GPU (SMs) Max bw State Time (µs) Avg. utilisationGiB/s KiB min avg max GiB/s %

GeForce GT 710 (1) 14.4 ∼63.9 9.2 21.5 80.1 2.83 (19.6%)GeForce GT 640 (2) 28.5 ∼68.2 13.6 26.5 43.7 2.45 (8.6%)GeForce GTX 650 (2) 80.0 ∼68.2 12.7 23.2 36.0 2.71 (3.4%)GeForce GTX 780 (12) 288.4 ∼268.6 9.7 20.0 28.6 13.76 (4.8%)

NVIDIA’s 25µs claim roughly holds on Kepler.

Worst case up to ∼3.7× average. . .

12 of 22

Page 16: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling - results

NVIDIA GPU (SMs) Max bw State Time (µs) Avg. utilisationGiB/s KiB min avg max GiB/s %

GeForce GT 710 (1) 14.4 ∼63.9 9.2 21.5 80.1 2.83 (19.6%)GeForce GT 640 (2) 28.5 ∼68.2 13.6 26.5 43.7 2.45 (8.6%)GeForce GTX 650 (2) 80.0 ∼68.2 12.7 23.2 36.0 2.71 (3.4%)GeForce GTX 780 (12) 288.4 ∼268.6 9.7 20.0 28.6 13.76 (4.8%)

NVIDIA’s 25µs claim roughly holds on Kepler.

Worst case up to ∼3.7× average. . .

12 of 22

Page 17: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling - results

NVIDIA GPU (SMs) Max bw State Time (µs) Avg. utilisationGiB/s KiB min avg max GiB/s %

GeForce GT 710 (1) 14.4 ∼63.9 9.2 21.5 80.1 2.83 (19.6%)GeForce GT 640 (2) 28.5 ∼68.2 13.6 26.5 43.7 2.45 (8.6%)GeForce GTX 650 (2) 80.0 ∼68.2 12.7 23.2 36.0 2.71 (3.4%)GeForce GTX 780 (12) 288.4 ∼268.6 9.7 20.0 28.6 13.76 (4.8%)

NVIDIA’s 25µs claim roughly holds on Kepler.

Worst case up to ∼3.7× average. . .

12 of 22

Page 18: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling

Step 2: Estimate conservative WCRT of preemptive context switch.

Assumption: WCRT grows linear with size of context.Each SM:

I 256KiB registers

I Max. 48KiB local memory

13 of 22

Page 19: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling

Ex: GeForce GT 640 (2×SM) full-preemption context size:

68.2 + 2× (256 + 48) = 676.2KiB

Results in following (conservative) estimates:

Ctxswitch type Avg (µs) Max (µs)

Non-preemptive (68.2KiB) 26.5 43.7Preemptive (676.2KiB) 262.7 433.3

14 of 22

Page 20: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling

Step 3: determine schedulability of random task sets.

Parameters:

I Uniprocessor EDF scheduling policy.

I 8.1M random tasksets (UUniFast).

I Taskset: two tasks, 1000µs ≤ Pi < 15000µs.

Ctxswitch type Avg (µs) Max (µs)

Non-preemptive (68.2KiB) 26.5 43.7Preemptive (676.2KiB) 262.7 433.3

15 of 22

Page 21: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling

Step 3: determine schedulability of random task sets.

Assumptions:

I NVIDIA Tegra K1-like system (28.5GiB/s, 2×SM).

I Non-preemptive context switch: 1 context switch/job.

I Preemptive context switch: 2 context switches/job.

16 of 22

Page 22: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling

0

10

20

30

40

50

60

70

80

90

100

0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

Sch

ed

ula

bili

ty (

%)

Utilisation

Preemptive (avg)Preemptive (max)

Non-preemptive (avg)Non-preemptive (max)

For 0.25 ≤ U ≤ 0.72 full-preempt beneficial

Reduce preemptive ctxswitch overhead → higher schedulability.

17 of 22

Page 23: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling

0

10

20

30

40

50

60

70

80

90

100

0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

Sch

ed

ula

bili

ty (

%)

Utilisation

Preemptive (avg)Preemptive (max)

Non-preemptive (avg)Non-preemptive (max)

For 0.25 ≤ U ≤ 0.72 full-preempt beneficial

Reduce preemptive ctxswitch overhead → higher schedulability.

17 of 22

Page 24: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling

0

10

20

30

40

50

60

70

80

90

100

0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

Sch

ed

ula

bili

ty (

%)

Utilisation

Preemptive (avg)Preemptive (max)

Non-preemptive (avg)Non-preemptive (max)

For 0.25 ≤ U ≤ 0.72 full-preempt beneficial

Reduce preemptive ctxswitch overhead → higher schedulability.

17 of 22

Page 25: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling - summary

Preemption for real-time systems is a trade-off between:

I Lower WCRT for high-priority tasks, and

I Higher context switching overhead.

Can the higher overhead be justified by lower WCRT?→ Yes

. . . under real-time task(/shader/compute kernel) scheduling.

18 of 22

Page 26: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Preemptive GPU scheduling - summary

Preemption for real-time systems is a trade-off between:

I Lower WCRT for high-priority tasks, and

I Higher context switching overhead.

Can the higher overhead be justified by lower WCRT?→ Yes. . . under real-time task(/shader/compute kernel) scheduling.

18 of 22

Page 27: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

The need for better models

NVIDIA GPU (SMs) Max bw State Time (µs) Avg. utilisationGiB/s KiB min avg max GiB/s %

GeForce GT 710 (1) 14.4 ∼63.9 9.2 21.5 80.1 2.83 (19.6%)GeForce GT 640 (2) 28.5 ∼68.2 13.6 26.5 43.7 2.45 (8.6%)GeForce GTX 650 (2) 80.0 ∼68.2 12.7 23.2 36.0 2.71 (3.4%)GeForce GTX 780 (12) 288.4 ∼268.6 9.7 20.0 28.6 13.76 (4.8%)

NVIDIA’s 25µs claim roughly holds on Kepler.

Worst case up to ∼3.7× average. Why?

19 of 22

Page 28: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

The need for better models

NVIDIA GeForce GT 710:

19900000

19920000

19940000

19960000

19980000

20000000

0 20000 40000 60000 80000 100000 120000

Max 1 Max 2 Max 3

# S

am

ple

s

Context switch time (ns)

1: 1024x768 60Hz (180MiB/s)2: 1600x1200 60Hz (439.5MiB/s)3: 3840x2160 30Hz (949.2MiB/s)

Tail ∼ 0.3% of all samples.

Maximum correlates with display resolution → interference!

20 of 22

Page 29: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

The need for better models

NVIDIA GeForce GT 710:

19900000

19920000

19940000

19960000

19980000

20000000

0 20000 40000 60000 80000 100000 120000

Max 1 Max 2 Max 3

# S

am

ple

s

Context switch time (ns)

1: 1024x768 60Hz (180MiB/s)2: 1600x1200 60Hz (439.5MiB/s)3: 3840x2160 30Hz (949.2MiB/s)

Tail ∼ 0.3% of all samples.

Maximum correlates with display resolution → interference!

20 of 22

Page 30: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

The need for better models

NVIDIA GeForce GT 710:

19900000

19920000

19940000

19960000

19980000

20000000

0 20000 40000 60000 80000 100000 120000

Max 1 Max 2 Max 3

# S

am

ple

s

Context switch time (ns)

1: 1024x768 60Hz (180MiB/s)2: 1600x1200 60Hz (439.5MiB/s)3: 3840x2160 30Hz (949.2MiB/s)

Tail ∼ 0.3% of all samples.

Maximum correlates with display resolution → interference!

20 of 22

Page 31: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

The need for better models - summary

I Tasks on GPUs susceptible to performance interference.

I Ex.: display scan-out interferes with context switch.

I Need models to distinguish WCET from WCRT!

21 of 22

Page 32: Motivating preemptive GPU scheduling for real-time systems ...Preemptive GPU scheduling Preemption for real-time systems is a trade-o between: I Lower WCRT for high-priority tasks,

Conclusion

Preemptive GPU scheduling for real-time systems

I Use-cases for parallel accelerators in RTS.I Autonomous robotics driving force.

I Preemptive scheduling: improved WCRT outweighs overhead.I We need:

I More control over task(/shader/compute kernel) scheduling policies.I More accurate performance interference models.

22 of 22