00001 /* Copyright (C) 2005, 2007, 2008, 2009, 2011 Free Software Foundation, Inc. 00002 Contributed by Jakub Jelinek <jakub@redhat.com>. 00003 00004 This file is part of the GNU OpenMP Library (libgomp). 00005 00006 Libgomp is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3, or (at your option) 00009 any later version. 00010 00011 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY 00012 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00013 FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00014 more details. 00015 00016 Under Section 7 of GPL version 3, you are granted additional 00017 permissions described in the GCC Runtime Library Exception, version 00018 3.1, as published by the Free Software Foundation. 00019 00020 You should have received a copy of the GNU General Public License and 00021 a copy of the GCC Runtime Library Exception along with this program; 00022 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 <http://www.gnu.org/licenses/>. */ 00024 00025 /* This file contains Fortran wrapper routines. */ 00026 00027 #include "libgomp.h" 00028 #include "libgomp_f.h" 00029 #include <stdlib.h> 00030 #include <limits.h> 00031 00032 #ifdef HAVE_ATTRIBUTE_ALIAS 00033 /* Use internal aliases if possible. */ 00034 # define ULP STR1(__USER_LABEL_PREFIX__) 00035 # define STR1(x) STR2(x) 00036 # define STR2(x) #x 00037 # define ialias_redirect(fn) \ 00038 extern __typeof (fn) fn __asm__ (ULP "gomp_ialias_" #fn) attribute_hidden; 00039 # ifndef LIBGOMP_GNU_SYMBOL_VERSIONING 00040 ialias_redirect (omp_init_lock) 00041 ialias_redirect (omp_init_nest_lock) 00042 ialias_redirect (omp_destroy_lock) 00043 ialias_redirect (omp_destroy_nest_lock) 00044 ialias_redirect (omp_set_lock) 00045 ialias_redirect (omp_set_nest_lock) 00046 ialias_redirect (omp_unset_lock) 00047 ialias_redirect (omp_unset_nest_lock) 00048 ialias_redirect (omp_test_lock) 00049 ialias_redirect (omp_test_nest_lock) 00050 # endif 00051 ialias_redirect (omp_set_dynamic) 00052 ialias_redirect (omp_set_nested) 00053 ialias_redirect (omp_set_num_threads) 00054 ialias_redirect (omp_get_dynamic) 00055 ialias_redirect (omp_get_nested) 00056 ialias_redirect (omp_in_parallel) 00057 ialias_redirect (omp_get_max_threads) 00058 ialias_redirect (omp_get_num_procs) 00059 ialias_redirect (omp_get_num_threads) 00060 ialias_redirect (omp_get_thread_num) 00061 ialias_redirect (omp_get_wtick) 00062 ialias_redirect (omp_get_wtime) 00063 ialias_redirect (omp_set_schedule) 00064 ialias_redirect (omp_get_schedule) 00065 ialias_redirect (omp_get_thread_limit) 00066 ialias_redirect (omp_set_max_active_levels) 00067 ialias_redirect (omp_get_max_active_levels) 00068 ialias_redirect (omp_get_level) 00069 ialias_redirect (omp_get_ancestor_thread_num) 00070 ialias_redirect (omp_get_team_size) 00071 ialias_redirect (omp_get_active_level) 00072 #endif 00073 00074 #ifndef LIBGOMP_GNU_SYMBOL_VERSIONING 00075 # define gomp_init_lock__30 omp_init_lock_ 00076 # define gomp_destroy_lock__30 omp_destroy_lock_ 00077 # define gomp_set_lock__30 omp_set_lock_ 00078 # define gomp_unset_lock__30 omp_unset_lock_ 00079 # define gomp_test_lock__30 omp_test_lock_ 00080 # define gomp_init_nest_lock__30 omp_init_nest_lock_ 00081 # define gomp_destroy_nest_lock__30 omp_destroy_nest_lock_ 00082 # define gomp_set_nest_lock__30 omp_set_nest_lock_ 00083 # define gomp_unset_nest_lock__30 omp_unset_nest_lock_ 00084 # define gomp_test_nest_lock__30 omp_test_nest_lock_ 00085 #endif 00086 00087 void 00088 gomp_init_lock__30 (omp_lock_arg_t lock) 00089 { 00090 #ifndef OMP_LOCK_DIRECT 00091 omp_lock_arg (lock) = malloc (sizeof (omp_lock_t)); 00092 #endif 00093 gomp_init_lock_30 (omp_lock_arg (lock)); 00094 } 00095 00096 void 00097 gomp_init_nest_lock__30 (omp_nest_lock_arg_t lock) 00098 { 00099 #ifndef OMP_NEST_LOCK_DIRECT 00100 omp_nest_lock_arg (lock) = malloc (sizeof (omp_nest_lock_t)); 00101 #endif 00102 gomp_init_nest_lock_30 (omp_nest_lock_arg (lock)); 00103 } 00104 00105 void 00106 gomp_destroy_lock__30 (omp_lock_arg_t lock) 00107 { 00108 gomp_destroy_lock_30 (omp_lock_arg (lock)); 00109 #ifndef OMP_LOCK_DIRECT 00110 free (omp_lock_arg (lock)); 00111 omp_lock_arg (lock) = NULL; 00112 #endif 00113 } 00114 00115 void 00116 gomp_destroy_nest_lock__30 (omp_nest_lock_arg_t lock) 00117 { 00118 gomp_destroy_nest_lock_30 (omp_nest_lock_arg (lock)); 00119 #ifndef OMP_NEST_LOCK_DIRECT 00120 free (omp_nest_lock_arg (lock)); 00121 omp_nest_lock_arg (lock) = NULL; 00122 #endif 00123 } 00124 00125 void 00126 gomp_set_lock__30 (omp_lock_arg_t lock) 00127 { 00128 gomp_set_lock_30 (omp_lock_arg (lock)); 00129 } 00130 00131 void 00132 gomp_set_nest_lock__30 (omp_nest_lock_arg_t lock) 00133 { 00134 gomp_set_nest_lock_30 (omp_nest_lock_arg (lock)); 00135 } 00136 00137 void 00138 gomp_unset_lock__30 (omp_lock_arg_t lock) 00139 { 00140 gomp_unset_lock_30 (omp_lock_arg (lock)); 00141 } 00142 00143 void 00144 gomp_unset_nest_lock__30 (omp_nest_lock_arg_t lock) 00145 { 00146 gomp_unset_nest_lock_30 (omp_nest_lock_arg (lock)); 00147 } 00148 00149 int32_t 00150 gomp_test_lock__30 (omp_lock_arg_t lock) 00151 { 00152 return gomp_test_lock_30 (omp_lock_arg (lock)); 00153 } 00154 00155 int32_t 00156 gomp_test_nest_lock__30 (omp_nest_lock_arg_t lock) 00157 { 00158 return gomp_test_nest_lock_30 (omp_nest_lock_arg (lock)); 00159 } 00160 00161 #ifdef LIBGOMP_GNU_SYMBOL_VERSIONING 00162 void 00163 gomp_init_lock__25 (omp_lock_25_arg_t lock) 00164 { 00165 #ifndef OMP_LOCK_25_DIRECT 00166 omp_lock_25_arg (lock) = malloc (sizeof (omp_lock_25_t)); 00167 #endif 00168 gomp_init_lock_25 (omp_lock_25_arg (lock)); 00169 } 00170 00171 void 00172 gomp_init_nest_lock__25 (omp_nest_lock_25_arg_t lock) 00173 { 00174 #ifndef OMP_NEST_LOCK_25_DIRECT 00175 omp_nest_lock_25_arg (lock) = malloc (sizeof (omp_nest_lock_25_t)); 00176 #endif 00177 gomp_init_nest_lock_25 (omp_nest_lock_25_arg (lock)); 00178 } 00179 00180 void 00181 gomp_destroy_lock__25 (omp_lock_25_arg_t lock) 00182 { 00183 gomp_destroy_lock_25 (omp_lock_25_arg (lock)); 00184 #ifndef OMP_LOCK_25_DIRECT 00185 free (omp_lock_25_arg (lock)); 00186 omp_lock_25_arg (lock) = NULL; 00187 #endif 00188 } 00189 00190 void 00191 gomp_destroy_nest_lock__25 (omp_nest_lock_25_arg_t lock) 00192 { 00193 gomp_destroy_nest_lock_25 (omp_nest_lock_25_arg (lock)); 00194 #ifndef OMP_NEST_LOCK_25_DIRECT 00195 free (omp_nest_lock_25_arg (lock)); 00196 omp_nest_lock_25_arg (lock) = NULL; 00197 #endif 00198 } 00199 00200 void 00201 gomp_set_lock__25 (omp_lock_25_arg_t lock) 00202 { 00203 gomp_set_lock_25 (omp_lock_25_arg (lock)); 00204 } 00205 00206 void 00207 gomp_set_nest_lock__25 (omp_nest_lock_25_arg_t lock) 00208 { 00209 gomp_set_nest_lock_25 (omp_nest_lock_25_arg (lock)); 00210 } 00211 00212 void 00213 gomp_unset_lock__25 (omp_lock_25_arg_t lock) 00214 { 00215 gomp_unset_lock_25 (omp_lock_25_arg (lock)); 00216 } 00217 00218 void 00219 gomp_unset_nest_lock__25 (omp_nest_lock_25_arg_t lock) 00220 { 00221 gomp_unset_nest_lock_25 (omp_nest_lock_25_arg (lock)); 00222 } 00223 00224 int32_t 00225 gomp_test_lock__25 (omp_lock_25_arg_t lock) 00226 { 00227 return gomp_test_lock_25 (omp_lock_25_arg (lock)); 00228 } 00229 00230 int32_t 00231 gomp_test_nest_lock__25 (omp_nest_lock_25_arg_t lock) 00232 { 00233 return gomp_test_nest_lock_25 (omp_nest_lock_25_arg (lock)); 00234 } 00235 00236 omp_lock_symver (omp_init_lock_) 00237 omp_lock_symver (omp_destroy_lock_) 00238 omp_lock_symver (omp_set_lock_) 00239 omp_lock_symver (omp_unset_lock_) 00240 omp_lock_symver (omp_test_lock_) 00241 omp_lock_symver (omp_init_nest_lock_) 00242 omp_lock_symver (omp_destroy_nest_lock_) 00243 omp_lock_symver (omp_set_nest_lock_) 00244 omp_lock_symver (omp_unset_nest_lock_) 00245 omp_lock_symver (omp_test_nest_lock_) 00246 #endif 00247 00248 #define TO_INT(x) ((x) > INT_MIN ? (x) < INT_MAX ? (x) : INT_MAX : INT_MIN) 00249 00250 void 00251 omp_set_dynamic_ (const int32_t *set) 00252 { 00253 omp_set_dynamic (*set); 00254 } 00255 00256 void 00257 omp_set_dynamic_8_ (const int64_t *set) 00258 { 00259 omp_set_dynamic (!!*set); 00260 } 00261 00262 void 00263 omp_set_nested_ (const int32_t *set) 00264 { 00265 omp_set_nested (*set); 00266 } 00267 00268 void 00269 omp_set_nested_8_ (const int64_t *set) 00270 { 00271 omp_set_nested (!!*set); 00272 } 00273 00274 void 00275 omp_set_num_threads_ (const int32_t *set) 00276 { 00277 omp_set_num_threads (*set); 00278 } 00279 00280 void 00281 omp_set_num_threads_8_ (const int64_t *set) 00282 { 00283 omp_set_num_threads (TO_INT (*set)); 00284 } 00285 00286 int32_t 00287 omp_get_dynamic_ (void) 00288 { 00289 return omp_get_dynamic (); 00290 } 00291 00292 int32_t 00293 omp_get_nested_ (void) 00294 { 00295 return omp_get_nested (); 00296 } 00297 00298 int32_t 00299 omp_in_parallel_ (void) 00300 { 00301 return omp_in_parallel (); 00302 } 00303 00304 int32_t 00305 omp_get_max_threads_ (void) 00306 { 00307 return omp_get_max_threads (); 00308 } 00309 00310 int32_t 00311 omp_get_num_procs_ (void) 00312 { 00313 return omp_get_num_procs (); 00314 } 00315 00316 int32_t 00317 omp_get_num_threads_ (void) 00318 { 00319 return omp_get_num_threads (); 00320 } 00321 00322 int32_t 00323 omp_get_thread_num_ (void) 00324 { 00325 return omp_get_thread_num (); 00326 } 00327 00328 double 00329 omp_get_wtick_ (void) 00330 { 00331 return omp_get_wtick (); 00332 } 00333 00334 double 00335 omp_get_wtime_ (void) 00336 { 00337 return omp_get_wtime (); 00338 } 00339 00340 void 00341 omp_set_schedule_ (const int32_t *kind, const int32_t *modifier) 00342 { 00343 omp_set_schedule (*kind, *modifier); 00344 } 00345 00346 void 00347 omp_set_schedule_8_ (const int32_t *kind, const int64_t *modifier) 00348 { 00349 omp_set_schedule (*kind, TO_INT (*modifier)); 00350 } 00351 00352 void 00353 omp_get_schedule_ (int32_t *kind, int32_t *modifier) 00354 { 00355 omp_sched_t k; 00356 int m; 00357 omp_get_schedule (&k, &m); 00358 *kind = k; 00359 *modifier = m; 00360 } 00361 00362 void 00363 omp_get_schedule_8_ (int32_t *kind, int64_t *modifier) 00364 { 00365 omp_sched_t k; 00366 int m; 00367 omp_get_schedule (&k, &m); 00368 *kind = k; 00369 *modifier = m; 00370 } 00371 00372 int32_t 00373 omp_get_thread_limit_ (void) 00374 { 00375 return omp_get_thread_limit (); 00376 } 00377 00378 void 00379 omp_set_max_active_levels_ (const int32_t *levels) 00380 { 00381 omp_set_max_active_levels (*levels); 00382 } 00383 00384 void 00385 omp_set_max_active_levels_8_ (const int64_t *levels) 00386 { 00387 omp_set_max_active_levels (TO_INT (*levels)); 00388 } 00389 00390 int32_t 00391 omp_get_max_active_levels_ (void) 00392 { 00393 return omp_get_max_active_levels (); 00394 } 00395 00396 int32_t 00397 omp_get_level_ (void) 00398 { 00399 return omp_get_level (); 00400 } 00401 00402 int32_t 00403 omp_get_ancestor_thread_num_ (const int32_t *level) 00404 { 00405 return omp_get_ancestor_thread_num (*level); 00406 } 00407 00408 int32_t 00409 omp_get_ancestor_thread_num_8_ (const int64_t *level) 00410 { 00411 return omp_get_ancestor_thread_num (TO_INT (*level)); 00412 } 00413 00414 int32_t 00415 omp_get_team_size_ (const int32_t *level) 00416 { 00417 return omp_get_team_size (*level); 00418 } 00419 00420 int32_t 00421 omp_get_team_size_8_ (const int64_t *level) 00422 { 00423 return omp_get_team_size (TO_INT (*level)); 00424 } 00425 00426 int32_t 00427 omp_get_active_level_ (void) 00428 { 00429 return omp_get_active_level (); 00430 }