source: CIVL/examples/omp/defect_num_544.c@ 631a953

1.23 2.0 main test-branch
Last change on this file since 631a953 was 166fc1f, checked in by Matthew B. Dwyer <matthewbdwyer@…>, 11 years ago

Ticket 544 intermediate commit. Bounding conditions are not being computed accurately. This example is not simplifiable, but it should not throw an exception. Immediate fix is easy. Consider copy propagation fix - still wouldn't be simplifiable. Consider non-aliasing fix - still wouldn't be simplifiable.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@2688 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.4 KB
Line 
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
19void 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
31void 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
43int 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}
Note: See TracBrowser for help on using the repository browser.