source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB161-nolocksimd-orig-gpu-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: 1.0 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/*
11This example is from DRACC by Adrian Schmitz et al.
12Concurrent access on a counter with no lock with simd. Atomicity Violation. Intra Region.
13Data Race Pairs: var@33:7 and var@33:7.
14*/
15
16#include <stdio.h>
17#define N 20
18#define C 8
19
20int main(){
21 int var[C];
22
23 for(int i=0; i<C; i++){
24 var[i] = 0;
25 }
26
27 #pragma omp target map(tofrom:var) device(0)
28 #pragma omp teams num_teams(1) thread_limit(1048)
29 #pragma omp distribute parallel for
30 for (int i=0; i<N; i++){
31 #pragma omp simd
32 for(int i=0; i<C; i++){
33 var[i]++;
34 }
35 }
36
37 for(int i=0; i<C; i++){
38 if(var[i]!=N) printf("%d\n ",var[i]);
39 }
40
41 return 0;
42}
Note: See TracBrowser for help on using the repository browser.