oacc-async.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* OpenACC Runtime Library Definitions.
  2. Copyright (C) 2013-2015 Free Software Foundation, Inc.
  3. Contributed by Mentor Embedded.
  4. This file is part of the GNU Offloading and Multi Processing Library
  5. (libgomp).
  6. Libgomp is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3, or (at your option)
  9. any later version.
  10. Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. more details.
  14. Under Section 7 of GPL version 3, you are granted additional
  15. permissions described in the GCC Runtime Library Exception, version
  16. 3.1, as published by the Free Software Foundation.
  17. You should have received a copy of the GNU General Public License and
  18. a copy of the GCC Runtime Library Exception along with this program;
  19. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  20. <http://www.gnu.org/licenses/>. */
  21. #include <assert.h>
  22. #include "openacc.h"
  23. #include "libgomp.h"
  24. #include "oacc-int.h"
  25. int
  26. acc_async_test (int async)
  27. {
  28. if (async < acc_async_sync)
  29. gomp_fatal ("invalid async argument: %d", async);
  30. struct goacc_thread *thr = goacc_thread ();
  31. if (!thr || !thr->dev)
  32. gomp_fatal ("no device active");
  33. return thr->dev->openacc.async_test_func (async);
  34. }
  35. int
  36. acc_async_test_all (void)
  37. {
  38. struct goacc_thread *thr = goacc_thread ();
  39. if (!thr || !thr->dev)
  40. gomp_fatal ("no device active");
  41. return thr->dev->openacc.async_test_all_func ();
  42. }
  43. void
  44. acc_wait (int async)
  45. {
  46. if (async < acc_async_sync)
  47. gomp_fatal ("invalid async argument: %d", async);
  48. struct goacc_thread *thr = goacc_thread ();
  49. if (!thr || !thr->dev)
  50. gomp_fatal ("no device active");
  51. thr->dev->openacc.async_wait_func (async);
  52. }
  53. void
  54. acc_wait_async (int async1, int async2)
  55. {
  56. struct goacc_thread *thr = goacc_thread ();
  57. if (!thr || !thr->dev)
  58. gomp_fatal ("no device active");
  59. thr->dev->openacc.async_wait_async_func (async1, async2);
  60. }
  61. void
  62. acc_wait_all (void)
  63. {
  64. struct goacc_thread *thr = goacc_thread ();
  65. if (!thr || !thr->dev)
  66. gomp_fatal ("no device active");
  67. thr->dev->openacc.async_wait_all_func ();
  68. }
  69. void
  70. acc_wait_all_async (int async)
  71. {
  72. if (async < acc_async_sync)
  73. gomp_fatal ("invalid async argument: %d", async);
  74. struct goacc_thread *thr = goacc_thread ();
  75. if (!thr || !thr->dev)
  76. gomp_fatal ("no device active");
  77. thr->dev->openacc.async_wait_all_async_func (async);
  78. }