fortran.c 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. /* Copyright (C) 2005-2015 Free Software Foundation, Inc.
  2. Contributed by Jakub Jelinek <jakub@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 contains Fortran wrapper routines. */
  21. #include "libgomp.h"
  22. #include "libgomp_f.h"
  23. #include <stdlib.h>
  24. #include <limits.h>
  25. #ifdef HAVE_ATTRIBUTE_ALIAS
  26. /* Use internal aliases if possible. */
  27. # ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
  28. ialias_redirect (omp_init_lock)
  29. ialias_redirect (omp_init_nest_lock)
  30. ialias_redirect (omp_destroy_lock)
  31. ialias_redirect (omp_destroy_nest_lock)
  32. ialias_redirect (omp_set_lock)
  33. ialias_redirect (omp_set_nest_lock)
  34. ialias_redirect (omp_unset_lock)
  35. ialias_redirect (omp_unset_nest_lock)
  36. ialias_redirect (omp_test_lock)
  37. ialias_redirect (omp_test_nest_lock)
  38. # endif
  39. ialias_redirect (omp_set_dynamic)
  40. ialias_redirect (omp_set_nested)
  41. ialias_redirect (omp_set_num_threads)
  42. ialias_redirect (omp_get_dynamic)
  43. ialias_redirect (omp_get_nested)
  44. ialias_redirect (omp_in_parallel)
  45. ialias_redirect (omp_get_max_threads)
  46. ialias_redirect (omp_get_num_procs)
  47. ialias_redirect (omp_get_num_threads)
  48. ialias_redirect (omp_get_thread_num)
  49. ialias_redirect (omp_get_wtick)
  50. ialias_redirect (omp_get_wtime)
  51. ialias_redirect (omp_set_schedule)
  52. ialias_redirect (omp_get_schedule)
  53. ialias_redirect (omp_get_thread_limit)
  54. ialias_redirect (omp_set_max_active_levels)
  55. ialias_redirect (omp_get_max_active_levels)
  56. ialias_redirect (omp_get_level)
  57. ialias_redirect (omp_get_ancestor_thread_num)
  58. ialias_redirect (omp_get_team_size)
  59. ialias_redirect (omp_get_active_level)
  60. ialias_redirect (omp_in_final)
  61. ialias_redirect (omp_get_cancellation)
  62. ialias_redirect (omp_get_proc_bind)
  63. ialias_redirect (omp_set_default_device)
  64. ialias_redirect (omp_get_default_device)
  65. ialias_redirect (omp_get_num_devices)
  66. ialias_redirect (omp_get_num_teams)
  67. ialias_redirect (omp_get_team_num)
  68. ialias_redirect (omp_is_initial_device)
  69. #endif
  70. #ifndef LIBGOMP_GNU_SYMBOL_VERSIONING
  71. # define gomp_init_lock__30 omp_init_lock_
  72. # define gomp_destroy_lock__30 omp_destroy_lock_
  73. # define gomp_set_lock__30 omp_set_lock_
  74. # define gomp_unset_lock__30 omp_unset_lock_
  75. # define gomp_test_lock__30 omp_test_lock_
  76. # define gomp_init_nest_lock__30 omp_init_nest_lock_
  77. # define gomp_destroy_nest_lock__30 omp_destroy_nest_lock_
  78. # define gomp_set_nest_lock__30 omp_set_nest_lock_
  79. # define gomp_unset_nest_lock__30 omp_unset_nest_lock_
  80. # define gomp_test_nest_lock__30 omp_test_nest_lock_
  81. #endif
  82. void
  83. gomp_init_lock__30 (omp_lock_arg_t lock)
  84. {
  85. #ifndef OMP_LOCK_DIRECT
  86. omp_lock_arg (lock) = malloc (sizeof (omp_lock_t));
  87. #endif
  88. gomp_init_lock_30 (omp_lock_arg (lock));
  89. }
  90. void
  91. gomp_init_nest_lock__30 (omp_nest_lock_arg_t lock)
  92. {
  93. #ifndef OMP_NEST_LOCK_DIRECT
  94. omp_nest_lock_arg (lock) = malloc (sizeof (omp_nest_lock_t));
  95. #endif
  96. gomp_init_nest_lock_30 (omp_nest_lock_arg (lock));
  97. }
  98. void
  99. gomp_destroy_lock__30 (omp_lock_arg_t lock)
  100. {
  101. gomp_destroy_lock_30 (omp_lock_arg (lock));
  102. #ifndef OMP_LOCK_DIRECT
  103. free (omp_lock_arg (lock));
  104. omp_lock_arg (lock) = NULL;
  105. #endif
  106. }
  107. void
  108. gomp_destroy_nest_lock__30 (omp_nest_lock_arg_t lock)
  109. {
  110. gomp_destroy_nest_lock_30 (omp_nest_lock_arg (lock));
  111. #ifndef OMP_NEST_LOCK_DIRECT
  112. free (omp_nest_lock_arg (lock));
  113. omp_nest_lock_arg (lock) = NULL;
  114. #endif
  115. }
  116. void
  117. gomp_set_lock__30 (omp_lock_arg_t lock)
  118. {
  119. gomp_set_lock_30 (omp_lock_arg (lock));
  120. }
  121. void
  122. gomp_set_nest_lock__30 (omp_nest_lock_arg_t lock)
  123. {
  124. gomp_set_nest_lock_30 (omp_nest_lock_arg (lock));
  125. }
  126. void
  127. gomp_unset_lock__30 (omp_lock_arg_t lock)
  128. {
  129. gomp_unset_lock_30 (omp_lock_arg (lock));
  130. }
  131. void
  132. gomp_unset_nest_lock__30 (omp_nest_lock_arg_t lock)
  133. {
  134. gomp_unset_nest_lock_30 (omp_nest_lock_arg (lock));
  135. }
  136. int32_t
  137. gomp_test_lock__30 (omp_lock_arg_t lock)
  138. {
  139. return gomp_test_lock_30 (omp_lock_arg (lock));
  140. }
  141. int32_t
  142. gomp_test_nest_lock__30 (omp_nest_lock_arg_t lock)
  143. {
  144. return gomp_test_nest_lock_30 (omp_nest_lock_arg (lock));
  145. }
  146. #ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
  147. void
  148. gomp_init_lock__25 (omp_lock_25_arg_t lock)
  149. {
  150. #ifndef OMP_LOCK_25_DIRECT
  151. omp_lock_25_arg (lock) = malloc (sizeof (omp_lock_25_t));
  152. #endif
  153. gomp_init_lock_25 (omp_lock_25_arg (lock));
  154. }
  155. void
  156. gomp_init_nest_lock__25 (omp_nest_lock_25_arg_t lock)
  157. {
  158. #ifndef OMP_NEST_LOCK_25_DIRECT
  159. omp_nest_lock_25_arg (lock) = malloc (sizeof (omp_nest_lock_25_t));
  160. #endif
  161. gomp_init_nest_lock_25 (omp_nest_lock_25_arg (lock));
  162. }
  163. void
  164. gomp_destroy_lock__25 (omp_lock_25_arg_t lock)
  165. {
  166. gomp_destroy_lock_25 (omp_lock_25_arg (lock));
  167. #ifndef OMP_LOCK_25_DIRECT
  168. free (omp_lock_25_arg (lock));
  169. omp_lock_25_arg (lock) = NULL;
  170. #endif
  171. }
  172. void
  173. gomp_destroy_nest_lock__25 (omp_nest_lock_25_arg_t lock)
  174. {
  175. gomp_destroy_nest_lock_25 (omp_nest_lock_25_arg (lock));
  176. #ifndef OMP_NEST_LOCK_25_DIRECT
  177. free (omp_nest_lock_25_arg (lock));
  178. omp_nest_lock_25_arg (lock) = NULL;
  179. #endif
  180. }
  181. void
  182. gomp_set_lock__25 (omp_lock_25_arg_t lock)
  183. {
  184. gomp_set_lock_25 (omp_lock_25_arg (lock));
  185. }
  186. void
  187. gomp_set_nest_lock__25 (omp_nest_lock_25_arg_t lock)
  188. {
  189. gomp_set_nest_lock_25 (omp_nest_lock_25_arg (lock));
  190. }
  191. void
  192. gomp_unset_lock__25 (omp_lock_25_arg_t lock)
  193. {
  194. gomp_unset_lock_25 (omp_lock_25_arg (lock));
  195. }
  196. void
  197. gomp_unset_nest_lock__25 (omp_nest_lock_25_arg_t lock)
  198. {
  199. gomp_unset_nest_lock_25 (omp_nest_lock_25_arg (lock));
  200. }
  201. int32_t
  202. gomp_test_lock__25 (omp_lock_25_arg_t lock)
  203. {
  204. return gomp_test_lock_25 (omp_lock_25_arg (lock));
  205. }
  206. int32_t
  207. gomp_test_nest_lock__25 (omp_nest_lock_25_arg_t lock)
  208. {
  209. return gomp_test_nest_lock_25 (omp_nest_lock_25_arg (lock));
  210. }
  211. omp_lock_symver (omp_init_lock_)
  212. omp_lock_symver (omp_destroy_lock_)
  213. omp_lock_symver (omp_set_lock_)
  214. omp_lock_symver (omp_unset_lock_)
  215. omp_lock_symver (omp_test_lock_)
  216. omp_lock_symver (omp_init_nest_lock_)
  217. omp_lock_symver (omp_destroy_nest_lock_)
  218. omp_lock_symver (omp_set_nest_lock_)
  219. omp_lock_symver (omp_unset_nest_lock_)
  220. omp_lock_symver (omp_test_nest_lock_)
  221. #endif
  222. #define TO_INT(x) ((x) > INT_MIN ? (x) < INT_MAX ? (x) : INT_MAX : INT_MIN)
  223. void
  224. omp_set_dynamic_ (const int32_t *set)
  225. {
  226. omp_set_dynamic (*set);
  227. }
  228. void
  229. omp_set_dynamic_8_ (const int64_t *set)
  230. {
  231. omp_set_dynamic (!!*set);
  232. }
  233. void
  234. omp_set_nested_ (const int32_t *set)
  235. {
  236. omp_set_nested (*set);
  237. }
  238. void
  239. omp_set_nested_8_ (const int64_t *set)
  240. {
  241. omp_set_nested (!!*set);
  242. }
  243. void
  244. omp_set_num_threads_ (const int32_t *set)
  245. {
  246. omp_set_num_threads (*set);
  247. }
  248. void
  249. omp_set_num_threads_8_ (const int64_t *set)
  250. {
  251. omp_set_num_threads (TO_INT (*set));
  252. }
  253. int32_t
  254. omp_get_dynamic_ (void)
  255. {
  256. return omp_get_dynamic ();
  257. }
  258. int32_t
  259. omp_get_nested_ (void)
  260. {
  261. return omp_get_nested ();
  262. }
  263. int32_t
  264. omp_in_parallel_ (void)
  265. {
  266. return omp_in_parallel ();
  267. }
  268. int32_t
  269. omp_get_max_threads_ (void)
  270. {
  271. return omp_get_max_threads ();
  272. }
  273. int32_t
  274. omp_get_num_procs_ (void)
  275. {
  276. return omp_get_num_procs ();
  277. }
  278. int32_t
  279. omp_get_num_threads_ (void)
  280. {
  281. return omp_get_num_threads ();
  282. }
  283. int32_t
  284. omp_get_thread_num_ (void)
  285. {
  286. return omp_get_thread_num ();
  287. }
  288. double
  289. omp_get_wtick_ (void)
  290. {
  291. return omp_get_wtick ();
  292. }
  293. double
  294. omp_get_wtime_ (void)
  295. {
  296. return omp_get_wtime ();
  297. }
  298. void
  299. omp_set_schedule_ (const int32_t *kind, const int32_t *modifier)
  300. {
  301. omp_set_schedule (*kind, *modifier);
  302. }
  303. void
  304. omp_set_schedule_8_ (const int32_t *kind, const int64_t *modifier)
  305. {
  306. omp_set_schedule (*kind, TO_INT (*modifier));
  307. }
  308. void
  309. omp_get_schedule_ (int32_t *kind, int32_t *modifier)
  310. {
  311. omp_sched_t k;
  312. int m;
  313. omp_get_schedule (&k, &m);
  314. *kind = k;
  315. *modifier = m;
  316. }
  317. void
  318. omp_get_schedule_8_ (int32_t *kind, int64_t *modifier)
  319. {
  320. omp_sched_t k;
  321. int m;
  322. omp_get_schedule (&k, &m);
  323. *kind = k;
  324. *modifier = m;
  325. }
  326. int32_t
  327. omp_get_thread_limit_ (void)
  328. {
  329. return omp_get_thread_limit ();
  330. }
  331. void
  332. omp_set_max_active_levels_ (const int32_t *levels)
  333. {
  334. omp_set_max_active_levels (*levels);
  335. }
  336. void
  337. omp_set_max_active_levels_8_ (const int64_t *levels)
  338. {
  339. omp_set_max_active_levels (TO_INT (*levels));
  340. }
  341. int32_t
  342. omp_get_max_active_levels_ (void)
  343. {
  344. return omp_get_max_active_levels ();
  345. }
  346. int32_t
  347. omp_get_level_ (void)
  348. {
  349. return omp_get_level ();
  350. }
  351. int32_t
  352. omp_get_ancestor_thread_num_ (const int32_t *level)
  353. {
  354. return omp_get_ancestor_thread_num (*level);
  355. }
  356. int32_t
  357. omp_get_ancestor_thread_num_8_ (const int64_t *level)
  358. {
  359. return omp_get_ancestor_thread_num (TO_INT (*level));
  360. }
  361. int32_t
  362. omp_get_team_size_ (const int32_t *level)
  363. {
  364. return omp_get_team_size (*level);
  365. }
  366. int32_t
  367. omp_get_team_size_8_ (const int64_t *level)
  368. {
  369. return omp_get_team_size (TO_INT (*level));
  370. }
  371. int32_t
  372. omp_get_active_level_ (void)
  373. {
  374. return omp_get_active_level ();
  375. }
  376. int32_t
  377. omp_in_final_ (void)
  378. {
  379. return omp_in_final ();
  380. }
  381. int32_t
  382. omp_get_cancellation_ (void)
  383. {
  384. return omp_get_cancellation ();
  385. }
  386. int32_t
  387. omp_get_proc_bind_ (void)
  388. {
  389. return omp_get_proc_bind ();
  390. }
  391. void
  392. omp_set_default_device_ (const int32_t *device_num)
  393. {
  394. return omp_set_default_device (*device_num);
  395. }
  396. void
  397. omp_set_default_device_8_ (const int64_t *device_num)
  398. {
  399. return omp_set_default_device (TO_INT (*device_num));
  400. }
  401. int32_t
  402. omp_get_default_device_ (void)
  403. {
  404. return omp_get_default_device ();
  405. }
  406. int32_t
  407. omp_get_num_devices_ (void)
  408. {
  409. return omp_get_num_devices ();
  410. }
  411. int32_t
  412. omp_get_num_teams_ (void)
  413. {
  414. return omp_get_num_teams ();
  415. }
  416. int32_t
  417. omp_get_team_num_ (void)
  418. {
  419. return omp_get_team_num ();
  420. }
  421. int32_t
  422. omp_is_initial_device_ (void)
  423. {
  424. return omp_is_initial_device ();
  425. }