kmp_stub.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "kmp_stub.h"
00048
00049 #include <stdlib.h>
00050 #include <limits.h>
00051 #include <errno.h>
00052
00053 #include "kmp_os.h"
00054
00055 #if KMP_OS_WINDOWS
00056 #include <windows.h>
00057 #else
00058 #include <sys/time.h>
00059 #endif
00060
00061 #include "kmp.h"
00062 #include "kmp_version.h"
00063
00064 #include "omp.h"
00065
00066
00067 static double frequency = 0.0;
00068
00069
00070 static size_t __kmps_init() {
00071 static int initialized = 0;
00072 static size_t dummy = 0;
00073 if ( ! initialized ) {
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 dummy = __kmp_version_copyright - __kmp_version_build_time;
00086
00087 #if KMP_OS_WINDOWS
00088 LARGE_INTEGER freq;
00089 BOOL status = QueryPerformanceFrequency( & freq );
00090 if ( status ) {
00091 frequency = double( freq.QuadPart );
00092 };
00093 #endif
00094
00095 initialized = 1;
00096 };
00097 return dummy;
00098 };
00099
00100 #define i __kmps_init();
00101
00102
00103 void omp_set_num_threads( omp_int_t num_threads ) { i; }
00104 void omp_set_dynamic( omp_int_t dynamic ) { i; __kmps_set_dynamic( dynamic ); }
00105 void omp_set_nested( omp_int_t nested ) { i; __kmps_set_nested( nested ); }
00106 #if OMP_30_ENABLED
00107 void omp_set_max_active_levels( omp_int_t max_active_levels ) { i; }
00108 void omp_set_schedule( omp_sched_t kind, omp_int_t modifier ) { i; __kmps_set_schedule( (kmp_sched_t)kind, modifier ); }
00109 int omp_get_ancestor_thread_num( omp_int_t level ) { i; return ( level ) ? ( -1 ) : ( 0 ); }
00110 int omp_get_team_size( omp_int_t level ) { i; return ( level ) ? ( -1 ) : ( 1 ); }
00111 int kmpc_set_affinity_mask_proc( int proc, void **mask ) { i; return -1; }
00112 int kmpc_unset_affinity_mask_proc( int proc, void **mask ) { i; return -1; }
00113 int kmpc_get_affinity_mask_proc( int proc, void **mask ) { i; return -1; }
00114 #endif // OMP_30_ENABLED
00115
00116
00117 void kmp_set_stacksize( omp_int_t arg ) { i; __kmps_set_stacksize( arg ); }
00118 void kmp_set_stacksize_s( size_t arg ) { i; __kmps_set_stacksize( arg ); }
00119 void kmp_set_blocktime( omp_int_t arg ) { i; __kmps_set_blocktime( arg ); }
00120 void kmp_set_library( omp_int_t arg ) { i; __kmps_set_library( arg ); }
00121 void kmp_set_defaults( char const * str ) { i; }
00122
00123
00124 void * kmp_malloc( size_t size ) { i; return malloc( size ); }
00125 void * kmp_calloc( size_t nelem, size_t elsize ) { i; return calloc( nelem, elsize ); }
00126 void * kmp_realloc( void *ptr, size_t size ) { i; return realloc( ptr, size ); }
00127 void kmp_free( void * ptr ) { i; free( ptr ); }
00128
00129 static int __kmps_blocktime = INT_MAX;
00130
00131 void __kmps_set_blocktime( int arg ) {
00132 i;
00133 __kmps_blocktime = arg;
00134 }
00135
00136 int __kmps_get_blocktime( void ) {
00137 i;
00138 return __kmps_blocktime;
00139 }
00140
00141 static int __kmps_dynamic = 0;
00142
00143 void __kmps_set_dynamic( int arg ) {
00144 i;
00145 __kmps_dynamic = arg;
00146 }
00147
00148 int __kmps_get_dynamic( void ) {
00149 i;
00150 return __kmps_dynamic;
00151 }
00152
00153 static int __kmps_library = 1000;
00154
00155 void __kmps_set_library( int arg ) {
00156 i;
00157 __kmps_library = arg;
00158 }
00159
00160 int __kmps_get_library( void ) {
00161 i;
00162 return __kmps_library;
00163 }
00164
00165 static int __kmps_nested = 0;
00166
00167 void __kmps_set_nested( int arg ) {
00168 i;
00169 __kmps_nested = arg;
00170 }
00171
00172 int __kmps_get_nested( void ) {
00173 i;
00174 return __kmps_nested;
00175 }
00176
00177 static size_t __kmps_stacksize = KMP_DEFAULT_STKSIZE;
00178
00179 void __kmps_set_stacksize( int arg ) {
00180 i;
00181 __kmps_stacksize = arg;
00182 }
00183
00184 int __kmps_get_stacksize( void ) {
00185 i;
00186 return __kmps_stacksize;
00187 }
00188
00189 #if OMP_30_ENABLED
00190
00191 static kmp_sched_t __kmps_sched_kind = kmp_sched_default;
00192 static int __kmps_sched_modifier = 0;
00193
00194 void __kmps_set_schedule( kmp_sched_t kind, int modifier ) {
00195 i;
00196 __kmps_sched_kind = kind;
00197 __kmps_sched_modifier = modifier;
00198 }
00199
00200 void __kmps_get_schedule( kmp_sched_t *kind, int *modifier ) {
00201 i;
00202 *kind = __kmps_sched_kind;
00203 *modifier = __kmps_sched_modifier;
00204 }
00205
00206 #endif // OMP_30_ENABLED
00207
00208 #if OMP_40_ENABLED
00209
00210 static kmp_proc_bind_t __kmps_proc_bind = proc_bind_false;
00211
00212 void __kmps_set_proc_bind( kmp_proc_bind_t arg ) {
00213 i;
00214 __kmps_proc_bind = arg;
00215 }
00216
00217 kmp_proc_bind_t __kmps_get_proc_bind( void ) {
00218 i;
00219 return __kmps_proc_bind;
00220 }
00221
00222 #endif
00223
00224 double __kmps_get_wtime( void ) {
00225
00226 double wtime = 0.0;
00227 i;
00228 #if KMP_OS_WINDOWS
00229 if ( frequency > 0.0 ) {
00230 LARGE_INTEGER now;
00231 BOOL status = QueryPerformanceCounter( & now );
00232 if ( status ) {
00233 wtime = double( now.QuadPart ) / frequency;
00234 };
00235 };
00236 #else
00237
00238 struct timeval tval;
00239 int rc;
00240 rc = gettimeofday( & tval, NULL );
00241 if ( rc == 0 ) {
00242 wtime = (double)( tval.tv_sec ) + 1.0E-06 * (double)( tval.tv_usec );
00243 } else {
00244
00245 };
00246 #endif
00247 return wtime;
00248 };
00249
00250 double __kmps_get_wtick( void ) {
00251
00252 double wtick = 0.0;
00253 i;
00254 #if KMP_OS_WINDOWS
00255 {
00256 DWORD increment;
00257 DWORD adjustment;
00258 BOOL disabled;
00259 BOOL rc;
00260 rc = GetSystemTimeAdjustment( & adjustment, & increment, & disabled );
00261 if ( rc ) {
00262 wtick = 1.0E-07 * (double)( disabled ? increment : adjustment );
00263 } else {
00264
00265 wtick = 1.0E-03;
00266 };
00267 }
00268 #else
00269
00270 wtick = 1.0E-06;
00271 #endif
00272 return wtick;
00273 };
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300