/*This section is a complete, compilable program. Assume that it is placed in a file named ex.c and compiled with the following command: cc -c -h report=v ex.c The compiler writes vectorization information to stdout. Compile this on the Cray. In order for the report on vectorization information to be written to a file, use: cc -c -h report=vf ex.c This writes the information to ex.V (for more information: "man cc") */ #include extern int a[], b[], c[], d[], n; extern int a2[][100]; extern char s, t[], u[]; extern struct stack { int a[100]; int n; } sa, sb; extern struct point { double x, y; } p1[], p2[], * pp; extern struct vector { double x, y; } * pv; extern struct packed { int a:32; int b:32; } sc[], * ps; int *p; int *q; int *restrict rp, * restrict rq; /* int *rp; int *rq; */ #pragma _CRI vfunction vf extern int vf(int i, int j); int f(int i, int j) { return(i + j); } void examples() { int i, j, k; /* Vectorization of innermost loops: */ /* The innermost loop (do-while loop) vectorizes, */ /* the outer two loops (while loop and for loop) */ /* are not candidates for vectorization. */ i = 0; while (i<10) { for (j=0; j 0) break; } for (i=0; i 0) { break; } } /* Gather/Scatter: */ /* The first loop vectorizes, with a gather from */ /* a and a scatter to b. */ /* The second loop vectorizes, with scalar code */ /* to accommodate the potential recurrences. */ /* The third loop does not vectorize because */ /* of the potential output dependence on d. */ for (i=0; i