source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB150-missinglock1-orig-gpu-yes.c@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 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/*
11The distribute parallel for directive at line 27 will execute loop using multiple teams.
12The loop iterations are distributed across the teams in chunks in round robin fashion.
13The omp lock is only guaranteed for a contention group, i.e, within a team. Data Race Pair, var@30:5 and var@30:5.
14*/
15
16
17#include <omp.h>
18#include <stdio.h>
19
20int main(){
21
22 omp_lock_t lck;
23 int var=0,i;
24 omp_init_lock(&lck);
25
26 #pragma omp target map(tofrom:var) device(0)
27 #pragma omp teams distribute parallel for
28 for (int i=0; i<100; i++){
29 omp_set_lock(&lck);
30 var++;
31 omp_unset_lock(&lck);
32 }
33
34 omp_destroy_lock(&lck);
35
36 printf("%d\n",var);
37 return 0;
38}
Note: See TracBrowser for help on using the repository browser.