Image

Multicore Programming Practices Worth A Read

March 7, 2013
The Multicore Association (MCA) just released the first Multicore Programming Practices guide that you can download for free.

The Multicore Association (MCA) just released the first Multicore Programming Practices guide that you can download for free. The MCA is also know for its array of multicore APIs including:

These have been out for awhile and I wanted to give the guide a read before writing about it. It is rather extensive but well worth reading. It addresses everything from load balancing to debugging. It is not all encompassing but it is pretty broad in the areas it does cover. It is worth reading even if you are not into embedded multicore programming yet because it provides a good overview the available techniques being employed in the industry.

The level of detail and number of examples varies significantly from section to section. For example, the load balancing section addresses the topic area and introduces top-down, bottom-up and hybrid decomposition but not much more.

The section on threading is more helpful. There are a number of C++ code examples. PThreads are examined closely. There is even PThreads example for loop parallelism.

The debugging section was on the thin side. It starts with general recommendations like this:

  1. Debug a serial version of the application.
  2. Use defensive coding practices when parallelizing serial applications.
  3. Debug a parallel version executing serially.
  4. Debug a parallel version using an increasing number of parallel tasks.

It is not a bad start and a good way to approach the problem but there is not much on how. Of course, that would require more specific target tool information.

One section I really liked was optimization. It does get into some details that are useful. For example, it discusses the use of restrict with C pointers (Fig. 1). This feature was introduced in C99 (ISO/IEC 9899:1999 standard). It even notes that it is not a standard C++ feature although many C/C++ compilers often include the support.

/* File: restrict.c */
void f (int* restrict dest, int * restrict src, int n) {
  int i;
  for (i=0;i < n; i++){
    dest[i]=src[i];
  }
}

Some examples are platform specific like the one addressing SIMD vectorization. Here it mentions AltiVec and uses an x86 SSE intrinsic library. It is a simple example but easy to extrapolate to other implementations. The discussion is also general so the comments apply to any almost SIMD environment.

There may be an item or two for some to quibble with but overall this is an impressive collection. Don't forget to read the appendices because they are useful as well.
 

About the Author

William G. Wong | Senior Content Director - Electronic Design and Microwaves & RF

I am Editor of Electronic Design focusing on embedded, software, and systems. As Senior Content Director, I also manage Microwaves & RF and I work with a great team of editors to provide engineers, programmers, developers and technical managers with interesting and useful articles and videos on a regular basis. Check out our free newsletters to see the latest content.

You can send press releases for new products for possible coverage on the website. I am also interested in receiving contributed articles for publishing on our website. Use our template and send to me along with a signed release form. 

Check out my blog, AltEmbedded on Electronic Design, as well as his latest articles on this site that are listed below. 

You can visit my social media via these links:

I earned a Bachelor of Electrical Engineering at the Georgia Institute of Technology and a Masters in Computer Science from Rutgers University. I still do a bit of programming using everything from C and C++ to Rust and Ada/SPARK. I do a bit of PHP programming for Drupal websites. I have posted a few Drupal modules.  

I still get a hand on software and electronic hardware. Some of this can be found on our Kit Close-Up video series. You can also see me on many of our TechXchange Talk videos. I am interested in a range of projects from robotics to artificial intelligence. 

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!