aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-general.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-07-09 12:07:17 +0200
committerJakub Jelinek <jakub@redhat.com>2020-07-09 12:07:17 +0200
commit5acef69f9d3d9f3c537b5e5157519edf02f86c4d (patch)
treeaf18107dc1e787b46c735b2eea3fad74d6b091a2 /gcc/omp-general.h
parentea82325afeccf3604f393916832eaadcbe1225bd (diff)
downloadgcc-5acef69f9d3d9f3c537b5e5157519edf02f86c4d.zip
gcc-5acef69f9d3d9f3c537b5e5157519edf02f86c4d.tar.gz
gcc-5acef69f9d3d9f3c537b5e5157519edf02f86c4d.tar.bz2
openmp: Optimize triangular loop logical iterator to actual iterators computation using search for quadratic equation root(s)
This patch implements the optimized logical to actual iterators computation for triangular loops. I have a rough implementation using integers, but this one uses floating point. There is a small problem that -fopenmp programs aren't linked with -lm, so it does it only if the hw has sqrt optab (and uses ifn rather than __builtin_sqrt because it obviously doesn't need errno handling etc.). Do you think it is ok this way, or should I use the integral computation using inlined isqrt (we have inequation of the form start >= x * t10 + t11 * (((x - 1) * x) / 2) where t10 and t11 are signed long long values and start unsigned long long, and the division by 2 actually is a problem for accuracy in some cases, so if we do it in integral, we need to do actually long long t12 = 2 * t10 - t11; unsigned long long t13 = t12 * t12 + start * 8 * t11; unsigned long long isqrt_ = isqrtull (t13); long long x = (((long long) isqrt_ - t12) / t11) >> 1; with careful overflow checking on all the computations before isqrtull (and on overflows use the fallback implementation). 2020-07-09 Jakub Jelinek <jakub@redhat.com> * omp-general.h (struct omp_for_data): Add min_inner_iterations and factor members. * omp-general.c (omp_extract_for_data): Initialize them and remember them in OMP_CLAUSE_COLLAPSE_COUNT if needed and restore from there. * omp-expand.c (expand_omp_for_init_counts): Fix up computation of counts[fd->last_nonrect] if fd->loop.n2 is INTEGER_CST. (expand_omp_for_init_vars): For fd->first_nonrect + 1 == fd->last_nonrect loops with for now INTEGER_CST fd->loop.n2 find quadratic equation roots instead of using fallback method when possible. * testsuite/libgomp.c/loop-19.c: New test. * testsuite/libgomp.c/loop-20.c: New test.
Diffstat (limited to 'gcc/omp-general.h')
-rw-r--r--gcc/omp-general.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/omp-general.h b/gcc/omp-general.h
index a763965..ec0f2a4 100644
--- a/gcc/omp-general.h
+++ b/gcc/omp-general.h
@@ -78,6 +78,13 @@ struct omp_for_data
unsigned char sched_modifiers;
enum omp_clause_schedule_kind sched_kind;
struct omp_for_data_loop *loops;
+ /* The following are relevant only for non-rectangular loops
+ where only a single loop depends on an outer loop iterator. */
+ tree min_inner_iterations; /* Number of iterations of the inner
+ loop with either the first or last
+ outer iterator, depending on which
+ results in fewer iterations. */
+ tree factor; /* (m2 - m1) * outer_step / inner_step. */
};
#define OACC_FN_ATTRIB "oacc function"