github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}--> :warning: C/C++ code formatter, clang-format found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash git-clang-format --diff 30240e428f0ec7d4a6d1b84f9f807ce12b46cfd1 8b25e95008c4d794c4423d026c39382a0c7cfbf8 -- openmp/tools/archer/tests/races/DRB006-indirectaccess2-orig-yes.c clang/lib/CodeGen/CGOpenMPRuntime.cpp `````````` </details> <details> <summary> View the diff from clang-format here. </summary> ``````````diff diff --git a/openmp/tools/archer/tests/races/DRB006-indirectaccess2-orig-yes.c b/openmp/tools/archer/tests/races/DRB006-indirectaccess2-orig-yes.c index c9d1bf0ae..bfa451484 100644 --- a/openmp/tools/archer/tests/races/DRB006-indirectaccess2-orig-yes.c +++ b/openmp/tools/archer/tests/races/DRB006-indirectaccess2-orig-yes.c @@ -57,19 +57,21 @@ THE POSSIBILITY OF SUCH DAMAGE. */ /* Two pointers have a distance of 12 (p1 - p2 = 12). -They are used as base addresses for indirect array accesses using an index set (another array). +They are used as base addresses for indirect array accesses using an index set +(another array). The index set has two indices with a distance of 12 : indexSet[5]- indexSet[0] = 533 - 521 = 12 -So there is loop carried dependence (e.g. between loops with index values of 0 and 5). +So there is loop carried dependence (e.g. between loops with index values of 0 +and 5). We use the default loop scheduling (static even) in OpenMP. It is possible that two dependent iterations will be scheduled within a same chunk to a same thread. So there is no runtime data races. When N is 180, two iterations with N=0 and N= 5 have loop carried dependencies. -For static even scheduling, we must have at least 36 threads (180/36=5 iterations) -so iteration 0 and 5 will be scheduled to two different threads. +For static even scheduling, we must have at least 36 threads (180/36=5 +iterations) so iteration 0 and 5 will be scheduled to two different threads. Data race pair: xa1[idx]@128:5:W vs. xa2[idx]@129:5:W */ @@ -78,74 +80,63 @@ Data race pair: xa1[idx]@128:5:W vs. xa2[idx]@129:5:W // REQUIRES: tsan #include <omp.h> #include <stdio.h> -#include <unistd.h> #include <stdlib.h> +#include <unistd.h> #define NUM_THREADS 2 #define N 180 -int indexSet[N] = { -521, 523, 525, 527, 529, 533, // 521+12=533 -547, 549, 551, 553, 555, 557, -573, 575, 577, 579, 581, 583, -599, 601, 603, 605, 607, 609, -625, 627, 629, 631, 633, 635, - -651, 653, 655, 657, 659, 661, -859, 861, 863, 865, 867, 869, -885, 887, 889, 891, 893, 895, -911, 913, 915, 917, 919, 921, -937, 939, 941, 943, 945, 947, - -963, 965, 967, 969, 971, 973, -989, 991, 993, 995, 997, 999, -1197, 1199, 1201, 1203, 1205, 1207, -1223, 1225, 1227, 1229, 1231, 1233, -1249, 1251, 1253, 1255, 1257, 1259, - -1275, 1277, 1279, 1281, 1283, 1285, -1301, 1303, 1305, 1307, 1309, 1311, -1327, 1329, 1331, 1333, 1335, 1337, -1535, 1537, 1539, 1541, 1543, 1545, -1561, 1563, 1565, 1567, 1569, 1571, - -1587, 1589, 1591, 1593, 1595, 1597, -1613, 1615, 1617, 1619, 1621, 1623, -1639, 1641, 1643, 1645, 1647, 1649, -1665, 1667, 1669, 1671, 1673, 1675, -1873, 1875, 1877, 1879, 1881, 1883, - -1899, 1901, 1903, 1905, 1907, 1909, -1925, 1927, 1929, 1931, 1933, 1935, -1951, 1953, 1955, 1957, 1959, 1961, -1977, 1979, 1981, 1983, 1985, 1987, -2003, 2005, 2007, 2009, 2011, 2013}; - -int main (int argc, char* argv[]) -{ - double * base = (double*) malloc(sizeof(double)* (2013+12+1)); +int indexSet[N] = {521, 523, 525, 527, 529, 533, // 521+12=533 + 547, 549, 551, 553, 555, 557, 573, 575, 577, 579, + 581, 583, 599, 601, 603, 605, 607, 609, 625, 627, + 629, 631, 633, 635, + + 651, 653, 655, 657, 659, 661, 859, 861, 863, 865, + 867, 869, 885, 887, 889, 891, 893, 895, 911, 913, + 915, 917, 919, 921, 937, 939, 941, 943, 945, 947, + + 963, 965, 967, 969, 971, 973, 989, 991, 993, 995, + 997, 999, 1197, 1199, 1201, 1203, 1205, 1207, 1223, 1225, + 1227, 1229, 1231, 1233, 1249, 1251, 1253, 1255, 1257, 1259, + + 1275, 1277, 1279, 1281, 1283, 1285, 1301, 1303, 1305, 1307, + 1309, 1311, 1327, 1329, 1331, 1333, 1335, 1337, 1535, 1537, + 1539, 1541, 1543, 1545, 1561, 1563, 1565, 1567, 1569, 1571, + + 1587, 1589, 1591, 1593, 1595, 1597, 1613, 1615, 1617, 1619, + 1621, 1623, 1639, 1641, 1643, 1645, 1647, 1649, 1665, 1667, + 1669, 1671, 1673, 1675, 1873, 1875, 1877, 1879, 1881, 1883, + + 1899, 1901, 1903, 1905, 1907, 1909, 1925, 1927, 1929, 1931, + 1933, 1935, 1951, 1953, 1955, 1957, 1959, 1961, 1977, 1979, + 1981, 1983, 1985, 1987, 2003, 2005, 2007, 2009, 2011, 2013}; + +int main(int argc, char *argv[]) { + double *base = (double *)malloc(sizeof(double) * (2013 + 12 + 1)); if (base == 0) { - printf ("Error in malloc(). Aborting ...\n"); - return 1; + printf("Error in malloc(). Aborting ...\n"); + return 1; } - double * xa1 = base; - double * xa2 = xa1 + 12; + double *xa1 = base; + double *xa2 = xa1 + 12; int i; // initialize segments touched by indexSet - for (i =521; i<= 2025; ++i) { - base[i]=0.5*i; + for (i = 521; i <= 2025; ++i) { + base[i] = 0.5 * i; } -#pragma omp parallel for num_threads(NUM_THREADS) //schedule(static, 1) // default static even scheduling may not trigger data race! - for (i =0; i< N; ++i) { +#pragma omp parallel for num_threads( \ + NUM_THREADS) // schedule(static, 1) // default static even scheduling + // may not trigger data race! + for (i = 0; i < N; ++i) { int idx = indexSet[i]; - xa1[idx]+= 1.0; - xa2[idx]+= 3.0; + xa1[idx] += 1.0; + xa2[idx] += 3.0; } printf("x1[999]=%f xa2[1285]=%f\n", xa1[999], xa2[1285]); - free (base); + free(base); fprintf(stderr, "DONE\n"); return 0; } @@ -157,5 +148,3 @@ int main (int argc, char* argv[]) // CHECK-NEXT: #0 {{.*}}DRB006-indirectaccess2-orig-yes.c:145 // CHECK: DONE // CHECK: ThreadSanitizer: reported {{[0-9]+}} warnings - - `````````` </details> https://github.com/llvm/llvm-project/pull/68891 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits