source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB163-simdmissinglock1-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: 953 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/*
11Concurrent access of var@31:7 has no atomicity violation. No data race present.
12*/
13
14#include <stdio.h>
15#include <omp.h>
16#define N 100
17#define C 64
18
19int main(){
20 int var[C];
21
22 for(int i=0; i<C; i++){
23 var[i]=0;
24 }
25
26 #pragma omp target map(tofrom:var[0:C]) device(0)
27 #pragma omp teams distribute parallel for reduction(+:var)
28 for (int i=0; i<N; i++){
29 #pragma omp simd
30 for(int i=0; i<C; i++){
31 var[i]++;
32 }
33 }
34
35 for(int i=0; i<C; i++){
36 if(var[i]!=100){
37 printf("%d\n",var[i]);
38 }
39 }
40
41 return 0;
42}
Note: See TracBrowser for help on using the repository browser.