Duff's device

E900227

Duff's device is a loop-unrolling technique in the C programming language that exploits switch-case fall-through to optimize data copying, famously demonstrating an unusual and clever use of C's control structures.

All labels observed (1)

Label Occurrences
Duff's device canonical 3

How this entity was disambiguated

Statements (49)

Predicate Object
instanceOf C programming idiom ⓘ
code optimization technique ⓘ
loop unrolling technique ⓘ
author Tom Duff ⓘ
category low-level optimization ⓘ
systems programming idiom ⓘ
creationYear 1983 ⓘ
creator Tom Duff ⓘ
discussedIn The C Programming Language community ⓘ
comp.lang.c newsgroup ⓘ
linked to: comp.lang.c
documentedIn Tom Duff's original email to the C mailing list ⓘ
exploitsLanguageFeature C's relaxed grammar for statement placement ⓘ
switch-case fall-through ⓘ
firstUseContext Lucasfilm graphics system ⓘ
firstUseDomain graphics programming ⓘ
hasStatus mostly of historical and educational interest ⓘ
implementsConcept manual loop unrolling ⓘ
software pipelining style copy ⓘ
influenced compiler optimization pedagogy ⓘ
later discussions of C language design ⓘ
influencedBy manual loop unrolling techniques in assembly ⓘ
modernRelevance rarely needed with modern optimizing compilers ⓘ
notableProperty considered difficult to read ⓘ
considered error-prone in maintenance ⓘ
interleaves switch statement with loop body ⓘ
legal but surprising C syntax ⓘ
often cited as an example of C's syntactic flexibility ⓘ
places case labels inside a loop ⓘ
optimizationGoal improve performance of memory copy operations ⓘ
increase instruction-level parallelism ⓘ
reduce number of branch instructions ⓘ
performanceDependsOn compiler optimization level ⓘ
memory system characteristics ⓘ
target CPU architecture ⓘ
primaryPurpose optimize data copying ⓘ
reduce loop overhead ⓘ
programmingLanguage C ⓘ
relatedConcept branch prediction ⓘ
instruction scheduling ⓘ
loop unrolling ⓘ
memcpy ⓘ
typicalUnrollFactor 8 ⓘ
typicalUseCase copying arrays of bytes ⓘ
copying arrays of shorts ⓘ
copying arrays of words ⓘ
usesControlStructure case labels ⓘ
do-while loop ⓘ
fall-through behavior ⓘ
switch statement ⓘ

How these facts were elicited

Referenced by (3)

Full triples — surface form annotated when it differs from this entity's canonical label.

Tom Duff → knownFor → Duff's device ⓘ
Tom Duff → notableWork → Duff's device ⓘ
Tom Duff → developed → Duff's device ⓘ