Programming Itanium-based Systems: Developing High Performance Applications for Intel's New Architecture

Chapter 12: An Optimization Case Study

Thomas Edison once described genius as one percent inspiration and ninety-nine percent perspiration. And the same can be said, sometimes, of optimization. Good theory is part of the equation, but actually trying and testing and adjusting different code scenarios is often where the bulk of one s time may be spent. This chapter presents the story of the optimization of an illustrative function, followed through 27 different code builds, showing what worked and what didn t, noting where theory succeeded and where it failed, and encountering a few surprises along the way.

Test Function

Good science is often based on simple experiments and test cases, and it turns out that a relatively simple function is not only adequate, but appropriate, for exploring the principles of optimization. The function chosen for testing in this chapter simply counts the number of ASCII words found in a given stretch of memory, where a word is defined as any contiguous set of alphabetic characters bounded by either nonalphabetic characters or the ends of the search region. In other words, it s a word counter.

Figure 12.1 shows the first, simple version of the function used for testing. In order to be able to easily compare various versions of the function, including those that use multimedia instructions and require data to be aligned on 8-byte boundaries, the pointer to the region of memory to be analyzed is here constrained to be a pointer to data of type __m64, the multimedia type. To accommodate loop unrolling in one version...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Torque Wrenches
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.