00001 #include <omp.h> 00002 #include <stdlib.h> 00003 #include <string.h> 00004 00005 int 00006 test1 (void) 00007 { 00008 short int buf[64], *p; 00009 int i; 00010 memset (buf, '\0', sizeof (buf)); 00011 #pragma omp parallel for 00012 for (p = &buf[10]; &buf[54] > p; p++) 00013 *p = 5; 00014 for (i = 0; i < 64; i++) 00015 if (buf[i] != 5 * (i >= 10 && i < 54)) 00016 abort (); 00017 memset (buf, '\0', sizeof (buf)); 00018 #pragma omp parallel for 00019 for (p = &buf[3]; &buf[63] >= p; p += 2) 00020 p[-2] = 6; 00021 for (i = 0; i < 64; i++) 00022 if (buf[i] != 6 * ((i & 1) && i <= 61)) 00023 abort (); 00024 memset (buf, '\0', sizeof (buf)); 00025 #pragma omp parallel for 00026 for (p = &buf[16]; &buf[51] > p; p = 4 + p) 00027 p[2] = 7; 00028 for (i = 0; i < 64; i++) 00029 if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) 00030 abort (); 00031 memset (buf, '\0', sizeof (buf)); 00032 #pragma omp parallel for 00033 for (p = &buf[16]; &buf[40] >= p; p = p + 4ULL) 00034 p[2] = -7; 00035 for (i = 0; i < 64; i++) 00036 if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) 00037 abort (); 00038 memset (buf, '\0', sizeof (buf)); 00039 #pragma omp parallel for 00040 for (p = &buf[53]; &buf[9] < p; --p) 00041 *p = 5; 00042 for (i = 0; i < 64; i++) 00043 if (buf[i] != 5 * (i >= 10 && i < 54)) 00044 abort (); 00045 memset (buf, '\0', sizeof (buf)); 00046 #pragma omp parallel for 00047 for (p = &buf[63]; &buf[3] <= p; p -= 2) 00048 p[-2] = 6; 00049 for (i = 0; i < 64; i++) 00050 if (buf[i] != 6 * ((i & 1) && i <= 61)) 00051 abort (); 00052 memset (buf, '\0', sizeof (buf)); 00053 #pragma omp parallel for 00054 for (p = &buf[48]; &buf[15] < p; p = -4 + p) 00055 p[2] = 7; 00056 for (i = 0; i < 64; i++) 00057 if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) 00058 abort (); 00059 memset (buf, '\0', sizeof (buf)); 00060 #pragma omp parallel for 00061 for (p = &buf[40]; &buf[16] <= p; p = p - 4ULL) 00062 p[2] = -7; 00063 for (i = 0; i < 64; i++) 00064 if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) 00065 abort (); 00066 return 0; 00067 } 00068 00069 int 00070 test2 (void) 00071 { 00072 int buf[64], *p; 00073 int i; 00074 memset (buf, '\0', sizeof (buf)); 00075 #pragma omp parallel for schedule (static, 3) 00076 for (p = &buf[10]; &buf[54] > p; p++) 00077 *p = 5; 00078 for (i = 0; i < 64; i++) 00079 if (buf[i] != 5 * (i >= 10 && i < 54)) 00080 abort (); 00081 memset (buf, '\0', sizeof (buf)); 00082 #pragma omp parallel for schedule (static, 3) 00083 for (p = &buf[3]; &buf[63] >= p; p += 2) 00084 p[-2] = 6; 00085 for (i = 0; i < 64; i++) 00086 if (buf[i] != 6 * ((i & 1) && i <= 61)) 00087 abort (); 00088 memset (buf, '\0', sizeof (buf)); 00089 #pragma omp parallel for schedule (static, 3) 00090 for (p = &buf[16]; &buf[51] > p; p = 4 + p) 00091 p[2] = 7; 00092 for (i = 0; i < 64; i++) 00093 if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) 00094 abort (); 00095 memset (buf, '\0', sizeof (buf)); 00096 #pragma omp parallel for schedule (static, 3) 00097 for (p = &buf[16]; &buf[40] >= p; p = p + 4ULL) 00098 p[2] = -7; 00099 for (i = 0; i < 64; i++) 00100 if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) 00101 abort (); 00102 memset (buf, '\0', sizeof (buf)); 00103 #pragma omp parallel for schedule (static, 3) 00104 for (p = &buf[53]; &buf[9] < p; --p) 00105 *p = 5; 00106 for (i = 0; i < 64; i++) 00107 if (buf[i] != 5 * (i >= 10 && i < 54)) 00108 abort (); 00109 memset (buf, '\0', sizeof (buf)); 00110 #pragma omp parallel for schedule (static, 3) 00111 for (p = &buf[63]; &buf[3] <= p; p -= 2) 00112 p[-2] = 6; 00113 for (i = 0; i < 64; i++) 00114 if (buf[i] != 6 * ((i & 1) && i <= 61)) 00115 abort (); 00116 memset (buf, '\0', sizeof (buf)); 00117 #pragma omp parallel for schedule (static, 3) 00118 for (p = &buf[48]; &buf[15] < p; p = -4 + p) 00119 p[2] = 7; 00120 for (i = 0; i < 64; i++) 00121 if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) 00122 abort (); 00123 memset (buf, '\0', sizeof (buf)); 00124 #pragma omp parallel for schedule (static, 3) 00125 for (p = &buf[40]; &buf[16] <= p; p = p - 4ULL) 00126 p[2] = -7; 00127 for (i = 0; i < 64; i++) 00128 if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) 00129 abort (); 00130 return 0; 00131 } 00132 00133 int 00134 test3 (void) 00135 { 00136 int buf[64], *p; 00137 int i; 00138 memset (buf, '\0', sizeof (buf)); 00139 #pragma omp parallel for schedule (dynamic, 3) 00140 for (p = &buf[10]; &buf[54] > p; p++) 00141 *p = 5; 00142 for (i = 0; i < 64; i++) 00143 if (buf[i] != 5 * (i >= 10 && i < 54)) 00144 abort (); 00145 memset (buf, '\0', sizeof (buf)); 00146 #pragma omp parallel for schedule (dynamic, 3) 00147 for (p = &buf[3]; &buf[63] >= p; p += 2) 00148 p[-2] = 6; 00149 for (i = 0; i < 64; i++) 00150 if (buf[i] != 6 * ((i & 1) && i <= 61)) 00151 abort (); 00152 memset (buf, '\0', sizeof (buf)); 00153 #pragma omp parallel for schedule (dynamic, 3) 00154 for (p = &buf[16]; &buf[51] > p; p = 4 + p) 00155 p[2] = 7; 00156 for (i = 0; i < 64; i++) 00157 if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) 00158 abort (); 00159 memset (buf, '\0', sizeof (buf)); 00160 #pragma omp parallel for schedule (dynamic, 3) 00161 for (p = &buf[16]; &buf[40] >= p; p = p + 4ULL) 00162 p[2] = -7; 00163 for (i = 0; i < 64; i++) 00164 if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) 00165 abort (); 00166 memset (buf, '\0', sizeof (buf)); 00167 #pragma omp parallel for schedule (dynamic, 3) 00168 for (p = &buf[53]; &buf[9] < p; --p) 00169 *p = 5; 00170 for (i = 0; i < 64; i++) 00171 if (buf[i] != 5 * (i >= 10 && i < 54)) 00172 abort (); 00173 memset (buf, '\0', sizeof (buf)); 00174 #pragma omp parallel for schedule (dynamic, 3) 00175 for (p = &buf[63]; &buf[3] <= p; p -= 2) 00176 p[-2] = 6; 00177 for (i = 0; i < 64; i++) 00178 if (buf[i] != 6 * ((i & 1) && i <= 61)) 00179 abort (); 00180 memset (buf, '\0', sizeof (buf)); 00181 #pragma omp parallel for schedule (dynamic, 3) 00182 for (p = &buf[48]; &buf[15] < p; p = -4 + p) 00183 p[2] = 7; 00184 for (i = 0; i < 64; i++) 00185 if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) 00186 abort (); 00187 memset (buf, '\0', sizeof (buf)); 00188 #pragma omp parallel for schedule (dynamic, 3) 00189 for (p = &buf[40]; &buf[16] <= p; p = p - 4ULL) 00190 p[2] = -7; 00191 for (i = 0; i < 64; i++) 00192 if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) 00193 abort (); 00194 return 0; 00195 } 00196 00197 int 00198 test4 (void) 00199 { 00200 int buf[64], *p; 00201 int i; 00202 memset (buf, '\0', sizeof (buf)); 00203 #pragma omp parallel for schedule (runtime) 00204 for (p = &buf[10]; &buf[54] > p; p++) 00205 *p = 5; 00206 for (i = 0; i < 64; i++) 00207 if (buf[i] != 5 * (i >= 10 && i < 54)) 00208 abort (); 00209 memset (buf, '\0', sizeof (buf)); 00210 #pragma omp parallel for schedule (runtime) 00211 for (p = &buf[3]; &buf[63] >= p; p += 2) 00212 p[-2] = 6; 00213 for (i = 0; i < 64; i++) 00214 if (buf[i] != 6 * ((i & 1) && i <= 61)) 00215 abort (); 00216 memset (buf, '\0', sizeof (buf)); 00217 #pragma omp parallel for schedule (runtime) 00218 for (p = &buf[16]; &buf[51] > p; p = 4 + p) 00219 p[2] = 7; 00220 for (i = 0; i < 64; i++) 00221 if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) 00222 abort (); 00223 memset (buf, '\0', sizeof (buf)); 00224 #pragma omp parallel for schedule (runtime) 00225 for (p = &buf[16]; &buf[40] >= p; p = p + 4ULL) 00226 p[2] = -7; 00227 for (i = 0; i < 64; i++) 00228 if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) 00229 abort (); 00230 memset (buf, '\0', sizeof (buf)); 00231 #pragma omp parallel for schedule (runtime) 00232 for (p = &buf[53]; &buf[9] < p; --p) 00233 *p = 5; 00234 for (i = 0; i < 64; i++) 00235 if (buf[i] != 5 * (i >= 10 && i < 54)) 00236 abort (); 00237 memset (buf, '\0', sizeof (buf)); 00238 #pragma omp parallel for schedule (runtime) 00239 for (p = &buf[63]; &buf[3] <= p; p -= 2) 00240 p[-2] = 6; 00241 for (i = 0; i < 64; i++) 00242 if (buf[i] != 6 * ((i & 1) && i <= 61)) 00243 abort (); 00244 memset (buf, '\0', sizeof (buf)); 00245 #pragma omp parallel for schedule (runtime) 00246 for (p = &buf[48]; &buf[15] < p; p = -4 + p) 00247 p[2] = 7; 00248 for (i = 0; i < 64; i++) 00249 if (buf[i] != 7 * ((i & 3) == 2 && i >= 18 && i < 53)) 00250 abort (); 00251 memset (buf, '\0', sizeof (buf)); 00252 #pragma omp parallel for schedule (runtime) 00253 for (p = &buf[40]; &buf[16] <= p; p = p - 4ULL) 00254 p[2] = -7; 00255 for (i = 0; i < 64; i++) 00256 if (buf[i] != -7 * ((i & 3) == 2 && i >= 18 && i <= 42)) 00257 abort (); 00258 return 0; 00259 } 00260 00261 int 00262 main (void) 00263 { 00264 test1 (); 00265 test2 (); 00266 test3 (); 00267 omp_set_schedule (omp_sched_static, 0); 00268 test4 (); 00269 omp_set_schedule (omp_sched_static, 3); 00270 test4 (); 00271 omp_set_schedule (omp_sched_dynamic, 5); 00272 test4 (); 00273 omp_set_schedule (omp_sched_guided, 2); 00274 test4 (); 00275 return 0; 00276 }