icv-device.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright (C) 2005-2022 Free Software Foundation, Inc.
  2. Contributed by Richard Henderson <rth@redhat.com>.
  3. This file is part of the GNU Offloading and Multi Processing Library
  4. (libgomp).
  5. Libgomp is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. /* This file defines OpenMP API entry points that accelerator targets are
  21. expected to replace. */
  22. #include "libgomp.h"
  23. void
  24. omp_set_default_device (int device_num)
  25. {
  26. struct gomp_task_icv *icv = gomp_icv (true);
  27. icv->default_device_var = device_num >= 0 ? device_num : 0;
  28. }
  29. ialias (omp_set_default_device)
  30. int
  31. omp_get_default_device (void)
  32. {
  33. struct gomp_task_icv *icv = gomp_icv (false);
  34. return icv->default_device_var;
  35. }
  36. ialias (omp_get_default_device)
  37. int
  38. omp_get_initial_device (void)
  39. {
  40. return gomp_get_num_devices ();
  41. }
  42. ialias (omp_get_initial_device)
  43. int
  44. omp_get_num_devices (void)
  45. {
  46. return gomp_get_num_devices ();
  47. }
  48. ialias (omp_get_num_devices)
  49. int
  50. omp_is_initial_device (void)
  51. {
  52. /* Hardcoded to 1 on host, should be 0 on MIC, HSAIL, PTX. */
  53. return 1;
  54. }
  55. ialias (omp_is_initial_device)
  56. int
  57. omp_get_device_num (void)
  58. {
  59. /* By specification, this is equivalent to omp_get_initial_device
  60. on the host. */
  61. return ialias_call (omp_get_initial_device) ();
  62. }
  63. ialias (omp_get_device_num)