User`s guide

Optional Optimizations [9]
Alternatively, you can enable scalar replacement for individual aggregates by using
the mta assert can replace pragma. This pragma, which takes a list of
aggregates and/or aggregate pointers, serves two purposes. First, it tells the compiler
that it is safe to perform scalar replacement on the aggregates or pointers listed. The
compiler follows this assertion even if it was unable to prove that the replacement
was safe. Second, it is a request to replace the listed aggregates even if the code
was not compiled with the -scalar_replacement flag. This pragma is useful
in situations where the compiler would not be able to verify that a key aggregate is
replaceable. You can also use this pragma in situations where, because of the extra
memory references, you do not want to enable scalar replacement for an entire source
file, but where you need a particular aggregate to be replaced in order to achieve
automatic loop parallelization.
For example, consider the loop in the method doit below:
class foo {
int * restrict b;
int n;
public:
#pragma mta no inline
void doit(int *c) {
int i;
#pragma mta assert noalias *this
for (i = 1; i < n; ++i) {
b[i] = b[i-1] + c[i-1];
}
};
};
Without scalar replacement, this parallel recurrence loop will not parallelize, because
the accesses to the b array, which are accesses into a field of the aggregate *this,
defy alias analysis. By adding an mta assert can replace pragma, however,
the loop will parallelize as can be seen in the canal report:
| #pragma mta no inline
| void doit(int *c) {
** scalar replacing *this
| int i;
|
| #pragma mta assert noalias *this
| #pragma mta assert can replace *this
| for (i = 1; i < n; ++i) {
5 L | b[i] = b[i-1] + c[i-1];
|}
|};
|};
The can replace assertion also has a loop- specific variant, mta assert
loop can replace, which requests scalar replacement for a specific loop instead
of an entire function. In this case we copy into the temporaries immediately before
the loop, and copy back into the aggregate immediately after the loop. Any accesses
S247920 97