C code appropriate for hardware acceleration, Ideal acceleration candidates, C code appropriate for hardware acceleration –13 – Altera Nios II C2H Compiler User Manual

Page 19

Advertising
background image

Altera Corporation

9.1

1–13

November 2009

Nios II C2H Compiler User Guide

Introduction to the C2H Compiler

C Code
Appropriate for
Hardware
Acceleration

This section describes guidelines for identifying code that is appropriate
for the C2H Compiler.

Ideal Acceleration Candidates

Sections of C code that consume the most CPU time with the least amount
of code are excellent candidates for acceleration. These tend to have the
following characteristics:

They contain a relatively small and simple loop or set of nested
loops.

They iterate over a set of data, performing one or more operations on
the data per iteration, and then store the result.

Examples of such iterative tasks include memory copy-and-modify tasks,
checksum calculations, data encryption, decryption, and filtering
operations. In each of these cases, the C code iterates over a set of data
many times, with either one or more memory reads or writes performed
during each iteration.

Example 1–1

demonstrates a routine that performs a checksum

calculation. This code excerpt is from a TCP/IP stack, and it calculates the
checksum over ranges of data in a network protocol stack. Checksum
calculations are typically a time-consuming part of an IP stack, because all
data transmitted and received must be validated, which requires the
processor to loop through all bytes.

Advertising