source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB155-missingordered-orig-gpu-no.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: 983 bytes
Line 
1/*
2!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
3!!! Copyright (c) 2017-20, Lawrence Livermore National Security, LLC
4!!! and DataRaceBench project contributors. See the DataRaceBench/COPYRIGHT file for details.
5!!!
6!!! SPDX-License-Identifier: (BSD-3-Clause)
7!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!
8*/
9
10/*
11By utilizing the ordered construct @29 the execution will be
12sequentially consistent. No Data Race Pair.
13*/
14
15#include <stdio.h>
16#include <omp.h>
17#include <stdlib.h>
18#define N 100
19
20int main(){
21
22 int var[N];
23
24 for(int i=0; i<N; i++){
25 var[i]=0;
26 }
27
28 #pragma omp target map(tofrom:var[0:N]) device(0)
29 #pragma omp parallel for ordered
30 for (int i=1; i<N; i++){
31 #pragma omp ordered
32 {
33 var[i]=var[i-1]+1;
34 }
35 }
36
37 for(int i=0; i<N; i++){
38 if(var[i]!=i){
39 printf("Data Race Present");
40 return 0;
41 }
42 }
43
44 return 0;
45}
Note: See TracBrowser for help on using the repository browser.