51
Hardware-Software Interfaces Quality and Performance Alastair Reid Research Arm Ltd 1

Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Hardware-Software Interfaces Quality and Performance

Alastair ReidResearch

Arm Ltd

!1

Page 2: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Aspects of hw/sw interfaceQuality of specificationPerformanceSecurityScalability / FlexibilityParallelismEnergy efficiencyArea efficiency

!2

Page 3: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

!3

ArchitectureReference

Manual (.pdf)

Verification IP (Verilog)

ISA Spec(HOL)

ISA Spec(Coq)

ISA Spec(.smt2)

Compiler, JIT, OS, …

Simulator(.c)

Testsuite(.s)

Page 4: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

!3

ArchitectureReference

Manual (.pdf)

Verification IP (Verilog)

ISA Spec(HOL)

ISA Spec(Coq)

ISA Spec(.smt2)

Compiler, JIT, OS, …

Simulator(.c)

Testsuite(.s)

Documentation(.pdf)

ProcessorSpecification(.asl, .xml)

Page 5: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

!4

ProcessorSpecification

Page 6: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

ChallengesIncreased requirementsWhat specification language?Loss of redundancy - all eggs in one basket

!5

Page 7: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Creating Specifications

!6

Page 8: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Creating Specifications

!6

Page 9: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Creating Specifications

!6

Page 10: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Creating Specifications

!6

Page 11: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Creating Specifications

!6

Page 12: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Creating Specifications

!6

Page 13: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Pseudocode

!7

Page 14: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Arm Pseudocode~40,000 lines

- 32-bit and 64-bit modes- All 4 encodings: Thumb16, Thumb32, ARM32, ARM64- All instructions (> 1300 encodings)- All 4 privilege levels (User, Supervisor, Hypervisor, Secure Monitor)- Both Security modes (Secure / NonSecure)- MMU, Exceptions, Interrupts, Privilege checks, Debug, TrustZone, …

!8

Page 15: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Status at the start- Vague,incomplete,inaccuratelanguagedescription- Notools(parser,typechecker)- Incomplete(around15%missing)- Unexecuted,untested- Seniorarchitectsbelievedthatanexecutablespecwas- Impossible- Notuseful- Lessreadable- Lesscorrect

!9

Page 16: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Architectural Conformance SuiteProcessor architectural compliance sign-off

Large• v8-A 32,000 test programs, billions of instructions• v8-M 3,500 test programs, > 250 million instructions

Thorough• Tests dark corners of specification

Hard to run• Requires additional testing infrastructure

!10

Page 17: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

©2017ArmLimited

ProgressintestingArmspecification

- Doesnotparse,doesnottypecheck

- Can’tgetoutofreset

- Can’texecutefirstinstruction

- Can’texecutefirst100instructions

- …

- Passes90%oftests

- Passes99%oftests

- …

0

50

100

Progress testing Arm specification

Does not parse, does not type checkCan’t get out of resetCan’t execute first instructionCan’t execute first 100 instructions…Passes 90% of testsPasses 99% of tests

!11

Page 18: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Formally validating Arm processors

!12

Arm Specification

Arm Processor

TranslatetoVerilog

VerilogModelChecker

Page 19: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

!13

ArithmeticoperationsBooleanoperationsBitVectorsUnboundedintegersArraysDependentTypesStatementsAssignmentsIf-statementsLoopsExceptions

ArmSpecificationLanguage Verilog

ArithmeticoperationsBooleanoperationsBitVectorsUnboundedintegersArraysDependentTypesStatementsAssignmentsIf-statementsLoopsExceptions

Page 20: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

CheckinganinstrucKon

!14

ADD

Page 21: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

CheckinganinstrucKon

!14

ADDCMP LDR STR BNE

Context

Page 22: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Lessons Learned from validating processors

Very effective way to find bugs in implementations

Applied to commercial processors

• Cortex-A32, Cortex-A35, Cortex-A53, Cortex-A55, Cortex-A65

• Cortex-R52

• Cortex-M4, Cortex-M7, Cortex-M33

Formally validating implementations is effective at finding bugs in spec

!15

Spec

Page 23: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

!16

ProcessorSpecification

Page 24: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Rule JRJC Exit from lockup is by any of the following: • A Cold reset. • A Warm reset. • Entry to Debug state. • Preemption by a higher priority processor exception.

!17

Page 25: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Rule JRJC Exit from lockup is by any of the following: • A Cold reset. • A Warm reset. • Entry to Debug state. • Preemption by a higher priority processor exception.

!17

State Change X Event A Event B State Change C Event D

R

Page 26: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Rule JRJC Exit from lockup is by any of the following: • A Cold reset. • A Warm reset. • Entry to Debug state. • Preemption by a higher priority processor exception.

!17

State Change X Event A Event B State Change C Event D

R

RuleR:X→A∨B∨C∨D

Page 27: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

!18

StateChangeX Exit from lockup Fell(LockedUp)

EventA A Cold reset Called(TakeColdReset)

EventB A Warm reset Called(TakeReset)

StateChangeC Entry to Debug state Rose(Halted)

EventD Preemption by a higher priority processor exception

Called(ExceptionEntry)

Page 28: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Rule JRJC Exit from lockup is by any of the following: • A Cold reset. • A Warm reset. • Entry to Debug state. • Preemption by a higher priority processor exception.

!19

Fell(LockedUp)→Called(TakeColdReset)∨Called(TakeReset)∨Rose(Halted)∨Called(ExceptionEntry)

Page 29: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

!20

ArithmeticoperationsBooleanoperationsBitVectorsArraysDependentTypesFunctionsStatementsAssignmentsIf-statementsLoopsExceptions

ArmSpecificationLanguage SMT

ArithmeticoperationsBooleanoperationsBitVectorsArraysDependentTypesFunctionsStatementsAssignmentsIf-statementsLoopsExceptions

Page 30: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

ResultsMost properties proved in under 100 seconds (each)

Found 12 bugs in specification:- debug, exceptions, system registers, security

Found bugs in English prose:- ambiguous, imprecise, incorrect, …

!21

Page 31: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Public release of Arm v8-A specificationEnableformalverificaKonofsoUwareandtools

Machinereadable

Uptodate(v8.5-AarchitecturereleasedSept’18)

AutomaKctranslaKontoSailandIsabellewithCambridgeUniversity

-RerunArchitectureConformanceSuite

-“ISASemanKcsforARMv8-A,,RISC-V,andCHERI-MIPS,”POPL2019

h`ps://developer.arm.com/products/architecture/a-profile/exploraKon-toolsh`ps://github.com/alastairreid/mra_toolsh`ps://github.com/rems-project/sail-arm

!22

Page 32: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

SummaryMechanized major commercial architecture specification• High quality, broad scope

Formal validation of processors• Applied to multiple commercial processors• Adapted for use with other architectures

Formal validation of processor specificationPublic release of specification• Translation of Arm’s specification to Sail enabling Isabelle proofs w/ Cambridge

!23

“Trustworthy Specifications of the ARM v8-A and v8-M architecture” FMCAD 2016“End to End Verification of ARM processors with ISA Formal” CAV 2016“Who guards the guards? Formal Validation of ARM v8-M Specifications” OOPSLA 2017[“ISA Semantics for ARM v8-A, RISC-V, and CHERI-MIPS” POPL 2019]

Page 33: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Performance

!24

Software

Hardware

Instruction Stream

Page 34: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Performance

!25

Sequential Instruction Stream

Sequential Software

Parallel Hardware

Page 35: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Performance

!25

Out-of-Order Execution

Sequential Instruction Stream

Sequential Software

Parallel Hardware

Page 36: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Performance

!26

Parallel HardwareParallel Instruction Streams

Sequential Software

Page 37: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Performance

!26

Parallel Hardware

Parallelizing Compiler

Parallel Instruction Streams

Sequential Software

Page 38: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Performance

!26

Parallel Hardware

Parallelizing Compiler

Parallel Instruction Streams

Sequential Software

Annotations+

Page 39: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Performance

!27

Parallel Hardware

Parallelizing Compiler

Sequential Software

Annotations+

Page 40: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

ChallengesAnnotations depend on features of hardware and domainProgrammer burdenCompiler transformations

!28

Page 41: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Ardbeg (2006-2008)Goal: Build a commercial software defined radio system for LTE protocol

Subsystem:

• 2-4x 450MHz VLIW processors

• 512-bit predicated SIMD

• 14.4 Gops @ 250mW (each)

• Custom accelerators (Viterbi, Turbo, …)

!29

Page 42: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

HeterogeneousSpecialized coresLocal memories per processorExplicit data copying (DMA)

!30

HomogeneousGeneral Purpose coresCache hierarchyCache coherence

Asymmetric MP Symmetric MP

Page 43: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

HeterogeneousSpecialized coresLocal memoriesExplicit data copying (DMA)

!31

Pipeline ParallelismExplicit function placement (RPC)Explicit data placementStatic Distributed Shared Memory

Language Features

Don’t hide expensive operationsAnnotations direct restructuringAnnotation checking and inference

Programmer in controlPortabilityRapid design space exploration

Hardware + Requirements

Page 44: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

!32

int x[100]; int y[100];int z[100];

while (1) {        get(x);       foo(y,x);

       bar(z,y);       baz(z);       put(z);}

Page 45: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

int x[100]; int y[100];int z[100];

while (1) {        get(x);       foo(y,x) @ P0;       SYNC(x) @ DMA;

       bar(z,y) @ P1;       baz(z) @ P1;       put(z);}

!33

Remote Procedure Call

Synchronize data

Page 46: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

int x[100]; int y[100];int z[100];PIPELINE {  while (1) {        get(x);       foo(y,x) @ P0;       SYNC(x) @ DMA;       FIFO(y);       bar(z,y) @ P1;       baz(z) @ P1;       put(z);  }}

!34

Use pipelineParallelism

Transfer databetween threads

Page 47: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

int x[100] @ {M0}; int y[100] @ {M0,M1};int z[100] @ {M1};PIPELINE {  while (1) {        get(x@M0);       foo(y@M0, x@M0) @ P0;       SYNC(y,M1,M0) @ DMA;       FIFO(y@M1);       bar(z@M1, y@M1) @ P1;       baz(z@M1) @ P1;       put(z@M1);  }}

!35

Page 48: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

!36

int x[100] @ {M0}; int y0[100] @ {M0}; int y1a[100] @ {M1};    while (1) {        get(x);       foo(y0, x) @ P0;       memcpy(y1a,y0,…) @ DMA;       fifo_put(&f, y1a);    }

int y1b[100] @ {M1}; int z[100] @ {M1};    while (1) {       fifo_get(&f, y1b);       bar(z, y1b) @ P1;       baz(z) @ P1;       put(z);    }

Page 49: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

SummaryPart of “Ardbeg” Software Defined Radio project

• Energy efficient LTE radio modem

• Competitive with fixed function hardwareLanguage extensions balance performance and portability• Programmer uses annotations to control software-hardware mapping• Compiler restructures program to implement annotations

Defining hw/sw interface at a higher level to enable greater performance

!37

“SoC-C: Efficient Programming Abstractions for Heterogeneous Multicore Systems on Chip” CASES 2016“Reducing inter-task latency in a multiprocessor system” US 8,359,588[“From SODA to scotch: The evolution of a wireless baseband processor” MICRO 2018]

Page 50: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Hardware-Software InterfacesTwo aspects of interface explored• High Quality Specifications• Performance

Future work• Security• Can we verify that ISA is “secure”?• Parallelism• Can we apply ideas to other parallelism frameworks?

!38

Page 51: Hardware-Software Interfaces Quality and Performance · 2020-05-25 · Summary Mechanized major commercial architecture specification • High quality, broad scope Formal validation

Fin

!39