Now that you have gotten a glimpse of some principles of performance programming, you may be wishing for software that would just take care of the details for you. And in fact, software libraries do exist to help you fulfill your quest for speed. Yet there are reasons for using such libraries that have nothing to do with performance. By calling a library, you can...

  • Save valuable programming time
  • Gain access to software that has been vetted for a variety of platforms
  • Ease the process of getting a large software application to function correctly

Assuming the library is one that is widely used in the HPC arena, the ultimate benefit is that it very likely has been optimized for a variety of platforms. The rationale for using a library is therefore similar to that for choosing a high-level language over assembly language: it involves far fewer lines of code, permits higher-level (more abstract) reasoning about the algorithm, and can be expected to perform very well, while freeing the programmer from the need to know about and keep track of hardware details. Implication: before you write a line of code, try to see if a routine exists in a performance library that already meets your needs.

Diagram with a series of five boxes representing five stages of code development, with arrows pointing from one box to the next. The second arrow is accompanied by an oval suggesting that both data locality and libraries are important when making the transition from an algorithm to high-level code.
Existing HPC libraries that already take account of data locality can be helpful in getting code to run well on a per-core basis.

Later in this roadmap, we give a few examples through which we hope to persuade the reader that writing high-performing numerical code for HPC is not a short or simple process. Trying to re-engineer both the performance and reliability of a good library can be more than doubly difficult. And if reinventing the wheel is not an appealing option, how much less appealing is it to reinvent a well-tuned sports car? Even if you have the expertise, you don't have the years of time it would take to do a decent job. Fortunately, others have already done the work for you, and made it available in the form of libraries.

To ensure that one's code stays maintainable, it is best to select a library that is fairly popular, so it will continue to be developed by third parties that are already familiar with its API and functionality. MPI is a good example: many highly successful implementations exist, both commercial (e.g., Intel MPI, Cray MPI) and non-commercial (e.g., MVAPICH). Variants have arisen over time to take advantage of diverse hardware and software environments, yet no implementation has ever strayed too far from the standard MPI specification. Indeed, most of the present ones are either proprietary or open-source customizations of an open-source MPICH baseline.

Just as you wouldn't try to write your own MPI library, why would you try to write your own math solvers? As with MPI, there are a lot of highly tuned, very successful implementations already available. Thus you might want to think about whether you can recast your problem in order to use a standard mathematical library. In particular, many algorithms can be re-expressed as linear algebra operations. With a bit of knowledge of linear algebra and of the typical functions available from popular HPC libraries like the Basic Linear Algebra Subprograms or BLAS,, you open up a whole new world of possibilities. The same applies to any domain that has seen exposure to research in numerical methods.

If a method you need isn't available in an existing library, consider collaborating with software developers who might want to add it to theirs. This increases the exposure of your preferred method, which is generally a desirable thing. It also increases the chances of having the software be maintained and vetted by third parties in the future.

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Inclusivity Statement