openacc_lib.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. ! OpenACC Runtime Library Definitions. -*- mode: fortran -*-
  2. ! Copyright (C) 2014-2022 Free Software Foundation, Inc.
  3. ! Contributed by Tobias Burnus <burnus@net-b.de>
  4. ! and Mentor Embedded.
  5. ! This file is part of the GNU Offloading and Multi Processing Library
  6. ! (libgomp).
  7. ! Libgomp is free software; you can redistribute it and/or modify it
  8. ! under the terms of the GNU General Public License as published by
  9. ! the Free Software Foundation; either version 3, or (at your option)
  10. ! any later version.
  11. ! Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
  12. ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. ! FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. ! more details.
  15. ! Under Section 7 of GPL version 3, you are granted additional
  16. ! permissions described in the GCC Runtime Library Exception, version
  17. ! 3.1, as published by the Free Software Foundation.
  18. ! You should have received a copy of the GNU General Public License and
  19. ! a copy of the GCC Runtime Library Exception along with this program;
  20. ! see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  21. ! <http://www.gnu.org/licenses/>.
  22. ! NOTE: Due to the use of dimension (..), the code only works when compiled
  23. ! with -std=f2008ts/gnu/legacy but not with other standard settings.
  24. ! Alternatively, the user can use the module version, which permits
  25. ! compilation with -std=f95.
  26. ! Keep in sync with openacc.f90 and config/accel/openacc.f90.
  27. integer, parameter :: acc_device_kind = 4
  28. ! Keep in sync with include/gomp-constants.h.
  29. integer (acc_device_kind), parameter :: acc_device_current = -1
  30. integer (acc_device_kind), parameter :: acc_device_none = 0
  31. integer (acc_device_kind), parameter :: acc_device_default = 1
  32. integer (acc_device_kind), parameter :: acc_device_host = 2
  33. ! integer (acc_device_kind), parameter :: acc_device_host_nonshm = 3
  34. ! removed.
  35. integer (acc_device_kind), parameter :: acc_device_not_host = 4
  36. integer (acc_device_kind), parameter :: acc_device_nvidia = 5
  37. integer (acc_device_kind), parameter :: acc_device_radeon = 8
  38. integer, parameter :: acc_device_property_kind = 4
  39. ! OpenACC 2.6/2.7/3.0 used acc_device_property; in a spec update the
  40. ! missing '_kind' was added for consistency. For backward compatibility, keep:
  41. integer, parameter :: acc_device_property &
  42. & = acc_device_property_kind
  43. integer (acc_device_property_kind), parameter :: &
  44. & acc_property_memory = 1
  45. integer (acc_device_property_kind), parameter :: &
  46. & acc_property_free_memory = 2
  47. integer (acc_device_property_kind), parameter :: &
  48. & acc_property_name = int(Z'10001')
  49. integer (acc_device_property_kind), parameter :: &
  50. & acc_property_vendor = int(Z'10002')
  51. integer (acc_device_property_kind), parameter :: &
  52. & acc_property_driver = int(Z'10003')
  53. integer, parameter :: acc_handle_kind = 4
  54. ! Keep in sync with include/gomp-constants.h.
  55. integer (acc_handle_kind), parameter :: acc_async_noval = -1
  56. integer (acc_handle_kind), parameter :: acc_async_sync = -2
  57. integer, parameter :: openacc_version = 201711
  58. interface acc_get_num_devices
  59. function acc_get_num_devices_h (devicetype)
  60. import acc_device_kind
  61. integer acc_get_num_devices_h
  62. integer (acc_device_kind) devicetype
  63. end function
  64. end interface
  65. interface acc_set_device_type
  66. subroutine acc_set_device_type_h (devicetype)
  67. import acc_device_kind
  68. integer (acc_device_kind) devicetype
  69. end subroutine
  70. end interface
  71. interface acc_get_device_type
  72. function acc_get_device_type_h ()
  73. import acc_device_kind
  74. integer (acc_device_kind) acc_get_device_type_h
  75. end function
  76. end interface
  77. interface acc_set_device_num
  78. subroutine acc_set_device_num_h (devicenum, devicetype)
  79. import acc_device_kind
  80. integer devicenum
  81. integer (acc_device_kind) devicetype
  82. end subroutine
  83. end interface
  84. interface acc_get_device_num
  85. function acc_get_device_num_h (devicetype)
  86. import acc_device_kind
  87. integer acc_get_device_num_h
  88. integer (acc_device_kind) devicetype
  89. end function
  90. end interface
  91. interface acc_get_property
  92. function acc_get_property_h (devicenum, devicetype, &
  93. & property)
  94. use iso_c_binding, only: c_size_t
  95. import acc_device_kind, acc_device_property_kind
  96. implicit none (type, external)
  97. integer (c_size_t) :: acc_get_property_h
  98. integer, value :: devicenum
  99. integer (acc_device_kind), value :: devicetype
  100. integer (acc_device_property_kind), value :: property
  101. end function
  102. end interface
  103. interface acc_get_property_string
  104. subroutine acc_get_property_string_h (devicenum, devicetype, &
  105. & property, string)
  106. import acc_device_kind, acc_device_property_kind
  107. implicit none (type, external)
  108. integer, value :: devicenum
  109. integer (acc_device_kind), value :: devicetype
  110. integer (acc_device_property_kind), value :: property
  111. character (*) :: string
  112. end subroutine
  113. end interface
  114. interface acc_async_test
  115. function acc_async_test_h (arg)
  116. logical acc_async_test_h
  117. integer arg
  118. end function
  119. end interface
  120. interface acc_async_test_all
  121. function acc_async_test_all_h ()
  122. logical acc_async_test_all_h
  123. end function
  124. end interface
  125. interface acc_wait
  126. subroutine acc_wait_h (arg)
  127. integer arg
  128. end subroutine
  129. end interface
  130. ! acc_async_wait is an OpenACC 1.0 compatibility name for acc_wait.
  131. interface acc_async_wait
  132. procedure :: acc_wait_h
  133. end interface
  134. interface acc_wait_async
  135. subroutine acc_wait_async_h (arg, async)
  136. integer arg, async
  137. end subroutine
  138. end interface
  139. interface acc_wait_all
  140. subroutine acc_wait_all_h ()
  141. end subroutine
  142. end interface
  143. ! acc_async_wait_all is an OpenACC 1.0 compatibility name for
  144. ! acc_wait_all.
  145. interface acc_async_wait_all
  146. procedure :: acc_wait_all_h
  147. end interface
  148. interface acc_wait_all_async
  149. subroutine acc_wait_all_async_h (async)
  150. integer async
  151. end subroutine
  152. end interface
  153. interface acc_init
  154. subroutine acc_init_h (devicetype)
  155. import acc_device_kind
  156. integer (acc_device_kind) devicetype
  157. end subroutine
  158. end interface
  159. interface acc_shutdown
  160. subroutine acc_shutdown_h (devicetype)
  161. import acc_device_kind
  162. integer (acc_device_kind) devicetype
  163. end subroutine
  164. end interface
  165. interface acc_on_device
  166. function acc_on_device_h (devicetype)
  167. import acc_device_kind
  168. logical acc_on_device_h
  169. integer (acc_device_kind) devicetype
  170. end function
  171. end interface
  172. ! acc_malloc: Only available in C/C++
  173. ! acc_free: Only available in C/C++
  174. interface acc_copyin
  175. subroutine acc_copyin_32_h (a, len)
  176. use iso_c_binding, only: c_int32_t
  177. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  178. type (*), dimension (*) :: a
  179. integer (c_int32_t) len
  180. end subroutine
  181. subroutine acc_copyin_64_h (a, len)
  182. use iso_c_binding, only: c_int64_t
  183. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  184. type (*), dimension (*) :: a
  185. integer (c_int64_t) len
  186. end subroutine
  187. subroutine acc_copyin_array_h (a)
  188. type (*), dimension (..), contiguous :: a
  189. end subroutine
  190. end interface
  191. interface acc_present_or_copyin
  192. subroutine acc_present_or_copyin_32_h (a, len)
  193. use iso_c_binding, only: c_int32_t
  194. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  195. type (*), dimension (*) :: a
  196. integer (c_int32_t) len
  197. end subroutine
  198. subroutine acc_present_or_copyin_64_h (a, len)
  199. use iso_c_binding, only: c_int64_t
  200. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  201. type (*), dimension (*) :: a
  202. integer (c_int64_t) len
  203. end subroutine
  204. subroutine acc_present_or_copyin_array_h (a)
  205. type (*), dimension (..), contiguous :: a
  206. end subroutine
  207. end interface
  208. interface acc_pcopyin
  209. procedure :: acc_present_or_copyin_32_h
  210. procedure :: acc_present_or_copyin_64_h
  211. procedure :: acc_present_or_copyin_array_h
  212. end interface
  213. interface acc_create
  214. subroutine acc_create_32_h (a, len)
  215. use iso_c_binding, only: c_int32_t
  216. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  217. type (*), dimension (*) :: a
  218. integer (c_int32_t) len
  219. end subroutine
  220. subroutine acc_create_64_h (a, len)
  221. use iso_c_binding, only: c_int64_t
  222. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  223. type (*), dimension (*) :: a
  224. integer (c_int64_t) len
  225. end subroutine
  226. subroutine acc_create_array_h (a)
  227. type (*), dimension (..), contiguous :: a
  228. end subroutine
  229. end interface
  230. interface acc_present_or_create
  231. subroutine acc_present_or_create_32_h (a, len)
  232. use iso_c_binding, only: c_int32_t
  233. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  234. type (*), dimension (*) :: a
  235. integer (c_int32_t) len
  236. end subroutine
  237. subroutine acc_present_or_create_64_h (a, len)
  238. use iso_c_binding, only: c_int64_t
  239. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  240. type (*), dimension (*) :: a
  241. integer (c_int64_t) len
  242. end subroutine
  243. subroutine acc_present_or_create_array_h (a)
  244. type (*), dimension (..), contiguous :: a
  245. end subroutine
  246. end interface
  247. interface acc_pcreate
  248. procedure :: acc_present_or_create_32_h
  249. procedure :: acc_present_or_create_64_h
  250. procedure :: acc_present_or_create_array_h
  251. end interface
  252. interface acc_copyout
  253. subroutine acc_copyout_32_h (a, len)
  254. use iso_c_binding, only: c_int32_t
  255. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  256. type (*), dimension (*) :: a
  257. integer (c_int32_t) len
  258. end subroutine
  259. subroutine acc_copyout_64_h (a, len)
  260. use iso_c_binding, only: c_int64_t
  261. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  262. type (*), dimension (*) :: a
  263. integer (c_int64_t) len
  264. end subroutine
  265. subroutine acc_copyout_array_h (a)
  266. type (*), dimension (..), contiguous :: a
  267. end subroutine
  268. end interface
  269. interface acc_copyout_finalize
  270. subroutine acc_copyout_finalize_32_h (a, len)
  271. use iso_c_binding, only: c_int32_t
  272. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  273. type (*), dimension (*) :: a
  274. integer (c_int32_t) len
  275. end subroutine
  276. subroutine acc_copyout_finalize_64_h (a, len)
  277. use iso_c_binding, only: c_int64_t
  278. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  279. type (*), dimension (*) :: a
  280. integer (c_int64_t) len
  281. end subroutine
  282. subroutine acc_copyout_finalize_array_h (a)
  283. type (*), dimension (..), contiguous :: a
  284. end subroutine
  285. end interface
  286. interface acc_delete
  287. subroutine acc_delete_32_h (a, len)
  288. use iso_c_binding, only: c_int32_t
  289. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  290. type (*), dimension (*) :: a
  291. integer (c_int32_t) len
  292. end subroutine
  293. subroutine acc_delete_64_h (a, len)
  294. use iso_c_binding, only: c_int64_t
  295. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  296. type (*), dimension (*) :: a
  297. integer (c_int64_t) len
  298. end subroutine
  299. subroutine acc_delete_array_h (a)
  300. type (*), dimension (..), contiguous :: a
  301. end subroutine
  302. end interface
  303. interface acc_delete_finalize
  304. subroutine acc_delete_finalize_32_h (a, len)
  305. use iso_c_binding, only: c_int32_t
  306. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  307. type (*), dimension (*) :: a
  308. integer (c_int32_t) len
  309. end subroutine
  310. subroutine acc_delete_finalize_64_h (a, len)
  311. use iso_c_binding, only: c_int64_t
  312. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  313. type (*), dimension (*) :: a
  314. integer (c_int64_t) len
  315. end subroutine
  316. subroutine acc_delete_finalize_array_h (a)
  317. type (*), dimension (..), contiguous :: a
  318. end subroutine
  319. end interface
  320. interface acc_update_device
  321. subroutine acc_update_device_32_h (a, len)
  322. use iso_c_binding, only: c_int32_t
  323. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  324. type (*), dimension (*) :: a
  325. integer (c_int32_t) len
  326. end subroutine
  327. subroutine acc_update_device_64_h (a, len)
  328. use iso_c_binding, only: c_int64_t
  329. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  330. type (*), dimension (*) :: a
  331. integer (c_int64_t) len
  332. end subroutine
  333. subroutine acc_update_device_array_h (a)
  334. type (*), dimension (..), contiguous :: a
  335. end subroutine
  336. end interface
  337. interface acc_update_self
  338. subroutine acc_update_self_32_h (a, len)
  339. use iso_c_binding, only: c_int32_t
  340. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  341. type (*), dimension (*) :: a
  342. integer (c_int32_t) len
  343. end subroutine
  344. subroutine acc_update_self_64_h (a, len)
  345. use iso_c_binding, only: c_int64_t
  346. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  347. type (*), dimension (*) :: a
  348. integer (c_int64_t) len
  349. end subroutine
  350. subroutine acc_update_self_array_h (a)
  351. type (*), dimension (..), contiguous :: a
  352. end subroutine
  353. end interface
  354. ! acc_map_data: Only available in C/C++
  355. ! acc_unmap_data: Only available in C/C++
  356. ! acc_deviceptr: Only available in C/C++
  357. ! acc_hostptr: Only available in C/C++
  358. interface acc_is_present
  359. function acc_is_present_32_h (a, len)
  360. use iso_c_binding, only: c_int32_t
  361. logical acc_is_present_32_h
  362. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  363. type (*), dimension (*) :: a
  364. integer (c_int32_t) len
  365. end function
  366. function acc_is_present_64_h (a, len)
  367. use iso_c_binding, only: c_int64_t
  368. logical acc_is_present_64_h
  369. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  370. type (*), dimension (*) :: a
  371. integer (c_int64_t) len
  372. end function
  373. function acc_is_present_array_h (a)
  374. logical acc_is_present_array_h
  375. type (*), dimension (..), contiguous :: a
  376. end function
  377. end interface
  378. ! acc_memcpy_to_device: Only available in C/C++
  379. ! acc_memcpy_from_device: Only available in C/C++
  380. interface acc_copyin_async
  381. subroutine acc_copyin_async_32_h (a, len, async)
  382. use iso_c_binding, only: c_int32_t
  383. import acc_handle_kind
  384. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  385. type (*), dimension (*) :: a
  386. integer (c_int32_t) len
  387. integer (acc_handle_kind) async
  388. end subroutine
  389. subroutine acc_copyin_async_64_h (a, len, async)
  390. use iso_c_binding, only: c_int64_t
  391. import acc_handle_kind
  392. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  393. type (*), dimension (*) :: a
  394. integer (c_int64_t) len
  395. integer (acc_handle_kind) async
  396. end subroutine
  397. subroutine acc_copyin_async_array_h (a, async_)
  398. import acc_handle_kind
  399. type (*), dimension (..), contiguous :: a
  400. integer (acc_handle_kind) async_
  401. end subroutine
  402. end interface
  403. interface acc_create_async
  404. subroutine acc_create_async_32_h (a, len, async)
  405. use iso_c_binding, only: c_int32_t
  406. import acc_handle_kind
  407. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  408. type (*), dimension (*) :: a
  409. integer (c_int32_t) len
  410. integer (acc_handle_kind) async
  411. end subroutine
  412. subroutine acc_create_async_64_h (a, len, async)
  413. use iso_c_binding, only: c_int64_t
  414. import acc_handle_kind
  415. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  416. type (*), dimension (*) :: a
  417. integer (c_int64_t) len
  418. integer (acc_handle_kind) async
  419. end subroutine
  420. subroutine acc_create_async_array_h (a, async_)
  421. import acc_handle_kind
  422. type (*), dimension (..), contiguous :: a
  423. integer (acc_handle_kind) async_
  424. end subroutine
  425. end interface
  426. interface acc_copyout_async
  427. subroutine acc_copyout_async_32_h (a, len, async)
  428. use iso_c_binding, only: c_int32_t
  429. import acc_handle_kind
  430. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  431. type (*), dimension (*) :: a
  432. integer (c_int32_t) len
  433. integer (acc_handle_kind) async
  434. end subroutine
  435. subroutine acc_copyout_async_64_h (a, len, async)
  436. use iso_c_binding, only: c_int64_t
  437. import acc_handle_kind
  438. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  439. type (*), dimension (*) :: a
  440. integer (c_int64_t) len
  441. integer (acc_handle_kind) async
  442. end subroutine
  443. subroutine acc_copyout_async_array_h (a, async_)
  444. import acc_handle_kind
  445. type (*), dimension (..), contiguous :: a
  446. integer (acc_handle_kind) async_
  447. end subroutine
  448. end interface
  449. interface acc_delete_async
  450. subroutine acc_delete_async_32_h (a, len, async)
  451. use iso_c_binding, only: c_int32_t
  452. import acc_handle_kind
  453. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  454. type (*), dimension (*) :: a
  455. integer (c_int32_t) len
  456. integer (acc_handle_kind) async
  457. end subroutine
  458. subroutine acc_delete_async_64_h (a, len, async)
  459. use iso_c_binding, only: c_int64_t
  460. import acc_handle_kind
  461. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  462. type (*), dimension (*) :: a
  463. integer (c_int64_t) len
  464. integer (acc_handle_kind) async
  465. end subroutine
  466. subroutine acc_delete_async_array_h (a, async_)
  467. import acc_handle_kind
  468. type (*), dimension (..), contiguous :: a
  469. integer (acc_handle_kind) async_
  470. end subroutine
  471. end interface
  472. interface acc_update_device_async
  473. subroutine acc_update_device_async_32_h (a, len, async)
  474. use iso_c_binding, only: c_int32_t
  475. import acc_handle_kind
  476. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  477. type (*), dimension (*) :: a
  478. integer (c_int32_t) len
  479. integer (acc_handle_kind) async
  480. end subroutine
  481. subroutine acc_update_device_async_64_h (a, len, async)
  482. use iso_c_binding, only: c_int64_t
  483. import acc_handle_kind
  484. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  485. type (*), dimension (*) :: a
  486. integer (c_int64_t) len
  487. integer (acc_handle_kind) async
  488. end subroutine
  489. subroutine acc_update_device_async_array_h (a, async_)
  490. import acc_handle_kind
  491. type (*), dimension (..), contiguous :: a
  492. integer (acc_handle_kind) async_
  493. end subroutine
  494. end interface
  495. interface acc_update_self_async
  496. subroutine acc_update_self_async_32_h (a, len, async)
  497. use iso_c_binding, only: c_int32_t
  498. import acc_handle_kind
  499. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  500. type (*), dimension (*) :: a
  501. integer (c_int32_t) len
  502. integer (acc_handle_kind) async
  503. end subroutine
  504. subroutine acc_update_self_async_64_h (a, len, async)
  505. use iso_c_binding, only: c_int64_t
  506. import acc_handle_kind
  507. !GCC$ ATTRIBUTES NO_ARG_CHECK :: a
  508. type (*), dimension (*) :: a
  509. integer (c_int64_t) len
  510. integer (acc_handle_kind) async
  511. end subroutine
  512. subroutine acc_update_self_async_array_h (a, async_)
  513. import acc_handle_kind
  514. type (*), dimension (..), contiguous :: a
  515. integer (acc_handle_kind) async_
  516. end subroutine
  517. end interface