Sun Studio 12: C User's Guide

3.1 Overview

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, it does not matter in what order the iterations are executed or if they are executed in parallel. Many, though not all, vector loops fall into this category.

Because of the way aliasing works in C, it is difficult to determine the safety of parallelization. To help the compiler, Sun 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.

3.1.1 Example of Use

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


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

This generates an executable called example, which can be executed normally. If you wish to take advantage of multiprocessor execution, see B.2.69 -xautopar.