source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB158-missingtaskbarrier-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: 1.1 KB
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/*
11Depend clause at line 33 and 37 will ensure that there is no data race. There is an implicit barrier after tasks execution.
12*/
13
14#include <stdio.h>
15#include <stdlib.h>
16#include <omp.h>
17#define C 64
18
19float a;
20float x[C];
21float y[C];
22
23int main(){
24 for(int i=0; i<C; i++){
25 a=5;
26 x[i]=0;
27 y[i]=3;
28 }
29
30 #pragma omp target map(to:y[0:C],a) map(tofrom:x[0:C]) device(0)
31 {
32 for(int i=0; i<C; i++){
33 #pragma omp task depend(inout:x[i])
34 {
35 x[i] = a * x[i];
36 }
37 #pragma omp task depend(inout:x[i])
38 {
39 x[i] = x[i] + y[i];
40 }
41 }
42 }
43
44 for(int i=0; i<C; i++){
45 if(x[i]!=3){
46 printf("Data Race Detected\n");
47 return 0;
48 }
49 }
50
51 #pragma omp taskwait
52 return 0;
53}
Note: See TracBrowser for help on using the repository browser.