14 fprintf(stderr,
"usage: omp_thread_limit <n>\n");
17void verify(
const char* file_name,
int line_number,
int team_size) {
19 if (team_size != num_threads) {
20#pragma omp critical(A)
23 snprintf(label,
sizeof(label),
"%s:%d", file_name, line_number);
25 printf(
"failed: %s: team_size(%d) != omp_get_num_threads(%d)\n",
26 label, team_size, num_threads);
31int main(
int argc,
char** argv)
39 cl_thread_limit = atoi(argv[1]);
42 if (omp_get_thread_limit() != cl_thread_limit) {
43 fprintf(stderr,
"omp_get_thread_limit failed with %d, should be%d\n",
44 omp_get_thread_limit(), cl_thread_limit);
49 int team_size = cl_thread_limit;
54 verify(__FILE__, __LINE__, 1);
57 verify(__FILE__, __LINE__, team_size);
58 verify(__FILE__, __LINE__, team_size);
60 verify(__FILE__, __LINE__, 1);
63#pragma omp parallel num_threads(3)
65 verify(__FILE__, __LINE__, 3);
67#pragma omp parallel num_threads(21)
69 verify(__FILE__, __LINE__, team_size-2);
70 verify(__FILE__, __LINE__, team_size-2);
73 verify(__FILE__, __LINE__, 1);
77 fprintf(stderr,
"This test is not applicable for max num_threads='%d'\n",
#define omp_set_num_threads
void verify(const char *file_name, int line_number, int team_size)
int omp_get_max_threads()
int omp_get_num_threads()