fstarpu_mod.f90 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. ! StarPU --- Runtime system for heterogeneous multicore architectures.
  2. !
  3. ! Copyright (C) 2016 Inria
  4. !
  5. ! StarPU is free software; you can redistribute it and/or modify
  6. ! it under the terms of the GNU Lesser General Public License as published by
  7. ! the Free Software Foundation; either version 2.1 of the License, or (at
  8. ! your option) any later version.
  9. !
  10. ! StarPU is distributed in the hope that it will be useful, but
  11. ! WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. !
  14. ! See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. module fstarpu_mod
  16. use iso_c_binding
  17. implicit none
  18. ! Note: Constants truly are intptr_t, but are declared as c_ptr to be
  19. ! readily usable in c_ptr arrays to mimic variadic functions.
  20. ! A side effect, though, is that such constants cannot be logically
  21. ! 'or'-ed.
  22. type(c_ptr), bind(C) :: FSTARPU_R
  23. type(c_ptr), bind(C) :: FSTARPU_W
  24. type(c_ptr), bind(C) :: FSTARPU_RW
  25. type(c_ptr), bind(C) :: FSTARPU_SCRATCH
  26. type(c_ptr), bind(C) :: FSTARPU_REDUX
  27. type(c_ptr), bind(C) :: FSTARPU_DATA
  28. type(c_ptr), bind(C) :: FSTARPU_VALUE
  29. type(c_ptr), bind(C) :: FSTARPU_SZ_INT4
  30. type(c_ptr), bind(C) :: FSTARPU_SZ_INT8
  31. type(c_ptr), bind(C) :: FSTARPU_SZ_REAL4
  32. type(c_ptr), bind(C) :: FSTARPU_SZ_REAL8
  33. interface
  34. ! == starpu.h ==
  35. ! starpu_conf_init: see fstarpu_conf_allocate
  36. function fstarpu_conf_allocate () bind(C)
  37. use iso_c_binding, only: c_ptr
  38. type(c_ptr) :: fstarpu_conf_allocate
  39. end function fstarpu_conf_allocate
  40. subroutine fstarpu_conf_free (cl) bind(C)
  41. use iso_c_binding, only: c_ptr
  42. type(c_ptr), value, intent(in) :: cl
  43. end subroutine fstarpu_conf_free
  44. subroutine fstarpu_conf_set_sched_policy_name (conf, policy_name) bind(C)
  45. use iso_c_binding, only: c_ptr, c_char
  46. type(c_ptr), value, intent(in) :: conf
  47. character(c_char), intent(in) :: policy_name
  48. end subroutine fstarpu_conf_set_sched_policy_name
  49. subroutine fstarpu_conf_set_min_prio (conf, min_prio) bind(C)
  50. use iso_c_binding, only: c_ptr, c_int
  51. type(c_ptr), value, intent(in) :: conf
  52. integer(c_int), value, intent(in) :: min_prio
  53. end subroutine fstarpu_conf_set_min_prio
  54. subroutine fstarpu_conf_set_max_prio (conf, max_prio) bind(C)
  55. use iso_c_binding, only: c_ptr, c_int
  56. type(c_ptr), value, intent(in) :: conf
  57. integer(c_int), value, intent(in) :: max_prio
  58. end subroutine fstarpu_conf_set_max_prio
  59. subroutine fstarpu_conf_set_ncpu (conf, ncpu) bind(C)
  60. use iso_c_binding, only: c_ptr, c_int
  61. type(c_ptr), value, intent(in) :: conf
  62. integer(c_int), value, intent(in) :: ncpu
  63. end subroutine fstarpu_conf_set_ncpu
  64. subroutine fstarpu_conf_set_ncuda (conf, ncuda) bind(C)
  65. use iso_c_binding, only: c_ptr, c_int
  66. type(c_ptr), value, intent(in) :: conf
  67. integer(c_int), value, intent(in) :: ncuda
  68. end subroutine fstarpu_conf_set_ncuda
  69. subroutine fstarpu_conf_set_nopencl (conf, nopencl) bind(C)
  70. use iso_c_binding, only: c_ptr, c_int
  71. type(c_ptr), value, intent(in) :: conf
  72. integer(c_int), value, intent(in) :: nopencl
  73. end subroutine fstarpu_conf_set_nopencl
  74. subroutine fstarpu_conf_set_nmic (conf, nmic) bind(C)
  75. use iso_c_binding, only: c_ptr, c_int
  76. type(c_ptr), value, intent(in) :: conf
  77. integer(c_int), value, intent(in) :: nmic
  78. end subroutine fstarpu_conf_set_nmic
  79. subroutine fstarpu_conf_set_nscc (conf, nscc) bind(C)
  80. use iso_c_binding, only: c_ptr, c_int
  81. type(c_ptr), value, intent(in) :: conf
  82. integer(c_int), value, intent(in) :: nscc
  83. end subroutine fstarpu_conf_set_nscc
  84. ! starpu_init: see fstarpu_init
  85. ! starpu_initialize: see fstarpu_init
  86. ! void starpu_pause(void);
  87. subroutine fstarpu_pause() bind(C,name="starpu_pause")
  88. end subroutine fstarpu_pause
  89. ! void starpu_resume(void);
  90. subroutine fstarpu_resume() bind(C,name="starpu_resume")
  91. end subroutine fstarpu_resume
  92. ! void starpu_shutdown(void);
  93. subroutine fstarpu_shutdown () bind(C,name="starpu_shutdown")
  94. end subroutine fstarpu_shutdown
  95. ! starpu_topology_print
  96. ! int starpu_asynchronous_copy_disabled(void);
  97. function fstarpu_asynchronous_copy_disabled() bind(C,name="starpu_asynchronous_copy_disabled")
  98. use iso_c_binding, only: c_int
  99. integer(c_int) :: fstarpu_asynchronous_copy_disabled
  100. end function fstarpu_asynchronous_copy_disabled
  101. ! int starpu_asynchronous_cuda_copy_disabled(void);
  102. function fstarpu_asynchronous_cuda_copy_disabled() bind(C,name="starpu_asynchronous_cuda_copy_disabled")
  103. use iso_c_binding, only: c_int
  104. integer(c_int) :: fstarpu_asynchronous_cuda_copy_disabled
  105. end function fstarpu_asynchronous_cuda_copy_disabled
  106. ! int starpu_asynchronous_opencl_copy_disabled(void);
  107. function fstarpu_asynchronous_opencl_copy_disabled() bind(C,name="starpu_asynchronous_opencl_copy_disabled")
  108. use iso_c_binding, only: c_int
  109. integer(c_int) :: fstarpu_asynchronous_opencl_copy_disabled
  110. end function fstarpu_asynchronous_opencl_copy_disabled
  111. ! int starpu_asynchronous_mic_copy_disabled(void);
  112. function fstarpu_asynchronous_mic_copy_disabled() bind(C,name="starpu_asynchronous_mic_copy_disabled")
  113. use iso_c_binding, only: c_int
  114. integer(c_int) :: fstarpu_asynchronous_mic_copy_disabled
  115. end function fstarpu_asynchronous_mic_copy_disabled
  116. ! void starpu_display_stats();
  117. subroutine fstarpu_display_stats() bind(C,name="starpu_display_stats")
  118. end subroutine fstarpu_display_stats
  119. ! void starpu_get_version(int *major, int *minor, int *release);
  120. subroutine fstarpu_get_version(major,minor,release) bind(C,name="starpu_get_version")
  121. use iso_c_binding, only: c_int
  122. integer(c_int), intent(out) :: major,minor,release
  123. end subroutine fstarpu_get_version
  124. ! == starpu_worker.h ==
  125. ! unsigned starpu_worker_get_count(void);
  126. function fstarpu_worker_get_count() bind(C,name="starpu_worker_get_count")
  127. use iso_c_binding, only: c_int
  128. integer(c_int) :: fstarpu_worker_get_count
  129. end function fstarpu_worker_get_count
  130. ! unsigned starpu_combined_worker_get_count(void);
  131. function fstarpu_combined_worker_get_count() bind(C,name="starpu_combined_worker_get_count")
  132. use iso_c_binding, only: c_int
  133. integer(c_int) :: fstarpu_combined_worker_get_count
  134. end function fstarpu_combined_worker_get_count
  135. ! unsigned starpu_worker_is_combined_worker(int id);
  136. function fstarpu_worker_is_combined_worker(id) bind(C,name="starpu_worker_is_combined_worker")
  137. use iso_c_binding, only: c_int
  138. integer(c_int) :: fstarpu_worker_is_combined_worker
  139. integer(c_int), value, intent(in) :: id
  140. end function fstarpu_worker_is_combined_worker
  141. ! unsigned starpu_cpu_worker_get_count(void);
  142. function fstarpu_cpu_worker_get_count() bind(C,name="starpu_cpu_worker_get_count")
  143. use iso_c_binding, only: c_int
  144. integer(c_int) :: fstarpu_cpu_worker_get_count
  145. end function fstarpu_cpu_worker_get_count
  146. ! unsigned starpu_cuda_worker_get_count(void);
  147. function fstarpu_cuda_worker_get_count() bind(C,name="starpu_cuda_worker_get_count")
  148. use iso_c_binding, only: c_int
  149. integer(c_int) :: fstarpu_cuda_worker_get_count
  150. end function fstarpu_cuda_worker_get_count
  151. ! unsigned starpu_opencl_worker_get_count(void);
  152. function fstarpu_opencl_worker_get_count() bind(C,name="starpu_opencl_worker_get_count")
  153. use iso_c_binding, only: c_int
  154. integer(c_int) :: fstarpu_opencl_worker_get_count
  155. end function fstarpu_opencl_worker_get_count
  156. ! unsigned starpu_mic_worker_get_count(void);
  157. function fstarpu_mic_worker_get_count() bind(C,name="starpu_mic_worker_get_count")
  158. use iso_c_binding, only: c_int
  159. integer(c_int) :: fstarpu_mic_worker_get_count
  160. end function fstarpu_mic_worker_get_count
  161. ! unsigned starpu_scc_worker_get_count(void);
  162. function fstarpu_scc_worker_get_count() bind(C,name="starpu_scc_worker_get_count")
  163. use iso_c_binding, only: c_int
  164. integer(c_int) :: fstarpu_scc_worker_get_count
  165. end function fstarpu_scc_worker_get_count
  166. ! int starpu_worker_get_id(void);
  167. function fstarpu_worker_get_id() bind(C,name="starpu_worker_get_id")
  168. use iso_c_binding, only: c_int
  169. integer(c_int) :: fstarpu_worker_get_id
  170. end function fstarpu_worker_get_id
  171. ! _starpu_worker_get_id_check
  172. ! starpu_worker_get_id_check
  173. ! int starpu_worker_get_bindid(int workerid);
  174. function fstarpu_worker_get_bindid(id) bind(C,name="starpu_worker_get_bindid")
  175. use iso_c_binding, only: c_int
  176. integer(c_int) :: fstarpu_worker_get_bindid
  177. integer(c_int), value, intent(in) :: id
  178. end function fstarpu_worker_get_bindid
  179. ! int starpu_combined_worker_get_id(void);
  180. function fstarpu_combined_worker_get_id() bind(C,name="starpu_combined_worker_get_id")
  181. use iso_c_binding, only: c_int
  182. integer(c_int) :: fstarpu_combined_worker_get_id
  183. end function fstarpu_combined_worker_get_id
  184. ! int starpu_combined_worker_get_size(void);
  185. function fstarpu_combined_worker_get_size() bind(C,name="starpu_combined_worker_get_size")
  186. use iso_c_binding, only: c_int
  187. integer(c_int) :: fstarpu_combined_worker_get_size
  188. end function fstarpu_combined_worker_get_size
  189. ! int starpu_combined_worker_get_rank(void);
  190. function fstarpu_combined_worker_get_rank() bind(C,name="starpu_combined_worker_get_rank")
  191. use iso_c_binding, only: c_int
  192. integer(c_int) :: fstarpu_combined_worker_get_rank
  193. end function fstarpu_combined_worker_get_rank
  194. ! enum starpu_worker_archtype starpu_worker_get_type(int id);
  195. ! int starpu_worker_get_count_by_type(enum starpu_worker_archtype type);
  196. ! int starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, int maxsize);
  197. ! int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num);
  198. ! int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid);
  199. ! void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  200. ! int starpu_worker_get_devid(int id);
  201. function fstarpu_worker_get_devid(id) bind(C,name="starpu_worker_get_devid")
  202. use iso_c_binding, only: c_int
  203. integer(c_int) :: fstarpu_worker_get_devid
  204. integer(c_int), value, intent(in) :: id
  205. end function fstarpu_worker_get_devid
  206. ! int starpu_worker_get_mp_nodeid(int id);
  207. function fstarpu_worker_get_mp_nodeid(id) bind(C,name="starpu_worker_get_mp_nodeid")
  208. use iso_c_binding, only: c_int
  209. integer(c_int) :: fstarpu_worker_get_mp_nodeid
  210. integer(c_int), value, intent(in) :: id
  211. end function fstarpu_worker_get_mp_nodeid
  212. ! struct starpu_tree* starpu_workers_get_tree(void);
  213. ! unsigned starpu_worker_get_sched_ctx_list(int worker, unsigned **sched_ctx);
  214. ! unsigned starpu_worker_is_blocked(int workerid);
  215. function fstarpu_worker_is_blocked(id) bind(C,name="starpu_worker_is_blocked")
  216. use iso_c_binding, only: c_int
  217. integer(c_int) :: fstarpu_worker_is_blocked
  218. integer(c_int), value, intent(in) :: id
  219. end function fstarpu_worker_is_blocked
  220. ! unsigned starpu_worker_is_slave_somewhere(int workerid);
  221. function fstarpu_worker_is_slave_somewhere(id) bind(C,name="starpu_worker_is_slave_somewhere")
  222. use iso_c_binding, only: c_int
  223. integer(c_int) :: fstarpu_worker_is_slave_somewhere
  224. integer(c_int), value, intent(in) :: id
  225. end function fstarpu_worker_is_slave_somewhere
  226. ! char *starpu_worker_get_type_as_string(enum starpu_worker_archtype type);
  227. ! int starpu_bindid_get_workerids(int bindid, int **workerids);
  228. ! == starpu_task.h ==
  229. ! starpu_tag_declare_deps
  230. ! starpu_tag_declare_deps_array
  231. ! starpu_task_declare_deps_array
  232. ! starpu_tag_wait
  233. ! starpu_tag_wait_array
  234. ! starpu_tag_notify_from_apps
  235. ! starpu_tag_restart
  236. ! starpu_tag_remove
  237. ! starpu_task_init
  238. ! starpu_task_clean
  239. ! starpu_task_create
  240. ! starpu_task_destroy
  241. ! starpu_task_submit
  242. ! starpu_task_submit_to_ctx
  243. ! starpu_task_finished
  244. ! starpu_task_wait
  245. ! int starpu_task_wait_for_all(void);
  246. subroutine fstarpu_task_wait_for_all () bind(C,name="starpu_task_wait_for_all")
  247. end subroutine fstarpu_task_wait_for_all
  248. ! starpu_task_wait_for_n_submitted
  249. ! starpu_task_wait_for_all_in_ctx
  250. ! starpu_task_wait_for_n_submitted_in_ctx
  251. ! starpu_task_wait_for_no_ready
  252. ! starpu_task_nready
  253. ! starpu_task_nsubmitted
  254. ! starpu_codelet_init
  255. ! starpu_codelet_display_stats
  256. ! starpu_task_get_current
  257. ! starpu_parallel_task_barrier_init
  258. ! starpu_parallel_task_barrier_init_n
  259. ! starpu_task_dup
  260. ! starpu_task_set_implementation
  261. ! starpu_task_get_implementation
  262. ! --
  263. function fstarpu_codelet_allocate () bind(C)
  264. use iso_c_binding, only: c_ptr
  265. type(c_ptr) :: fstarpu_codelet_allocate
  266. end function fstarpu_codelet_allocate
  267. subroutine fstarpu_codelet_free (cl) bind(C)
  268. use iso_c_binding, only: c_ptr
  269. type(c_ptr), value, intent(in) :: cl
  270. end subroutine fstarpu_codelet_free
  271. subroutine fstarpu_codelet_set_name (cl, cl_name) bind(C)
  272. use iso_c_binding, only: c_ptr, c_char
  273. type(c_ptr), value, intent(in) :: cl
  274. character(c_char), intent(in) :: cl_name
  275. end subroutine fstarpu_codelet_set_name
  276. subroutine fstarpu_codelet_add_cpu_func (cl, f_ptr) bind(C)
  277. use iso_c_binding, only: c_ptr, c_funptr
  278. type(c_ptr), value, intent(in) :: cl
  279. type(c_funptr), value, intent(in) :: f_ptr
  280. end subroutine fstarpu_codelet_add_cpu_func
  281. subroutine fstarpu_codelet_add_cuda_func (cl, f_ptr) bind(C)
  282. use iso_c_binding, only: c_ptr, c_funptr
  283. type(c_ptr), value, intent(in) :: cl
  284. type(c_funptr), value, intent(in) :: f_ptr
  285. end subroutine fstarpu_codelet_add_cuda_func
  286. subroutine fstarpu_codelet_add_opencl_func (cl, f_ptr) bind(C)
  287. use iso_c_binding, only: c_ptr, c_funptr
  288. type(c_ptr), value, intent(in) :: cl
  289. type(c_funptr), value, intent(in) :: f_ptr
  290. end subroutine fstarpu_codelet_add_opencl_func
  291. subroutine fstarpu_codelet_add_mic_func (cl, f_ptr) bind(C)
  292. use iso_c_binding, only: c_ptr, c_funptr
  293. type(c_ptr), value, intent(in) :: cl
  294. type(c_funptr), value, intent(in) :: f_ptr
  295. end subroutine fstarpu_codelet_add_mic_func
  296. subroutine fstarpu_codelet_add_scc_func (cl, f_ptr) bind(C)
  297. use iso_c_binding, only: c_ptr, c_funptr
  298. type(c_ptr), value, intent(in) :: cl
  299. type(c_funptr), value, intent(in) :: f_ptr
  300. end subroutine fstarpu_codelet_add_scc_func
  301. subroutine fstarpu_codelet_add_buffer (cl, mode) bind(C)
  302. use iso_c_binding, only: c_ptr
  303. type(c_ptr), value, intent(in) :: cl
  304. type(c_ptr), value, intent(in) :: mode ! C function expects an intptr_t
  305. end subroutine fstarpu_codelet_add_buffer
  306. function fstarpu_vector_data_register(vector, nx, elt_size, ram) bind(C)
  307. use iso_c_binding, only: c_ptr, c_int, c_size_t
  308. type(c_ptr) :: fstarpu_vector_data_register
  309. type(c_ptr), value, intent(in) :: vector
  310. integer(c_int), value, intent(in) :: nx
  311. integer(c_size_t), value, intent(in) :: elt_size
  312. integer(c_int), value, intent(in) :: ram
  313. end function fstarpu_vector_data_register
  314. function fstarpu_vector_get_ptr(buffers, i) bind(C)
  315. use iso_c_binding, only: c_ptr, c_int
  316. type(c_ptr) :: fstarpu_vector_get_ptr
  317. type(c_ptr), value, intent(in) :: buffers
  318. integer(c_int), value, intent(in) :: i
  319. end function fstarpu_vector_get_ptr
  320. function fstarpu_vector_get_nx(buffers, i) bind(C)
  321. use iso_c_binding, only: c_ptr, c_int
  322. integer(c_int) :: fstarpu_vector_get_nx
  323. type(c_ptr), value, intent(in) :: buffers
  324. integer(c_int), value, intent(in) :: i
  325. end function fstarpu_vector_get_nx
  326. function fstarpu_matrix_data_register(matrix, ldy, ny, nx, elt_size, ram) bind(C)
  327. use iso_c_binding, only: c_ptr, c_int, c_size_t
  328. type(c_ptr) :: fstarpu_matrix_data_register
  329. type(c_ptr), value, intent(in) :: matrix
  330. integer(c_int), value, intent(in) :: ldy
  331. integer(c_int), value, intent(in) :: ny
  332. integer(c_int), value, intent(in) :: nx
  333. integer(c_size_t), value, intent(in) :: elt_size
  334. integer(c_int), value, intent(in) :: ram
  335. end function fstarpu_matrix_data_register
  336. function fstarpu_matrix_get_ptr(buffers, i) bind(C)
  337. use iso_c_binding, only: c_ptr, c_int
  338. type(c_ptr) :: fstarpu_matrix_get_ptr
  339. type(c_ptr), value, intent(in) :: buffers
  340. integer(c_int), value, intent(in) :: i
  341. end function fstarpu_matrix_get_ptr
  342. function fstarpu_matrix_get_ld(buffers, i) bind(C)
  343. use iso_c_binding, only: c_ptr, c_int
  344. integer(c_int) :: fstarpu_matrix_get_ld
  345. type(c_ptr), value, intent(in) :: buffers
  346. integer(c_int), value, intent(in) :: i
  347. end function fstarpu_matrix_get_ld
  348. function fstarpu_matrix_get_ny(buffers, i) bind(C)
  349. use iso_c_binding, only: c_ptr, c_int
  350. integer(c_int) :: fstarpu_matrix_get_ny
  351. type(c_ptr), value, intent(in) :: buffers
  352. integer(c_int), value, intent(in) :: i
  353. end function fstarpu_matrix_get_ny
  354. function fstarpu_matrix_get_nx(buffers, i) bind(C)
  355. use iso_c_binding, only: c_ptr, c_int
  356. integer(c_int) :: fstarpu_matrix_get_nx
  357. type(c_ptr), value, intent(in) :: buffers
  358. integer(c_int), value, intent(in) :: i
  359. end function fstarpu_matrix_get_nx
  360. ! == starpu_data.h ==
  361. ! void starpu_data_unregister(starpu_data_handle_t handle);
  362. subroutine fstarpu_data_unregister (dh) bind(C,name="starpu_data_unregister")
  363. use iso_c_binding, only: c_ptr
  364. type(c_ptr), value, intent(in) :: dh
  365. end subroutine fstarpu_data_unregister
  366. ! void starpu_data_unregister_no_coherency(starpu_data_handle_t handle);
  367. subroutine fstarpu_data_unregister_no_coherency (dh) bind(C,name="starpu_data_unregister_no_coherency")
  368. use iso_c_binding, only: c_ptr
  369. type(c_ptr), value, intent(in) :: dh
  370. end subroutine fstarpu_data_unregister_no_coherency
  371. ! void starpu_data_unregister_submit(starpu_data_handle_t handle);
  372. subroutine fstarpu_data_unregister_submit (dh) bind(C,name="starpu_data_unregister_submit")
  373. use iso_c_binding, only: c_ptr
  374. type(c_ptr), value, intent(in) :: dh
  375. end subroutine fstarpu_data_unregister_submit
  376. ! void starpu_data_invalidate(starpu_data_handle_t handle);
  377. subroutine fstarpu_data_invalidate (dh) bind(C,name="starpu_data_invalidate")
  378. use iso_c_binding, only: c_ptr
  379. type(c_ptr), value, intent(in) :: dh
  380. end subroutine fstarpu_data_invalidate
  381. ! void starpu_data_invalidate_submit(starpu_data_handle_t handle);
  382. subroutine fstarpu_data_invalidate_submit (dh) bind(C,name="starpu_data_invalidate_submit")
  383. use iso_c_binding, only: c_ptr
  384. type(c_ptr), value, intent(in) :: dh
  385. end subroutine fstarpu_data_invalidate_submit
  386. ! void starpu_data_advise_as_important(starpu_data_handle_t handle, unsigned is_important);
  387. subroutine fstarpu_data_advise_as_important (dh,is_important) bind(C,name="starpu_data_advise_as_important")
  388. use iso_c_binding, only: c_ptr,c_int
  389. type(c_ptr), value, intent(in) :: dh
  390. integer(c_int), value, intent(in) :: is_important
  391. end subroutine fstarpu_data_advise_as_important
  392. ! starpu_data_acquire: see fstarpu_data_acquire
  393. subroutine fstarpu_data_acquire (dh, mode) bind(C)
  394. use iso_c_binding, only: c_ptr
  395. type(c_ptr), value, intent(in) :: dh
  396. type(c_ptr), value, intent(in) :: mode ! C function expects an intptr_t
  397. end subroutine fstarpu_data_acquire
  398. ! int starpu_data_acquire_on_node(starpu_data_handle_t handle, int node, enum starpu_data_access_mode mode);
  399. ! int starpu_data_acquire_cb(starpu_data_handle_t handle, enum starpu_data_access_mode mode, void (*callback)(void *), void *arg);
  400. ! int starpu_data_acquire_on_node_cb(starpu_data_handle_t handle, int node, enum starpu_data_access_mode mode, void (*callback)(void *), void *arg);
  401. ! int starpu_data_acquire_cb_sequential_consistency(starpu_data_handle_t handle, enum starpu_data_access_mode mode, void (*callback)(void *), void *arg, int sequential_consistency);
  402. ! int starpu_data_acquire_on_node_cb_sequential_consistency(starpu_data_handle_t handle, int node, enum starpu_data_access_mode mode, void (*callback)(void *), void *arg, int sequential_consistency);
  403. ! void starpu_data_release(starpu_data_handle_t handle);
  404. subroutine fstarpu_data_release (dh) bind(C,name="starpu_data_release")
  405. use iso_c_binding, only: c_ptr
  406. type(c_ptr), value, intent(in) :: dh
  407. end subroutine fstarpu_data_release
  408. ! void starpu_data_release_on_node(starpu_data_handle_t handle, int node);
  409. subroutine fstarpu_data_release_on_node (dh, node) bind(C,name="starpu_data_release_on_node")
  410. use iso_c_binding, only: c_ptr, c_int
  411. type(c_ptr), value, intent(in) :: dh
  412. integer(c_int), value, intent(in) :: node
  413. end subroutine fstarpu_data_release_on_node
  414. ! void starpu_data_assign_arbiter(starpu_data_handle_t handle, starpu_arbiter_t arbiter);
  415. ! void starpu_arbiter_destroy(starpu_arbiter_t arbiter);
  416. ! void starpu_data_display_memory_stats();
  417. subroutine fstarpu_display_memory_stats() bind(C,name="starpu_display_memory_stats")
  418. end subroutine fstarpu_display_memory_stats
  419. ! int starpu_data_request_allocation(starpu_data_handle_t handle, unsigned node);
  420. subroutine fstarpu_data_request_allocation (dh, node) &
  421. bind(C,name="starpu_data_request_allocation")
  422. use iso_c_binding, only: c_ptr, c_int
  423. type(c_ptr), value, intent(in) :: dh
  424. integer(c_int), value, intent(in) :: node
  425. end subroutine fstarpu_data_request_allocation
  426. ! int starpu_data_fetch_on_node(starpu_data_handle_t handle, unsigned node, unsigned async);
  427. subroutine fstarpu_data_fetch_on_node (dh, node, async) &
  428. bind(C,name="starpu_data_fetch_on_node")
  429. use iso_c_binding, only: c_ptr, c_int
  430. type(c_ptr), value, intent(in) :: dh
  431. integer(c_int), value, intent(in) :: node
  432. integer(c_int), value, intent(in) :: async
  433. end subroutine fstarpu_data_fetch_on_node
  434. ! int starpu_data_prefetch_on_node(starpu_data_handle_t handle, unsigned node, unsigned async);
  435. subroutine fstarpu_data_prefetch_on_node (dh, node, async) &
  436. bind(C,name="starpu_data_prefetch_on_node")
  437. use iso_c_binding, only: c_ptr, c_int
  438. type(c_ptr), value, intent(in) :: dh
  439. integer(c_int), value, intent(in) :: node
  440. integer(c_int), value, intent(in) :: async
  441. end subroutine fstarpu_data_prefetch_on_node
  442. ! int starpu_data_prefetch_on_node_prio(starpu_data_handle_t handle, unsigned node, unsigned async, int prio);
  443. subroutine fstarpu_data_prefetch_on_node_prio (dh, node, async, prio) &
  444. bind(C,name="starpu_data_prefetch_on_node_prio")
  445. use iso_c_binding, only: c_ptr, c_int
  446. type(c_ptr), value, intent(in) :: dh
  447. integer(c_int), value, intent(in) :: node
  448. integer(c_int), value, intent(in) :: async
  449. integer(c_int), value, intent(in) :: prio
  450. end subroutine fstarpu_data_prefetch_on_node_prio
  451. ! int starpu_data_idle_prefetch_on_node(starpu_data_handle_t handle, unsigned node, unsigned async);
  452. subroutine fstarpu_data_idle_prefetch_on_node (dh, node, async) &
  453. bind(C,name="starpu_data_idle_prefetch_on_node")
  454. use iso_c_binding, only: c_ptr, c_int
  455. type(c_ptr), value, intent(in) :: dh
  456. integer(c_int), value, intent(in) :: node
  457. integer(c_int), value, intent(in) :: async
  458. end subroutine fstarpu_data_idle_prefetch_on_node
  459. ! int starpu_data_idle_prefetch_on_node_prio(starpu_data_handle_t handle, unsigned node, unsigned async, int prio);
  460. subroutine fstarpu_data_idle_prefetch_on_node_prio (dh, node, async, prio) &
  461. bind(C,name="starpu_data_idle_prefetch_on_node_prio")
  462. use iso_c_binding, only: c_ptr, c_int
  463. type(c_ptr), value, intent(in) :: dh
  464. integer(c_int), value, intent(in) :: node
  465. integer(c_int), value, intent(in) :: async
  466. integer(c_int), value, intent(in) :: prio
  467. end subroutine fstarpu_data_idle_prefetch_on_node_prio
  468. ! void starpu_data_wont_use(starpu_data_handle_t handle);
  469. subroutine fstarpu_data_wont_use (dh) bind(c,name="starpu_data_wont_use")
  470. use iso_c_binding, only: c_ptr
  471. type(c_ptr), value, intent(in) :: dh
  472. end subroutine fstarpu_data_wont_use
  473. ! == starpu_task_util.h ==
  474. subroutine fstarpu_insert_task(arglist) bind(C)
  475. use iso_c_binding, only: c_ptr
  476. type(c_ptr), dimension(:), intent(in) :: arglist
  477. end subroutine fstarpu_insert_task
  478. subroutine fstarpu_unpack_arg(cl_arg,bufferlist) bind(C)
  479. use iso_c_binding, only: c_ptr
  480. type(c_ptr), value, intent(in) :: cl_arg
  481. type(c_ptr), dimension(:), intent(in) :: bufferlist
  482. end subroutine fstarpu_unpack_arg
  483. end interface
  484. contains
  485. function ip_to_p(i) bind(C)
  486. use iso_c_binding, only: c_ptr,c_intptr_t,C_NULL_PTR
  487. type(c_ptr) :: ip_to_p
  488. integer(c_intptr_t), value, intent(in) :: i
  489. ip_to_p = transfer(i,C_NULL_PTR)
  490. end function ip_to_p
  491. function sz_to_p(sz) bind(C)
  492. use iso_c_binding, only: c_ptr,c_size_t,c_intptr_t
  493. type(c_ptr) :: sz_to_p
  494. integer(c_size_t), value, intent(in) :: sz
  495. sz_to_p = ip_to_p(int(sz,kind=c_intptr_t))
  496. end function sz_to_p
  497. function fstarpu_init (conf) bind(C)
  498. use iso_c_binding
  499. integer(c_int) :: fstarpu_init
  500. type(c_ptr), value, intent(in) :: conf
  501. integer(4) :: FSTARPU_SZ_INT4_dummy
  502. integer(8) :: FSTARPU_SZ_INT8_dummy
  503. real(4) :: FSTARPU_SZ_REAL4_dummy
  504. real(8) :: FSTARPU_SZ_REAL8_dummy
  505. ! Note: Referencing global C constants from Fortran has
  506. ! been found unreliable on some architectures, notably
  507. ! on Darwin. The get_integer/get_pointer_constant
  508. ! scheme is a workaround to that issue.
  509. interface
  510. ! These functions are not exported to the end user
  511. function fstarpu_get_constant(s) bind(C)
  512. use iso_c_binding, only: c_ptr,c_char
  513. type(c_ptr) :: fstarpu_get_constant ! C function returns an intptr_t
  514. character(kind=c_char) :: s
  515. end function fstarpu_get_constant
  516. function fstarpu_init_internal (conf) bind(C,name="starpu_init")
  517. use iso_c_binding, only: c_ptr,c_int
  518. integer(c_int) :: fstarpu_init_internal
  519. type(c_ptr), value :: conf
  520. end function fstarpu_init_internal
  521. end interface
  522. ! Initialize Fortran constants from C peers
  523. FSTARPU_R = fstarpu_get_constant(C_CHAR_"FSTARPU_R"//C_NULL_CHAR)
  524. FSTARPU_W = fstarpu_get_constant(C_CHAR_"FSTARPU_W"//C_NULL_CHAR)
  525. FSTARPU_RW = fstarpu_get_constant(C_CHAR_"FSTARPU_RW"//C_NULL_CHAR)
  526. FSTARPU_SCRATCH = fstarpu_get_constant(C_CHAR_"FSTARPU_SCRATCH"//C_NULL_CHAR)
  527. FSTARPU_REDUX = fstarpu_get_constant(C_CHAR_"FSTARPU_REDUX"//C_NULL_CHAR)
  528. FSTARPU_DATA = fstarpu_get_constant(C_CHAR_"FSTARPU_DATA"//C_NULL_CHAR)
  529. FSTARPU_VALUE = fstarpu_get_constant(C_CHAR_"FSTARPU_VALUE"//C_NULL_CHAR)
  530. ! Initialize size constants as 'c_ptr'
  531. FSTARPU_SZ_INT4 = sz_to_p(c_sizeof(FSTARPU_SZ_INT4_dummy))
  532. FSTARPU_SZ_INT8 = sz_to_p(c_sizeof(FSTARPU_SZ_INT8_dummy))
  533. FSTARPU_SZ_REAL4 = sz_to_p(c_sizeof(FSTARPU_SZ_REAL4_dummy))
  534. FSTARPU_SZ_REAL8 = sz_to_p(c_sizeof(FSTARPU_SZ_REAL8_dummy))
  535. ! Initialize StarPU
  536. if (c_associated(conf)) then
  537. fstarpu_init = fstarpu_init_internal(conf)
  538. else
  539. fstarpu_init = fstarpu_init_internal(C_NULL_PTR)
  540. end if
  541. end function fstarpu_init
  542. function fstarpu_csizet_to_cptr(i) bind(C)
  543. use iso_c_binding
  544. type(c_ptr) :: fstarpu_csizet_to_cptr
  545. integer(c_size_t) :: i
  546. fstarpu_csizet_to_cptr = transfer(int(i,kind=c_intptr_t),C_NULL_PTR)
  547. end function fstarpu_csizet_to_cptr
  548. function fstarpu_int_to_cptr(i) bind(C)
  549. use iso_c_binding
  550. type(c_ptr) :: fstarpu_int_to_cptr
  551. integer :: i
  552. fstarpu_int_to_cptr = transfer(int(i,kind=c_intptr_t),C_NULL_PTR)
  553. end function fstarpu_int_to_cptr
  554. end module fstarpu_mod