oacc-host.c 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* OpenACC Runtime Library: acc_device_host.
  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. /* This shares much of the implementation of the plugin-host.c "host_nonshm"
  22. plugin. */
  23. #include "plugin/plugin-host.c"
  24. static struct gomp_device_descr host_dispatch =
  25. {
  26. .name = "host",
  27. .capabilities = (GOMP_OFFLOAD_CAP_OPENACC_200
  28. | GOMP_OFFLOAD_CAP_NATIVE_EXEC
  29. | GOMP_OFFLOAD_CAP_SHARED_MEM),
  30. .target_id = 0,
  31. .type = OFFLOAD_TARGET_TYPE_HOST,
  32. .get_name_func = GOMP_OFFLOAD_get_name,
  33. .get_caps_func = GOMP_OFFLOAD_get_caps,
  34. .get_type_func = GOMP_OFFLOAD_get_type,
  35. .get_num_devices_func = GOMP_OFFLOAD_get_num_devices,
  36. .init_device_func = GOMP_OFFLOAD_init_device,
  37. .fini_device_func = GOMP_OFFLOAD_fini_device,
  38. .load_image_func = GOMP_OFFLOAD_load_image,
  39. .unload_image_func = GOMP_OFFLOAD_unload_image,
  40. .alloc_func = GOMP_OFFLOAD_alloc,
  41. .free_func = GOMP_OFFLOAD_free,
  42. .dev2host_func = GOMP_OFFLOAD_dev2host,
  43. .host2dev_func = GOMP_OFFLOAD_host2dev,
  44. .run_func = GOMP_OFFLOAD_run,
  45. .is_initialized = false,
  46. .openacc = {
  47. .exec_func = GOMP_OFFLOAD_openacc_parallel,
  48. .register_async_cleanup_func
  49. = GOMP_OFFLOAD_openacc_register_async_cleanup,
  50. .async_set_async_func = GOMP_OFFLOAD_openacc_async_set_async,
  51. .async_test_func = GOMP_OFFLOAD_openacc_async_test,
  52. .async_test_all_func = GOMP_OFFLOAD_openacc_async_test_all,
  53. .async_wait_func = GOMP_OFFLOAD_openacc_async_wait,
  54. .async_wait_async_func = GOMP_OFFLOAD_openacc_async_wait_async,
  55. .async_wait_all_func = GOMP_OFFLOAD_openacc_async_wait_all,
  56. .async_wait_all_async_func = GOMP_OFFLOAD_openacc_async_wait_all_async,
  57. .create_thread_data_func = GOMP_OFFLOAD_openacc_create_thread_data,
  58. .destroy_thread_data_func = GOMP_OFFLOAD_openacc_destroy_thread_data,
  59. .cuda = {
  60. .get_current_device_func = NULL,
  61. .get_current_context_func = NULL,
  62. .get_stream_func = NULL,
  63. .set_stream_func = NULL,
  64. }
  65. }
  66. };
  67. /* Register this device type. */
  68. static __attribute__ ((constructor))
  69. void goacc_host_init (void)
  70. {
  71. gomp_mutex_init (&host_dispatch.lock);
  72. goacc_register (&host_dispatch);
  73. }