#ifndef HEADER
#define HEADER
void loop_with_counter_collapse() {
#pragma omp for collapse(2)
for (int i = 0; i < 4; i++) {
for (int j = i; j < 4 + i; j++) {
}
}
}
void loop_with_counter_collapse4() {
#pragma omp for collapse(4)
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 11; j++) {
for (int k = i; k < 7; k++) {
for (int l = 0; l < 11; l++) {
}
}
}
}
}
void without_schedule_clause(float *a, float *b, float *c, float *d) {
#pragma omp for nowait
for (int i = 33; i < 32000000; i += 7) {
a[i] = b[i] * c[i] * d[i];
}
}
void static_not_chunked(float *a, float *b, float *c, float *d) {
#pragma omp for schedule(static)
for (int i = 32000000; i > 33; i += -7) {
a[i] = b[i] * c[i] * d[i];
}
}
void static_chunked(float *a, float *b, float *c, float *d) {
#pragma omp for schedule(monotonic: static, 5)
for (unsigned i = 131071; i <= 2147483647; i += 127) {
a[i] = b[i] * c[i] * d[i];
}
}
void dynamic1(float *a, float *b, float *c, float *d) {
#pragma omp for schedule(nonmonotonic: dynamic)
for (unsigned long long i = 131071; i < 2147483647; i += 127) {
a[i] = b[i] * c[i] * d[i];
}
}
void guided7(float *a, float *b, float *c, float *d) {
#pragma omp for schedule(guided, 7)
for (unsigned long long i = 131071; i < 2147483647; i += 127) {
a[i] = b[i] * c[i] * d[i];
}
}
void test_auto(float *a, float *b, float *c, float *d) {
unsigned int x = 0;
unsigned int y = 0;
#pragma omp for schedule(auto) collapse(2)
for (char i = static_cast<char>(y); i <= '9'; ++i)
for (x = 11; x > 0; --x) {
a[i] = b[i] * c[i] * d[i];
}
}
void runtime(float *a, float *b, float *c, float *d) {
int x = 0;
#pragma omp for collapse(2) schedule(runtime)
for (unsigned char i = '0' ; i <= '9'; ++i)
for (x = -10; x < 10; ++x) {
a[i] = b[i] * c[i] * d[i];
}
}
void test_precond() {
char a = 0;
#pragma omp for
for(char i = a; i < 10; ++i);
}
int foo() { extern void mayThrow(); mayThrow(); return 0;};
void parallel_for(float *a) {
#pragma omp parallel
#pragma omp for schedule(static, 5)
for (unsigned i = 131071; i <= 2147483647; i += 127)
a[i] += foo();
}
char i = 1, j = 2, k = 3;
void for_with_global_lcv() {
#pragma omp for
for (i = 0; i < 2; ++i) {
k = i;
}
#pragma omp for collapse(2)
for (int i = 0; i < 2; ++i)
for (j = 0; j < 2; ++j) {
k = i;
k = j;
}
char &cnt = i;
#pragma omp for
for (cnt = 0; cnt < 2; ++cnt)
k = cnt;
}
void for_with_references() {
char i = 0;
char &cnt = i;
#pragma omp for collapse(2)
for (cnt = 0; cnt < 2; ++cnt)
for (int j = cnt; j < 4 + cnt; j++)
k = cnt;
}
void for_with_references_dep_cond() {
char i = 0;
char &cnt = i;
#pragma omp for collapse(2)
for (cnt = 0; cnt < 2; ++cnt)
for (int j = 0; j < 4 + cnt; j++)
k = cnt;
}
struct Bool {
Bool(bool b) : b(b) {}
operator bool() const { return b; }
const bool b;
};
template <typename T>
struct It {
It() : p(0) {}
It(const It &, int = 0) ;
template <typename U>
It(U &, int = 0) ;
It &operator=(const It &);
It &operator=(It &);
~It() {}
It(T *p) : p(p) {}
operator T *&() { return p; }
operator T *() const { return p; }
T *operator->() const { return p; }
It &operator++() { ++p; return *this; }
It &operator--() { --p; return *this; }
It &operator+=(unsigned n) { p += n; return *this; }
It &operator-=(unsigned n) { p -= n; return *this; }
T *p;
};
template <typename T>
It<T> operator+(It<T> a, typename It<T>::difference_type n) { return a.p + n; }
template <typename T>
It<T> operator+(typename It<T>::difference_type n, It<T> a) { return a.p + n; }
template <typename T>
It<T> operator-(It<T> a, typename It<T>::difference_type n) { return a.p - n; }
typedef Bool BoolType;
template <typename T>
BoolType operator<(It<T> a, It<T> b) { return a.p < b.p; }
void loop_with_It(It<char> begin, It<char> end) {
#pragma omp for
for (It<char> it = begin; it < end; ++it) {
*it = 0;
}
}
void loop_with_It_plus(It<char> begin, It<char> end) {
#pragma omp for
for (It<char> it = begin; it < end; it+=1u) {
*it = 0;
}
}
void loop_with_stmt_expr() {
#pragma omp for collapse(2)
for (int i = __extension__({float b = 0;b; }); i < __extension__({double c = 1;c; }); i += __extension__({char d = 1; d; }))
for (int j = i; j < 4 + i; j++)
;
}
template <typename T>
T ftemplate() {
short aa = 0;
#pragma omp parallel for schedule(static, aa)
for (int i = 0; i < 100; i++) {
}
return T();
}
int fint(void) { return ftemplate<int>(); }
#if _OPENMP == 201811
void first();
void last();
void inner_f();
void inner_l();
void body_f();
void imperfectly_nested_loop() {
#pragma omp for collapse(3) order(concurrent)
for (int i = 0; i < 10; ++i) {
{
int a, d;
first();
a = d;
for (int j = 0; j < 10; ++j) {
int a, d;
inner_f();
a = d;
for (int k = 0; k < 10; ++k) {
int a, d;
body_f();
a = d;
}
inner_l();
}
last();
}
}
}
#endif
#endif