target-5.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include <omp.h>
  2. #include <stdlib.h>
  3. int
  4. main ()
  5. {
  6. int d_o = omp_get_dynamic ();
  7. int n_o = omp_get_nested ();
  8. omp_sched_t s_o;
  9. int c_o;
  10. omp_get_schedule (&s_o, &c_o);
  11. int m_o = omp_get_max_threads ();
  12. omp_set_dynamic (1);
  13. omp_set_nested (1);
  14. omp_set_schedule (omp_sched_static, 2);
  15. omp_set_num_threads (4);
  16. int d = omp_get_dynamic ();
  17. int n = omp_get_nested ();
  18. omp_sched_t s;
  19. int c;
  20. omp_get_schedule (&s, &c);
  21. int m = omp_get_max_threads ();
  22. if (!omp_is_initial_device ())
  23. abort ();
  24. #pragma omp target if (0)
  25. {
  26. omp_sched_t s_c;
  27. int c_c;
  28. omp_get_schedule (&s_c, &c_c);
  29. if (d_o != omp_get_dynamic ()
  30. || n_o != omp_get_nested ()
  31. || s_o != s_c
  32. || c_o != c_c
  33. || m_o != omp_get_max_threads ())
  34. abort ();
  35. omp_set_dynamic (0);
  36. omp_set_nested (0);
  37. omp_set_schedule (omp_sched_dynamic, 4);
  38. omp_set_num_threads (2);
  39. if (!omp_is_initial_device ())
  40. abort ();
  41. }
  42. if (!omp_is_initial_device ())
  43. abort ();
  44. omp_sched_t s_c;
  45. int c_c;
  46. omp_get_schedule (&s_c, &c_c);
  47. if (d != omp_get_dynamic ()
  48. || n != omp_get_nested ()
  49. || s != s_c
  50. || c != c_c
  51. || m != omp_get_max_threads ())
  52. abort ();
  53. #pragma omp target if (0)
  54. #pragma omp teams
  55. {
  56. omp_sched_t s_c;
  57. int c_c;
  58. omp_get_schedule (&s_c, &c_c);
  59. if (d_o != omp_get_dynamic ()
  60. || n_o != omp_get_nested ()
  61. || s_o != s_c
  62. || c_o != c_c
  63. || m_o != omp_get_max_threads ())
  64. abort ();
  65. omp_set_dynamic (0);
  66. omp_set_nested (0);
  67. omp_set_schedule (omp_sched_dynamic, 4);
  68. omp_set_num_threads (2);
  69. if (!omp_is_initial_device ())
  70. abort ();
  71. }
  72. if (!omp_is_initial_device ())
  73. abort ();
  74. omp_get_schedule (&s_c, &c_c);
  75. if (d != omp_get_dynamic ()
  76. || n != omp_get_nested ()
  77. || s != s_c
  78. || c != c_c
  79. || m != omp_get_max_threads ())
  80. abort ();
  81. return 0;
  82. }