source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB032-truedepfirstdimension-var-yes.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

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

  • Property mode set to 100755
File size: 2.9 KB
Line 
1/*
2Copyright (c) 2017, Lawrence Livermore National Security, LLC.
3Produced at the Lawrence Livermore National Laboratory
4Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund,
5Markus Schordan, and Ian Karlin
6(email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov,
7schordan1@llnl.gov, karlin1@llnl.gov)
8LLNL-CODE-732144
9All rights reserved.
10
11This file is part of DataRaceBench. For details, see
12https://github.com/LLNL/dataracebench. Please also see the LICENSE file
13for our additional BSD notice.
14
15Redistribution and use in source and binary forms, with
16or without modification, are permitted provided that the following
17conditions are met:
18
19* Redistributions of source code must retain the above copyright
20 notice, this list of conditions and the disclaimer below.
21
22* Redistributions in binary form must reproduce the above copyright
23 notice, this list of conditions and the disclaimer (as noted below)
24 in the documentation and/or other materials provided with the
25 distribution.
26
27* Neither the name of the LLNS/LLNL nor the names of its contributors
28 may be used to endorse or promote products derived from this
29 software without specific prior written permission.
30
31THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
32CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
33INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL
36SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE
37LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
38OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
39PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
40DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
43IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
44THE POSSIBILITY OF SUCH DAMAGE.
45*/
46
47/* NOTE by WenhaoWu (wuwenhao@udel.edu)
48 * This example is modified so that the bound can be adjusted
49 * by defining 'N' and if it isn't defined then the bound value
50 * in the original example is used as the default value of 'N'
51 * And both 'argc' and 'argv' are assumed by using '$assume',
52 * which is included in <civlc.cvh>.
53 */
54#ifndef N
55#define N 1000
56#endif
57#ifdef _CIVL
58#include <civlc.cvh>
59#endif
60
61/*
62The outer loop has a loop-carried true dependence.
63Data race pair: b[i][j]@89:7 vs. b[i-1][j-1]@89:15
64*/
65#include <stdlib.h>
66int main(int argc, char* argv[])
67{
68
69#ifdef _CIVL
70 $assume(argc == 2);
71 $assume(atoi(argv[1]) == N);
72#endif
73
74 int i,j;
75 int len = 1000;
76 if (argc>1)
77 len = atoi(argv[1]);
78
79 int n=len, m=len;
80 double b[len][len];
81
82 for (i=0; i<n; i++)
83 for (j=0; j<m; j++)
84 b[i][j] = 0.5;
85
86#pragma omp parallel for private(j)
87 for (i=1;i<n;i++)
88 for (j=1;j<m;j++)
89 b[i][j]=b[i-1][j-1];
90
91 return 0;
92}
Note: See TracBrowser for help on using the repository browser.