SlideShare a Scribd company logo
1 
Embedded System - ARM 
Development and Optimization Sharing Session 
 Thumb2 Conditional Code 
 Benchmark using cycle count 
 Optimization Technique 
 Mutex & ARM Exclusive Monitor 
竹內宏輝 hirokiht <hiroki04030@yahoo.com>
2 
Thumb2 Conditional Code 
Thumb Thumb2 
ISA 16bit 16bit/32bit 
Conditional 
Only supported in 
Code 
branch 
Use IT-block 
Bitwise - BFC/BFI/SBFX 
/UBFX 
Table-branch 
TBB/TBH 
List of Condition Code: 
 Eq, hs, mi, vs, hi, ge, gt, 
al, ne, lo, pl, vc, ls, lt, le 
 Example: 
ITETT EQ 
MOVEQ r0, #1 
MOVNE r0, #0 
MOVEQ r1, #0 
MOVEQ r2, #0
3 
Thumb2 Conditional Code
4 
Benchmark using cycle count 
Naive Approach: 
 Using cycle 
count/systick/system time 
difference, less is better. 
 QEMU doesn't have 
systick, so can't be 
emulated. Have to use real 
hardware. 
Commercial Approach 
 Use SDK/Development 
Kit/Workbench, highly 
emulated mcu. Very 
expensive....
5 
Benchmark using cycle count 
My Thoughts: 
 For low-end hardware, hardware is cheaper 
than the commercial development tool, just 
buy and plug it in. The best benchmark is to do 
a REAL benchmark on hardware.
6 
Optimization Technique 
Choose the best compilation option, 
fully utilize the hardware (if 
possible) 
 Hardware Multiplication and Division 
 DSP 
 FPU 
 DMA 
 Saturation 
 Thumb2 ISA 
 Hardware controller - Ethernet, Graphic, 
SDIO, RTC, Encoder/Decoder, etc
7 
Optimization Technique 
 If the operation involve 2n, think again, 
maybe bitwise operator can help 
 Multiplication x<<n = x*2^n 
 Division x >> n = x/2^n (Note, lose 
precision) 
 Modulus x&(n-1) = x%2^n 
 Check is 2^n or not: x & (x-1) == 0 
 Swap (without using tmp): 
– x ^= y; y ^= x; x ^= y;
8 
Optimization Technique (for C) 
 Pointer is your friend, learn it, use it! (Esp. in memory limited 
environment) 
 Struct/Union is the best tool to pack data 
– C99 support bitwise struct. (Older version can use bitwise shifting and 
masking) 
– Variable order is important, in memory and in files. 
 If many boolean variable is needed, consider using "flag" 
implementation 
 #define can help to make better code readability, also can be used 
to define macro
9 
Optimization Technique 
Best Code Density != Best Code Performance 
(most of the time) 
 Decide before start to develop 
 Again use the compilation option accordingly
10 
Optimization Technique 
Algorithm is important, choose the one that 
best fit your application. 
 Searching, Sorting, Random, Hashing, etc 
Data Structure is more important! 
 But don't overkill, no need to use an indexed list, to 
store 10 single-attribute item, a simple array will do.
11 
Optimization Technique 
But sometimes overkill is good: 
 If the software need 128MB RAM, no harm giving 
512MB (Memory is cheap, Time is expensive to debug). 
Breathing room for further software modification. 
 A well structured program may not be needed for small 
project, but program only grows bigger and bigger.
12 
Optimization Technique 
Standards and Protocols are complicated, but 
they're there for some reason..... 
 Well designed, implemented, and tested. 
 Compatible with other software/hardware.
13 
Optimization Technique 
Don't reinvent the wheel, make the wheel 
better. 
 Google/Stack Overflow is your friend, see how other 
people implement and why. 
 If there's a (open source) library, why not use it?
14 
Mutex & ARM Exclusive Monitor 
What is Mutex? 
 Mutual Exclusion - Make sure no more than one 
concurrent process is in their critical section, so that 
race condition will not occur. Mutex only have two 
states -- "locked" and "unlocked".
15 
Mutex & ARM Exclusive Monitor 
Mutex vs Binary Semaphore 
 Semaphore is to control access by multiple process to a common resource. Typical 
producer-consumer problem can be solved using semaphore. 
 Binary semaphore is semaphore variable with only 0 or 1. Means only one process can 
access the resource at the time. Then how is it different with mutex? 
 Mutex have a owner concept, only the process who locks it can unlocks it. But 
semaphore doesn't, process A may be using the resource, and process B contain a 
bug which "release" the resource it doesn't own, and process C will attempt to use it, 
and causing concurrent access with process A.
16 
Mutex & ARM Exclusive Monitor 
ARM Exclusive Monitor 
 Each processor that supports 
exclusive accesses has a local 
monitor. As the name indicate, "local 
monitor" is to monitor the memory 
which is local (shared and non-shared). 
Whereas, "global monitor" is 
to monitor shared memory. Access to 
shared memory will be checked for 
both local and global monitor.
17 
Mutex & ARM Exclusive Monitor 
 Since during "exclusive" state, access to the specific memory is 
only done by one process/thread. 
 To enter the "exclusive" state, we must use LDREX, if we decided 
to update the value, we use STREX to update the value and return 
to the "open access" state; otherwise it is advisable that we use 
CLREX to return to "open access" state without change any value. 
 If we attempt to use STREX during "open access" state, it will fail. 
For safety purpose, it is necessary to check if an operation has 
been succeeded.

More Related Content

What's hot

Code optimization
Code optimizationCode optimization
Code optimization
Pradip Bhattarai
 
Multi layered perceptron (mlp)
Multi layered perceptron (mlp)Multi layered perceptron (mlp)
Multi layered perceptron (mlp)
Handson System
 
Peephole optimization techniques
Peephole optimization techniquesPeephole optimization techniques
Peephole optimization techniques
garishma bhatia
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazation
Siva Sathya
 
Loop optimization
Loop optimizationLoop optimization
Loop optimization
Vivek Gandhi
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler design
Rajkumar R
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
Muhammad Hammad Waseem
 
Matopt
MatoptMatopt
Unit 3 part2
Unit 3 part2Unit 3 part2
Unit 3 part2
Karthik Vivek
 
Compiler optimization
Compiler optimizationCompiler optimization
Compiler optimization
Karthik Vivek
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
Akhil Kaushik
 
Embedded programming u3 part 1
Embedded programming u3 part 1Embedded programming u3 part 1
Embedded programming u3 part 1
Karthik Vivek
 
Parallel Programming on the ANDC cluster
Parallel Programming on the ANDC clusterParallel Programming on the ANDC cluster
Parallel Programming on the ANDC cluster
Sudhang Shankar
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basics
ayeshasafdar8
 
Compiler optimization techniques
Compiler optimization techniquesCompiler optimization techniques
Compiler optimization techniques
Hardik Devani
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 
Chap6 procedures &amp; macros
Chap6 procedures &amp; macrosChap6 procedures &amp; macros
Chap6 procedures &amp; macros
HarshitParkar6677
 
Elementary Parallel Algorithms
Elementary Parallel AlgorithmsElementary Parallel Algorithms
Elementary Parallel Algorithms
Heman Pathak
 

What's hot (19)

Code optimization
Code optimizationCode optimization
Code optimization
 
Multi layered perceptron (mlp)
Multi layered perceptron (mlp)Multi layered perceptron (mlp)
Multi layered perceptron (mlp)
 
Optimization
OptimizationOptimization
Optimization
 
Peephole optimization techniques
Peephole optimization techniquesPeephole optimization techniques
Peephole optimization techniques
 
Principle source of optimazation
Principle source of optimazationPrinciple source of optimazation
Principle source of optimazation
 
Loop optimization
Loop optimizationLoop optimization
Loop optimization
 
Principal source of optimization in compiler design
Principal source of optimization in compiler designPrincipal source of optimization in compiler design
Principal source of optimization in compiler design
 
Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]Data Structures - Lecture 1 [introduction]
Data Structures - Lecture 1 [introduction]
 
Matopt
MatoptMatopt
Matopt
 
Unit 3 part2
Unit 3 part2Unit 3 part2
Unit 3 part2
 
Compiler optimization
Compiler optimizationCompiler optimization
Compiler optimization
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
 
Embedded programming u3 part 1
Embedded programming u3 part 1Embedded programming u3 part 1
Embedded programming u3 part 1
 
Parallel Programming on the ANDC cluster
Parallel Programming on the ANDC clusterParallel Programming on the ANDC cluster
Parallel Programming on the ANDC cluster
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basics
 
Compiler optimization techniques
Compiler optimization techniquesCompiler optimization techniques
Compiler optimization techniques
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Chap6 procedures &amp; macros
Chap6 procedures &amp; macrosChap6 procedures &amp; macros
Chap6 procedures &amp; macros
 
Elementary Parallel Algorithms
Elementary Parallel AlgorithmsElementary Parallel Algorithms
Elementary Parallel Algorithms
 

Viewers also liked

Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)
Adair Dingle
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
Anurag Tomar
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
sato262
 
SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
Anurag Tomar
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
adil raja
 
Protols used in bluetooth
Protols used in bluetoothProtols used in bluetooth
Protols used in bluetooth
Sonali Parab
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
Emertxe Information Technologies Pvt Ltd
 
Arm processor
Arm processorArm processor
Arm processor
SHREEHARI WADAWADAGI
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
Ronak Chhajed
 
Embedded C
Embedded CEmbedded C
Introduction to Embedded System
Introduction to Embedded SystemIntroduction to Embedded System
Introduction to Embedded System
Emertxe Information Technologies Pvt Ltd
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
Abhijeet kapse
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
Mohamed Abdallah
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)Varun Mahajan
 
Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
Abhijeet kapse
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
Dhaval Kaneria
 
Code Optimization
Code OptimizationCode Optimization
Code Optimizationguest9f8315
 
Iot
IotIot

Viewers also liked (18)

Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
 
SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
 
Protols used in bluetooth
Protols used in bluetoothProtols used in bluetooth
Protols used in bluetooth
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
 
Arm processor
Arm processorArm processor
Arm processor
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Introduction to Embedded System
Introduction to Embedded SystemIntroduction to Embedded System
Introduction to Embedded System
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Iot
IotIot
Iot
 

Similar to Arm developement

Analytics tools and Instruments
Analytics tools and InstrumentsAnalytics tools and Instruments
Analytics tools and InstrumentsKrunal Soni
 
Presentation
PresentationPresentation
Presentation
Aanchal Batra
 
Lab6 rtos
Lab6 rtosLab6 rtos
Lab6 rtos
indirakumar86
 
Linux scheduler
Linux schedulerLinux scheduler
Linux scheduler
Liran Ben Haim
 
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,GrafanaPrometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Sridhar Kumar N
 
Describe synchronization techniques used by programmers who develop .pdf
Describe synchronization techniques used by programmers who develop .pdfDescribe synchronization techniques used by programmers who develop .pdf
Describe synchronization techniques used by programmers who develop .pdf
excellentmobiles
 
ARM.pdf
ARM.pdfARM.pdf
ARM.pdf
SnehaSoni72
 
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation SystemsShorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation Systems
National Cheng Kung University
 
Techno-Fest-15nov16
Techno-Fest-15nov16Techno-Fest-15nov16
Techno-Fest-15nov16
Satish Navkar
 
Linux Assignment 3
Linux Assignment 3Linux Assignment 3
Linux Assignment 3
Diane Allen
 
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ ProcessorsUnderstand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Intel® Software
 
Bsdtw17: theo de raadt: mitigations and other real security features
Bsdtw17: theo de raadt: mitigations and other real security featuresBsdtw17: theo de raadt: mitigations and other real security features
Bsdtw17: theo de raadt: mitigations and other real security features
Scott Tsai
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of ThingsJerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
Samsung Open Source Group
 
Multicore
MulticoreMulticore
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slots
mha4
 
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slots
mha4
 
Backtrack Manual Part8
Backtrack Manual Part8Backtrack Manual Part8
Backtrack Manual Part8
Nutan Kumar Panda
 
Java under the hood
Java under the hoodJava under the hood
Java under the hood
Vachagan Balayan
 
System Software ( Os )
System Software ( Os )System Software ( Os )
System Software ( Os )
Paula Smith
 
Developing Real-Time Systems on Application Processors
Developing Real-Time Systems on Application ProcessorsDeveloping Real-Time Systems on Application Processors
Developing Real-Time Systems on Application Processors
Toradex
 

Similar to Arm developement (20)

Analytics tools and Instruments
Analytics tools and InstrumentsAnalytics tools and Instruments
Analytics tools and Instruments
 
Presentation
PresentationPresentation
Presentation
 
Lab6 rtos
Lab6 rtosLab6 rtos
Lab6 rtos
 
Linux scheduler
Linux schedulerLinux scheduler
Linux scheduler
 
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,GrafanaPrometheus - Intro, CNCF, TSDB,PromQL,Grafana
Prometheus - Intro, CNCF, TSDB,PromQL,Grafana
 
Describe synchronization techniques used by programmers who develop .pdf
Describe synchronization techniques used by programmers who develop .pdfDescribe synchronization techniques used by programmers who develop .pdf
Describe synchronization techniques used by programmers who develop .pdf
 
ARM.pdf
ARM.pdfARM.pdf
ARM.pdf
 
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation SystemsShorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation Systems
 
Techno-Fest-15nov16
Techno-Fest-15nov16Techno-Fest-15nov16
Techno-Fest-15nov16
 
Linux Assignment 3
Linux Assignment 3Linux Assignment 3
Linux Assignment 3
 
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ ProcessorsUnderstand and Harness the Capabilities of Intel® Xeon Phi™ Processors
Understand and Harness the Capabilities of Intel® Xeon Phi™ Processors
 
Bsdtw17: theo de raadt: mitigations and other real security features
Bsdtw17: theo de raadt: mitigations and other real security featuresBsdtw17: theo de raadt: mitigations and other real security features
Bsdtw17: theo de raadt: mitigations and other real security features
 
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of ThingsJerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
JerryScript: An ultra-lighteweight JavaScript Engine for the Internet of Things
 
Multicore
MulticoreMulticore
Multicore
 
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slots
 
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slots
 
Backtrack Manual Part8
Backtrack Manual Part8Backtrack Manual Part8
Backtrack Manual Part8
 
Java under the hood
Java under the hoodJava under the hood
Java under the hood
 
System Software ( Os )
System Software ( Os )System Software ( Os )
System Software ( Os )
 
Developing Real-Time Systems on Application Processors
Developing Real-Time Systems on Application ProcessorsDeveloping Real-Time Systems on Application Processors
Developing Real-Time Systems on Application Processors
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Arm developement

  • 1. 1 Embedded System - ARM Development and Optimization Sharing Session  Thumb2 Conditional Code  Benchmark using cycle count  Optimization Technique  Mutex & ARM Exclusive Monitor 竹內宏輝 hirokiht <hiroki04030@yahoo.com>
  • 2. 2 Thumb2 Conditional Code Thumb Thumb2 ISA 16bit 16bit/32bit Conditional Only supported in Code branch Use IT-block Bitwise - BFC/BFI/SBFX /UBFX Table-branch TBB/TBH List of Condition Code:  Eq, hs, mi, vs, hi, ge, gt, al, ne, lo, pl, vc, ls, lt, le  Example: ITETT EQ MOVEQ r0, #1 MOVNE r0, #0 MOVEQ r1, #0 MOVEQ r2, #0
  • 4. 4 Benchmark using cycle count Naive Approach:  Using cycle count/systick/system time difference, less is better.  QEMU doesn't have systick, so can't be emulated. Have to use real hardware. Commercial Approach  Use SDK/Development Kit/Workbench, highly emulated mcu. Very expensive....
  • 5. 5 Benchmark using cycle count My Thoughts:  For low-end hardware, hardware is cheaper than the commercial development tool, just buy and plug it in. The best benchmark is to do a REAL benchmark on hardware.
  • 6. 6 Optimization Technique Choose the best compilation option, fully utilize the hardware (if possible)  Hardware Multiplication and Division  DSP  FPU  DMA  Saturation  Thumb2 ISA  Hardware controller - Ethernet, Graphic, SDIO, RTC, Encoder/Decoder, etc
  • 7. 7 Optimization Technique  If the operation involve 2n, think again, maybe bitwise operator can help  Multiplication x<<n = x*2^n  Division x >> n = x/2^n (Note, lose precision)  Modulus x&(n-1) = x%2^n  Check is 2^n or not: x & (x-1) == 0  Swap (without using tmp): – x ^= y; y ^= x; x ^= y;
  • 8. 8 Optimization Technique (for C)  Pointer is your friend, learn it, use it! (Esp. in memory limited environment)  Struct/Union is the best tool to pack data – C99 support bitwise struct. (Older version can use bitwise shifting and masking) – Variable order is important, in memory and in files.  If many boolean variable is needed, consider using "flag" implementation  #define can help to make better code readability, also can be used to define macro
  • 9. 9 Optimization Technique Best Code Density != Best Code Performance (most of the time)  Decide before start to develop  Again use the compilation option accordingly
  • 10. 10 Optimization Technique Algorithm is important, choose the one that best fit your application.  Searching, Sorting, Random, Hashing, etc Data Structure is more important!  But don't overkill, no need to use an indexed list, to store 10 single-attribute item, a simple array will do.
  • 11. 11 Optimization Technique But sometimes overkill is good:  If the software need 128MB RAM, no harm giving 512MB (Memory is cheap, Time is expensive to debug). Breathing room for further software modification.  A well structured program may not be needed for small project, but program only grows bigger and bigger.
  • 12. 12 Optimization Technique Standards and Protocols are complicated, but they're there for some reason.....  Well designed, implemented, and tested.  Compatible with other software/hardware.
  • 13. 13 Optimization Technique Don't reinvent the wheel, make the wheel better.  Google/Stack Overflow is your friend, see how other people implement and why.  If there's a (open source) library, why not use it?
  • 14. 14 Mutex & ARM Exclusive Monitor What is Mutex?  Mutual Exclusion - Make sure no more than one concurrent process is in their critical section, so that race condition will not occur. Mutex only have two states -- "locked" and "unlocked".
  • 15. 15 Mutex & ARM Exclusive Monitor Mutex vs Binary Semaphore  Semaphore is to control access by multiple process to a common resource. Typical producer-consumer problem can be solved using semaphore.  Binary semaphore is semaphore variable with only 0 or 1. Means only one process can access the resource at the time. Then how is it different with mutex?  Mutex have a owner concept, only the process who locks it can unlocks it. But semaphore doesn't, process A may be using the resource, and process B contain a bug which "release" the resource it doesn't own, and process C will attempt to use it, and causing concurrent access with process A.
  • 16. 16 Mutex & ARM Exclusive Monitor ARM Exclusive Monitor  Each processor that supports exclusive accesses has a local monitor. As the name indicate, "local monitor" is to monitor the memory which is local (shared and non-shared). Whereas, "global monitor" is to monitor shared memory. Access to shared memory will be checked for both local and global monitor.
  • 17. 17 Mutex & ARM Exclusive Monitor  Since during "exclusive" state, access to the specific memory is only done by one process/thread.  To enter the "exclusive" state, we must use LDREX, if we decided to update the value, we use STREX to update the value and return to the "open access" state; otherwise it is advisable that we use CLREX to return to "open access" state without change any value.  If we attempt to use STREX during "open access" state, it will fail. For safety purpose, it is necessary to check if an operation has been succeeded.