24.02.2014 Views

Parallel Processing: A KISS Approach - University of North Dakota

Parallel Processing: A KISS Approach - University of North Dakota

Parallel Processing: A KISS Approach - University of North Dakota

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

calls are required (to libraries, etc) and s<strong>of</strong>tware engineering principles tell us to use<br />

functions to improve code readability and maintainability. Another issue is the<br />

development <strong>of</strong> loops. It is well known that most programs spend most <strong>of</strong> their time<br />

within a loop. In staying with the <strong>KISS</strong> approach we will concentrate our discussion on<br />

loops with function calls as this generally has the greatest impact on performance.<br />

Many programs spend much <strong>of</strong> their execution time in loops. Therefore, it is especially<br />

important to be able to write loop code effectively. There are 3 basic practices:<br />

1. Simplifying the loop construct.<br />

2. Removing non-dependent function calls from within a loop.<br />

3. Removing excessive non-dependent memory accesses.<br />

Here is an example <strong>of</strong> a poorly designed loop:<br />

for (I = 0; I < (s+2); I++) { // not simple<br />

j = cos(φ);<br />

// function call<br />

k = array_element[6]; // memory access<br />

new_data[I] = (j+k)*I;<br />

}<br />

The loop construct is not simple (I

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!