source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB138-simdsafelen-orig-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: 942 bytes
RevLine 
[e3f356c]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/* The safelen(2) clause at safelen(2)@24:20 guarantees that the vector code is safe for vectors
11 * up to 2 (inclusive). In the loop, m@25:12 can be 2 or more for the correct execution. If the
12 * value of m is less than 2, the behavior is undefined.
13 * Data Race Pair: b[i]@26:5 and b[i-m]@26:12.
14 * */
15
16#include <stdio.h>
17#include <omp.h>
18
19int main(){
20
21 int i, m=1, n=4;
22 int b[4] = {};
23
24 #pragma omp simd safelen(2)
25 for (i = m; i<n; i++)
26 b[i] = b[i-m] - 1.0f;
27
28 printf("Expected: -1; Real: %d\n",b[3]);
29 return 0;
30}
Note: See TracBrowser for help on using the repository browser.