source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB164-simdmissinglock1-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.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/*
11This kernel is referred from “DataRaceOnAccelerator A Micro-benchmark Suite for Evaluating
12Correctness Tools Targeting Accelerators” by Adrian Schmitz et al.
13Concurrent access of var@35:7 without acquiring locks causes atomicity violation. Data race present.
14Data Race Pairs, var@35:7 and var@35:7.
15*/
16
17#include <stdio.h>
18#include <omp.h>
19#define N 100
20#define C 64
21
22int main(){
23
24 int var[C];
25
26 for(int i=0; i<C; i++){
27 var[i]=0;
28 }
29
30 #pragma omp target map(tofrom:var[0:C]) device(0)
31 #pragma omp teams distribute parallel for
32 for (int i=0; i<N; i++){
33 #pragma omp simd
34 for(int i=0; i<C; i++){
35 var[i]++;
36 }
37 }
38
39 printf("%d\n",var[63]);
40
41 return 0;
42}
Note: See TracBrowser for help on using the repository browser.