Jonathan Peyton | 50e8f18 | 2016-04-04 19:38:32 +0000 | [diff] [blame] | 1 | // RUN: %libomp-compile && env OMP_WAIT_POLICY=active %libomp-run active |
| 2 | // RUN: %libomp-compile && env OMP_WAIT_POLICY=passive %libomp-run passive |
| 3 | // |
Jonathan Peyton | 3731076 | 2016-05-17 21:08:52 +0000 | [diff] [blame] | 4 | // OMP_WAIT_POLICY=active should imply blocktime == INT_MAX |
Jonathan Peyton | 50e8f18 | 2016-04-04 19:38:32 +0000 | [diff] [blame] | 5 | // i.e., threads spin-wait forever |
Jonathan Peyton | 3731076 | 2016-05-17 21:08:52 +0000 | [diff] [blame] | 6 | // OMP_WAIT_POLICY=passive should imply blocktime == 0 |
Jonathan Peyton | 50e8f18 | 2016-04-04 19:38:32 +0000 | [diff] [blame] | 7 | // i.e., threads immediately sleep |
| 8 | #include <stdio.h> |
| 9 | #include <string.h> |
| 10 | #include <limits.h> |
| 11 | #include "omp_testsuite.h" |
| 12 | |
| 13 | void usage() { |
| 14 | fprintf(stderr, "usage: omp_wait_policy active|passive\n"); |
| 15 | } |
| 16 | |
| 17 | int main(int argc, char** argv) |
| 18 | { |
| 19 | int blocktime, retval=1; |
| 20 | const char* env_var_value; |
| 21 | |
| 22 | if (argc != 2) { |
| 23 | usage(); |
| 24 | return 1; |
| 25 | } |
| 26 | |
| 27 | blocktime = kmp_get_blocktime(); |
Jonathan Peyton | 3731076 | 2016-05-17 21:08:52 +0000 | [diff] [blame] | 28 | |
Jonathan Peyton | 50e8f18 | 2016-04-04 19:38:32 +0000 | [diff] [blame] | 29 | env_var_value = argv[1]; |
| 30 | if (!strcmp(env_var_value, "active")) { |
| 31 | retval = (blocktime != INT_MAX); |
| 32 | } else if (!strcmp(env_var_value, "passive")) { |
| 33 | retval = (blocktime != 0); |
| 34 | } else { |
| 35 | usage(); |
| 36 | retval = 1; |
| 37 | } |
| 38 | |
| 39 | return retval; |
| 40 | } |