Oracle® Solaris Studio 12.4: C User's Guide

Exit Print View

Updated: March 2015
 
 

3.2 Automatic Parallelization

The C compiler generates parallel code for those loops that it determines are safe to parallelize. Typically, these loops have iterations that are independent of each other. For such loops, the order in which iterations are executed or if they are executed in parallel, does not matter. Many, though not all, vector loops fall into this category.

Because of the way aliasing works in C, determining the safety of parallelization is difficult. To help the compiler, Solaris Studio C offers pragmas and additional pointer qualifications to provide aliasing information known to the programmer that the compiler cannot determine. See Chapter 5, Type-Based Alias Analysis for more information.

The following example illustrates how to enable and control parallelized C:

% cc -fast -xO4 -xautopar example.c -o example

This compiler command generates an executable called example, which can be executed normally. To find out how to take advantage of multiprocessor execution, see -xautopar.