Chapter 4

Flynn's Taxonomy (parallel operation types)


Branch Prediction in games consoles

Fast branch-avoidant code for safe floating point division

(handle divide-by-zero)

int SafeFloatDivide_pred(float a, float b, float d)
  // convert Boolean (b != 0.0f) into either 1U or 0U
  const unsigned condition = (unsigned)(b != 0.0f);

  // convert 1U -> 0xFFFFFFFFU
  // convert 0U -> 0x00000000U
  const unsigned mask = 0U - condition;

  // calculate quotient (will be QNaN if b == 0.0f)
  const float q = a / b;

  // select quotient when mask is all ones, or default
  // value d when mask is all zeros (NOTE: this won't
  // work as written -- you'd need to use a union to
  // interpret the floats as unsigned for masking)
  const float result = (q & mask) | (d & ~mask);
  return result;

This technique for selecting one of two possible values is called predication or a select operation

Very Long Instruction Word (VLIW) CPU Design

Multi Core CPUs

Symmetric vs Assymetric Parallelism

Console Shared Libraries


Mutexes vs Semaphores

C++ Atomic

Testing if a lock is needed