Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS −...

33
TM August 2013

Transcript of Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS −...

Page 1: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

TM

August 2013

Page 2: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

TM 2

• Objective• System characteristics of a Multicore Architecture• Challenges with Multicore Architecture− Application Porting Challenges from Unicore to Multicore

ArchitectureProgramming ModelProcessing Model

• Debugging Support with Multicore Architecture− Performance Debugging Support− Functionality Debugging support

• USDPAA programming model

Page 3: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

TM 3

After this presentation, you should be able to understand following:

• Challenges in effectively exploiting the Multicore SoC architecture• Performance and functionality debugging challenges

− Effective threading− Avoidance of deadlock situations

• Role of OS− Thread and interrupt migration across different CPUs− Support for thread and interrupt affinity and debugging

• Role of enhanced I/O devices in Multicore migration− Load Spreading− Data Stashing

• Debugging Support− Freescale proprietary debugging support− OpenSource debugging support

Page 4: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

TM 4

• Objective• System characteristics of a Multicore Architecture• Challenges with Multicore Architecture− Application Porting Challenges from Unicore to Multicore

ArchitectureProgramming ModelProcessing Model

• Debugging Support with Multicore Architecture− Performance Debugging Support− Functionality Debugging support

• USDPAA programming model

Page 5: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

5TM

• Homogeneous CPUs with multilevel cache hierarchy

− Threaded cores, co-located control/data planes

− OSes, baremetal apps running on virtual partitions

• Specialized hardware accelerators, I/O ports with support for load spreading and selective data stashing

• More powerful and complex Buses inside SoC package reduce debug application thread interaction with I/O devices

VxWorks / Linux

PA

L3 cache

L2 cache

PA

Light Weight / Bare Metal Application

Har

dwar

e A

ccel

erat

ors

PA

L2 cache

L2 cache

ctrl data

Page 6: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

6TM

• Heterogeneous CPUs with multilevel cache hierarchy

− Threaded cores, co-located control/data planes

− OSes, baremetal apps running on virtual partitions

• Optionally virtual machine appliance (e.g. KVM, etc.)

• More powerful and complex Buses inside SoC package reduce debug application thread interaction with I/O devices

KVM

Linux1

VxWorks

PA

L3 cache

L2 cache

PASC

Bare Metal Application

Har

dwar

e A

ccel

erat

ors

Linux2

Page 7: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

7TM

• SMP is a multi-processor homogeneous computer architecturewhere two or more identical processors are connected to a globally shared main memory…

• Processors could be separate devices,all on 1 device or a mix

• Typically all CPUs share memory,I/O and are run one OS instance

• Each processor can run independentprocesses and threads

• Any idle processor can be assigned any task

MemoryMemoryCPU

CPU

I/OI/O

Cache

Cache

Cache

CPU

CacheCache

CacheCache

CPU

Page 8: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

8TM

• A multi-processing usage model in which individual processors are dedicated to particular tasks, such as running the operating system or performing user requests

• Beware: AMP does not need to imply heterogeneous hardware!It is perfectly possible to implement a software AMP system design on SMP hardware (e.g. MPC8641HPCN Linux BSP supports both)

QoSprocessing

Power Architecture™Core

D-Cache I-Cache

L2 Cache

Securityprocessing

Power Architecture™Core

D-Cache I-Cache

L2 Cache

Linux OS(control/interrupts)

Power Architecture™Core

D-Cache I-Cache

L2 Cache

L2 - L3processing

Power Architecture™Core

D-Cache I-Cache

L2 Cache

Page 9: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

9TM

MemoryEnet0 Enet1 Enet2 UART SRIO

Power Architecture™Core

D-Cache I-Cache

L2 Cache

Power Architecture™Core

D-Cache I-Cache

L2 Cache

Power Architecture™Core

D-Cache I-Cache

L2 Cache

Power Architecture™Core

D-Cache I-Cache

L2 Cache

Virtual Machine Monitor / Hypervisor

H/W

S/W

Page 10: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

10TM

• System partition (mainly cores, memory, ports resources)• OS consideration (control plane OS, data plane bare-board or light-

weighted env)• Data plane cores working architecture (functionalities bound to each

core/core-group)• Mutext mechanism• Data plane tables shared among all data plane cores (shared memory

mechanism)• Inter core communication mechanism• System global variables, CPU global variables• Rx/Tx driver • Arch specific accelerators use• Control plane partition and data plane partition communications

Page 11: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

11TM

core

multi‐threads/processes    

Shared tablesSem_take

Sem_give

core 1 core n

Shared tables

spinlock

spinunlock

Page 12: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

TM 12

• Objective• System characteristics of a Multicore Architecture• Challenges with Multicore Architecture− Application Porting Challenges from Unicore to Multicore

ArchitectureProgramming ModelProcessing Model

• Debugging Support with Multicore Architecture− Performance Debugging Support− Functionality Debugging support

• USDPAA programming model

Page 13: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

13TM

• Legacy software written for non-SMP− Multithreading a must for scaling with Multicore

− Dynamic thread migration by OS scheduler

− Possibility to Affine application threads and interrupts to a core

− Locks must for shared resources in multithreaded applications

Resource contention, priority inversion, deadlocks

• Parallel threads execution in real time− Latent race conditions get uncovered

− Difficult to reproduce bugs

− Data corruption more difficult to nail down

Page 14: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

14TM

• Cache efficiency requires careful Software design

− False cache line sharing

− Cache line thrashing due to threads running on different cores

• Finding performance bottleneck

− Core loading by scheduler

− TLB, cache thrashing

− Stash downgrades

− Too many interrupts, interrupt distribution, context switches

− Slow IPC

Page 15: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

15TM

• Pipeline− Work division across the cores by the way of functionality− Each core executes a subset of functions on each work unit− Individual work units passed along functional blocks/cores

Core 0

Function A

Core 1

Function B

Core 2

Function CMPI MPI

Ingress work

Page 16: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

16TM

• Run to completion− Work is divided by splitting work units across cores− Work scheduler divides work units across cores− Each core executes all functions on received work units

Core 0

Function A+B+C

Core 1

Function A+B+C

Core 2

Function A+B+C

Work scheduler

Page 17: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

17TM

Aspect Pipeline Run to completionProgrammability Difficult to break a problem in

equal chunks of workEasy

I-Cache utilization Good Poor

D-cache utilization Poor Good

Load balancing Poor Easy(If hardware supported)

Fault tolerance Poor Good

Locks required No Yes

Egress work ordering Maintained Disturbed

Work distribution hardware Not required Required

IPC/MPI overhead High Nil

Real-time/priority work latency

Low High

Scalability with cores Difficult (requires redesign) Easy

Page 18: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

18TM

• ‘C’ does not natively support multithreading− Compiler assumes single flow of control− Protecting shared resource is responsibility of programmer

Locks, volatile etc

− Parallelism cannot be expressed as an intent to compilerCompiler cannot do inter thread optimization

• Relaxed ordering− Out of order completion of loads and stores across cores

Instruction/storage barriers

− Programmers need to be closely aware of hardware

Page 19: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

19TM

• The compiler may not be able to do the parallelization in the way you like to see it:− A loop is not parallelized− The data dependency analysis is not able to determine whether it is

safe to parallelize or not.− The granularity is not high enough− The compiler lacks information to parallelize at the highest possible

level

Explicit parallelization through OpenMP directives and functions are used to overcome above limitations

Page 20: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

20TM

• Synchronous− Requester waits till response arrives− Simplifies programming as response pending state not required− Only single pending request− Suitable for core-inbuilt offload hardware accelerators

Requester Accelerator

Request

ResponseWait

RequestIdle Time

Page 21: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

21TM

• Asynchronous− Requesters do not wait till response arrives (fire and forget)− Response comes as another state machine input− Request & response co-relation required− Multiple requests can be pending− Suitable for core external offload hardware accelerators

Requester Accelerator

Some other work

Requests

Responses

Page 22: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

22TM

Aspect Synchronous Asynchronous

Programming ease High Low

Context switches High Low

Accelerator utilization Low High

Pending requests Single Multiple

Context switches High Low

Single flow B/W Low High

Page 23: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

TM 23

• Objective• System characteristics of a Multicore Architecture• Challenges with Multicore Architecture− Application Porting Challenges from Unicore to Multicore

ArchitectureProgramming ModelProcessing Model

• Debugging Support with Multicore Architecture− Performance Debugging Support− Functionality Debugging support

• USDPAA programming model

Page 24: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

24TM

• Function trace: Kernel internal tracer− Derived from -rt patch Latency Tracer− Plugin tracers

ftrace : function tracerirqsoff : interrupt disabled latencywakeup : latency of highest priority task to wake upsched_switch: task context switches(more)

− Works with Ring buffer− Saved traces used to save maximum latency traces

Gives cost-view of different context level in kernel per core

Page 25: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

25TM

• Oprofile & Perf

− System-wide profiler (both kernel and user code)− Sample-based profiler –Time based and event based− SMP machine support− Performance monitoring hardware support− Relatively low overhead, typically <10%− Designed to run for long times− Perf supports recording function trace between two events

Gives more complete picture of where application spends time per core or process wide

Page 26: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

26TM

• Scenarios Tool− Simple one click access to common performance analysis

scenarios for QorIQ – including DPAA Debug IP

− Removed need from customer to know how to configure DPAA debug IP to collect performance data from common scenarios.

• Register Analyzer − Alpha version delivered

− Provides feedback on incorrect configuration of DPAA blocks (FM, QM, BM and SEC)

• SPID (Major Updates for 2012)− Target Side Library to access debug IP inside (instrumentation)

a customer application.

− Sample code to show how to collect trace and performance data for basic cases.

− Extensive documentation.

− Supports Linux and Bare Metal Applications

• SPID Utilities (New for 2012)− Applications focused on specific use-cases to improve

usability of debug IP in FSL SDK Linux applications.

− Packaged for release in SDK 1.2

− First release 3Q 2012

• Application Notes

− Performance Analysis

− LTTng Trace

− Application Debugging

• qoriq-dbg (Major Updates for 2012)

− Easy access to QorIQ debug IP from user scripts or applications via standard file system operations.

− Present tools in a manner that is familiar to Linux developers

• DPAA Tools. (New for 2012)

− Packet Tracing tool – Allows a customer to trace a packet as it moves through system.

− Focus for 2012

− First version scheduled for 4Q 2012.

− This tooling makes use of the on-board trace facility of each block.

− DPAA Trace supporting ALU USDPAA application Alpha being delivered in CW 10.1.2 (may 2012) and Production versions (Expert mode) scheduled for CW 10.2 (June 2012)

− LTTng/LTTngX

− Linux Community standard Kernel Tracing Framework

− LTTngX – Freescale’s unique extensions to LTTngFramework to support access to Freescale QorIQ Debug IP

Page 27: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

TM 27

• Multicore processor is like a traditional multiprocessor boards shrunk to a single chip. Additionally it may have hardware accelerators

• Application needs to be threaded to benefit from multicore but most legacy applications are single threaded

• To benefit from multicore capabilities, applications need to be careful about many aspects like core / interrupt affinity, cache thrashing, TLB management, priorities, deadlocks, etc.

• There are multiple programming models for multicoreapplications, with each one having its own advantages and disadvantages

• Several open source tools are available for functionality and performance debugging on multicore platforms

• Freescale supports QorIQ debug architecture to assist debug across layers of software and hardware

Page 28: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

TM 28

• Objective• System characteristics of a Multicore Architecture• Challenges with Multicore Architecture− Application Porting Challenges from Unicore to Multicore

ArchitectureProgramming ModelProcessing Model

• Debugging Support with Multicore Architecture− Performance Debugging Support− Functionality Debugging support

• USDPAA programming model

Page 29: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

29TM

• USDPAA is a change in deployment context for “data plane” run-to-completion software. − LWE – deployed in a partition in the Freescale Hypervisor− USDPAA – deployed in a Linux user space process

• Benefits:− Richer, more flexible environment– use Linux standard services− C++, 36-bit, 8th core, debug, etc− More standard– Linux is ubiquitous and supported from multiple

sources.− Provides high-performance run-to-completion

Freescale Embedded Hypervisor

Linux User Space

Linux KernelLWE

Linux User Space

USDPAA

Linux Kernel

Page 30: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

30TM

Some portals can be allocated to the Linux kernel. Others are free to be dedicated to an USDPAA thread (that is in turn affine to a core).

User Space Driver

QMan Driver

Ethernet Driver

PME Driver

SEC Driver

portal

Portal Driver

portal

QMan Driver

High API

High API

User Space Thread

Contiguous Space for Buffer Pools

user

kernel

Kernel DriversUSDPAA Thread Affine to Core

map

map

QMan shown. BMan similar.

Portals allocated to the kernel are accessed via in-kernel drivers. These provide enqueue/dequeue and other services to a next layer of kernel drivers such as standard ethernet drivers that use QMan to exchange frames with FMan. One portal multiplexes several kernel drivers.

USDPAA threads directly map and access the portal that is dedicated to them.

Page 31: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

31TM

31

C4

QPortal

BPortal

C5

QPortal

BPortal

C6

QPortal

BPortal

C7

QPortal

BPortal

C3

QPortal

BPortal

C2

QPortal

BPortal

C0

QPortal

BPortal

C1

QPortal

BPortal

Other Processes

Other Processes

USDPAA Application in User Space Process

BMan / QMan

FMan Ethernet Ports

QPortal

BPortal

BQMan Drivers

Other Driver

Net Stack

Eth Driver

kernel

thread

isolated cores

USDPAA Application Can Use 1 to 8 Cores (P4080)

Each thread has a dedicated portal and is affine to a core, 1 thread per core

7 cores are isolated but 1 can run an USDPAA thread as well as other processes.

Core 0 has portal for kernel use and standard Linux networking

thread thread thread thread thread thread thread

Page 32: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

32TM

Reflector performance with 64-byte packetsTested with 22 Gbps (full duplex) Ethernet Connectivity

0

5

10

15

20

25

30

35

1 2 3 4 5 6 7 8

Mpps

Cores

0

5

10

15

20

25

1 2 3 4 5 6 7 8

Gbps

Cores

1.2G1.5G

1.2G1.5G

Page 33: Simplify Your Application Development and Port to US DPAA ......− deadlock situations • OS − CPUs − debugging • migration − Load Spreading − Data Stashing • g Support

TM