Want to create interactive content? It’s easy in Genially!

Get started free

Présentation technologie numérique

filaen

Created on March 18, 2024

Start designing with a free template

Discover more than 1500 professional designs like these:

Geniaflix Presentation

Vintage Mosaic Presentation

Shadow Presentation

Newspaper Presentation

Zen Presentation

Audio tutorial

Pechakucha Presentation

Transcript

Branchless Programming

PRESENTATIONbyRémi Del Medico

01

Programming

Programming language

  • Instructions
    • If (condition) then ...
    • else ...
    • For (...) do ...
    • While (condition) do ...
    • ...
  • Types of variables
    • Int
    • Char
    • Boolean
    • ...

The art of assembling instructions

int a = 10;int b = 5; int max = 0; if (a < b) thenmax = b;elsemax = a; print(max);

02

What is a branche?

Execution

int a = 10;int b = 5; int max = 0; if (a < b) thenmax = b;elsemax = a; print(max);

Execution

int a = 10;int b = 5; int max = 0; if (a < b) thenmax = b;elsemax = a; print(max);

Execution

int a = 10;int b = 5; int max = 0; if (a < b) thenmax = b;elsemax = a; print(max);

Execution

int a = 10;int b = 5; int max = 0; if (a < b) thenmax = b;elsemax = a; print(max);

Execution

int a = 10;int b = 5; int max = 0; if (a < b) thenmax = b;elsemax = a; print(max);

Execution

int a = 10;int b = 5; int max = 0; if (a < b) thenmax = b;elsemax = a; print(max);

What is a branche

int a = 10;int b = 5; int max = 0; if (a < b) {max = b;} else {max = a;} print(max);
int a = 10;int b = 5; int max = 0; max = maximum(a, b); print(max);
for (...) { }

03

Why branche should be avoided?

CPU Prediction

int a = 10;int b = 5; int max = 0; if (a < b) {max = b;} else {max = a;} print(max);
50%
50%

04

How to avoid branches?

10

Boolean condition

False <=> 0True <=> 1
int a = 10; boolean b = false; int c = a * b; // 10 * false = 10 * 0 = 0

11

Max function without branchment

int a = 10;int b = 5; int max = 0; if (a < b) {max = b;} else {max = a;} print(max);

12

Max function without branchment

int a = 10;int b = 5; int max = 0; if (a < b) {max = b;} else {max = a;} print(max);
int a = 10;int b = 5; int max = 0; max = a * (a > b) + b * (a < b); print(max);

13

THANK YOU!

Let's do a little Kahoot!