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.

Try in SPARQL Jump to: Statements Referenced by

Statements (49)

Predicate Object
instanceOf C programming idiom
code optimization technique
loop unrolling technique
author Tom Duff NERFINISHED
category low-level optimization
systems programming idiom
creationYear 1983
creator Tom Duff NERFINISHED
discussedIn The C Programming Language community NERFINISHED
comp.lang.c newsgroup NERFINISHED
documentedIn Tom Duff's original email to the C mailing list NERFINISHED
exploitsLanguageFeature C's relaxed grammar for statement placement
switch-case fall-through
firstUseContext Lucasfilm graphics system NERFINISHED
firstUseDomain graphics programming GENERATED
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 GENERATED
typicalUseCase copying arrays of bytes
copying arrays of shorts
copying arrays of words
usesControlStructure case labels
do-while loop
fall-through behavior
switch statement

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