| 1 | /*
|
|---|
| 2 | * This program captures VSL ticket #544
|
|---|
| 3 | * https://vsl.cis.udel.edu/trac/civl/ticket/544
|
|---|
| 4 | * which reports an error in the OpenMP Simplifier.
|
|---|
| 5 | */
|
|---|
| 6 | #include <omp.h>
|
|---|
| 7 | #include <stdio.h>
|
|---|
| 8 | #include <stdlib.h>
|
|---|
| 9 |
|
|---|
| 10 | #ifdef _CIVL
|
|---|
| 11 | #define N 4
|
|---|
| 12 | #define NEDGES 3
|
|---|
| 13 | #else
|
|---|
| 14 | #define N 4
|
|---|
| 15 | #define NEDGES 3
|
|---|
| 16 | #endif
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | void residualPrllel(double uin[N], double resout[N], int edges[NEDGES][2], int colourIA[3]) {
|
|---|
| 20 | for(int c=0; c<2; c++) {
|
|---|
| 21 | #pragma omp parallel for default(none) shared(edges,uin,resout,colourIA,c)
|
|---|
| 22 | for(int e=colourIA[c]; e<colourIA[c+1]; e++) {
|
|---|
| 23 | int i = edges[e][0];
|
|---|
| 24 | int j = edges[e][1];
|
|---|
| 25 | resout[i] = resout[i] + uin[i]*uin[j];
|
|---|
| 26 | resout[j] = resout[j] + 2*uin[i]+2*uin[j];
|
|---|
| 27 | }
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | void residualPrllel_defect(double uin[N], double resout[N], int edges[NEDGES][2], int colourIA[3]) {
|
|---|
| 32 | for(int c=0; c<2; c++) {
|
|---|
| 33 | #pragma omp parallel for default(none) shared(edges,uin,resout,colourIA,c)
|
|---|
| 34 | for(int e=colourIA[c]; e<colourIA[c+1]; e++) {
|
|---|
| 35 | int i = edges[e][0];
|
|---|
| 36 | int j = edges[e][1];
|
|---|
| 37 | resout[i] += uin[i]*uin[j];
|
|---|
| 38 | resout[j] += 2*uin[i]+2*uin[j];
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | int main (int argc, char *argv[]) {
|
|---|
| 44 | double input[N];
|
|---|
| 45 | double output[N];
|
|---|
| 46 | int edges[NEDGES][2];
|
|---|
| 47 | int colors[3] = {0, 1, 2};
|
|---|
| 48 |
|
|---|
| 49 | for (int i=0; i<N; i++) {
|
|---|
| 50 | input[i] = i;
|
|---|
| 51 | output[i] = 0;
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | residualPrllel(input, output, edges, colors);
|
|---|
| 55 |
|
|---|
| 56 | for (int i=0; i<N; i++) {
|
|---|
| 57 | input[i] = i;
|
|---|
| 58 | output[i] = 0;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | residualPrllel_defect(input, output, edges, colors);
|
|---|
| 62 | }
|
|---|