13 #ifndef MTMETIS_BASE_H 14 #define MTMETIS_BASE_H 24 #define _POSIX_SOURCE 1 51 #ifdef MTMETIS_64BIT_THREADS 52 typedef uint64_t mtmetis_tid_type;
54 typedef uint32_t mtmetis_tid_type;
58 typedef int64_t mtmetis_twgt_type;
59 typedef uint16_t mtmetis_offset_type;
63 #define vtx_type mtmetis_vtx_type 64 #define adj_type mtmetis_adj_type 65 #define wgt_type mtmetis_wgt_type 66 #define twgt_type mtmetis_twgt_type 67 #define pid_type mtmetis_pid_type 68 #define tid_type mtmetis_tid_type 69 #define real_type mtmetis_real_type 70 #define offset_type mtmetis_offset_type 81 #define DEF_NULL_VTX ((vtx_type)-1) 82 #define DEF_NULL_ADJ ((adj_type)-1) 83 #define DEF_NULL_PID ((pid_type)-1) 84 #define DEF_NULL_TID ((tid_type)-1) 85 #define DEF_NULL_WGT ((wgt_type)-1) 86 #define DEF_NULL_OFFSET ((offset_type)-1) 90 static const vtx_type NULL_VTX = DEF_NULL_VTX;
91 static const wgt_type NULL_WGT = DEF_NULL_WGT;
92 static const adj_type NULL_ADJ = DEF_NULL_ADJ;
93 static const pid_type NULL_PID = DEF_NULL_PID;
94 static const tid_type NULL_TID = DEF_NULL_TID;
95 static const offset_type NULL_OFFSET = DEF_NULL_OFFSET;
99 static const vtx_type BLOCKSIZE = 0x1000;
100 static const int BLOCKSHIFT = 12;
101 static const vtx_type BLOCKMASK = 0x0FFF;
112 #define DLMEM_PREFIX vtx 113 #define DLMEM_TYPE_T vtx_type 114 #define DLMEM_DLTYPE DLTYPE_INTEGRAL 116 #include "dlmem_headers.h" 123 #define DLMATH_PREFIX vtx 124 #define DLMATH_TYPE_T vtx_type 125 #define DLMATH_DLTYPE DLTYPE_INTEGRAL 126 #define DLMATH_STATIC 127 #include "dlmath_headers.h" 134 #define DLRAND_PREFIX vtx 135 #define DLRAND_TYPE_T vtx_type 136 #define DLRAND_DLTYPE DLTYPE_INTEGRAL 137 #define DLRAND_STATIC 138 #include "dlrand_headers.h" 145 #define DLSTATS_PREFIX vtx 146 #define DLSTATS_TYPE_T vtx_type 147 #define DLSTATS_STATIC 148 #include "dlstats_headers.h" 149 #undef DLSTATS_STATIC 150 #undef DLSTATS_PREFIX 151 #undef DLSTATS_TYPE_T 154 #define DLISET_PREFIX vtx 155 #define DLISET_TYPE_T vtx_type 156 #define DLISET_STATIC 157 #include "dliset_headers.h" 163 #define DLTHREAD_PREFIX vtx 164 #define DLTHREAD_TYPE_T vtx_type 165 #define DLTHREAD_STATIC 1 166 #include "dlthread_reduction_headers.h" 167 #undef DLTHREAD_STATIC 168 #undef DLTHREAD_TYPE_T 169 #undef DLTHREAD_PREFIX 172 #define DLSORT_PREFIX vtx 173 #define DLSORT_TYPE_T vtx_type 174 #define DLSORT_STATIC 175 #include "dlsort_headers.h" 184 #define DLMEM_PREFIX adj 185 #define DLMEM_TYPE_T adj_type 186 #define DLMEM_DLTYPE DLTYPE_INTEGRAL 188 #include "dlmem_headers.h" 195 #define DLMATH_PREFIX adj 196 #define DLMATH_TYPE_T adj_type 197 #define DLMATH_DLTYPE DLTYPE_INTEGRAL 198 #define DLMATH_STATIC 199 #include "dlmath_headers.h" 206 #define DLRAND_PREFIX adj 207 #define DLRAND_TYPE_T adj_type 208 #define DLRAND_DLTYPE DLTYPE_INTEGRAL 209 #define DLRAND_STATIC 210 #include "dlrand_headers.h" 217 #define DLSTATS_PREFIX adj 218 #define DLSTATS_TYPE_T adj_type 219 #define DLSTATS_STATIC 220 #include "dlstats_headers.h" 221 #undef DLSTATS_STATIC 222 #undef DLSTATS_PREFIX 223 #undef DLSTATS_TYPE_T 226 #define DLTHREAD_PREFIX adj 227 #define DLTHREAD_TYPE_T adj_type 228 #define DLTHREAD_STATIC 1 229 #include "dlthread_reduction_headers.h" 230 #undef DLTHREAD_STATIC 231 #undef DLTHREAD_TYPE_T 232 #undef DLTHREAD_PREFIX 238 #define DLMEM_PREFIX pid 239 #define DLMEM_TYPE_T pid_type 240 #define DLMEM_DLTYPE DLTYPE_INTEGRAL 242 #include "dlmem_headers.h" 249 #define DLMATH_PREFIX pid 250 #define DLMATH_TYPE_T pid_type 251 #define DLMATH_DLTYPE DLTYPE_INTEGRAL 252 #define DLMATH_STATIC 253 #include "dlmath_headers.h" 260 #define DLRAND_PREFIX pid 261 #define DLRAND_TYPE_T pid_type 262 #define DLRAND_DLTYPE DLTYPE_INTEGRAL 263 #define DLRAND_STATIC 264 #include "dlrand_headers.h" 271 #define DLSTATS_PREFIX pid 272 #define DLSTATS_TYPE_T pid_type 273 #define DLSTATS_STATIC 274 #include "dlstats_headers.h" 275 #undef DLSTATS_STATIC 276 #undef DLSTATS_PREFIX 277 #undef DLSTATS_TYPE_T 281 #define DLMEM_PREFIX tid 282 #define DLMEM_TYPE_T tid_type 283 #define DLMEM_DLTYPE DLTYPE_INTEGRAL 285 #include "dlmem_headers.h" 292 #define DLMATH_PREFIX tid 293 #define DLMATH_TYPE_T tid_type 294 #define DLMATH_DLTYPE DLTYPE_INTEGRAL 295 #define DLMATH_STATIC 296 #include "dlmath_headers.h" 304 #define DLMEM_PREFIX wgt 305 #define DLMEM_TYPE_T wgt_type 306 #define DLMEM_DLTYPE DLTYPE_INTEGRAL 308 #include "dlmem_headers.h" 315 #define DLMATH_PREFIX wgt 316 #define DLMATH_TYPE_T wgt_type 317 #define DLMATH_DLTYPE DLTYPE_INTEGRAL 318 #define DLMATH_STATIC 319 #include "dlmath_headers.h" 326 #define DLRAND_PREFIX wgt 327 #define DLRAND_TYPE_T wgt_type 328 #define DLRAND_DLTYPE DLTYPE_INTEGRAL 329 #define DLRAND_STATIC 330 #include "dlrand_headers.h" 337 #define DLSTATS_PREFIX wgt 338 #define DLSTATS_TYPE_T wgt_type 339 #define DLSTATS_STATIC 340 #include "dlstats_headers.h" 341 #undef DLSTATS_STATIC 342 #undef DLSTATS_PREFIX 343 #undef DLSTATS_TYPE_T 346 #define DLTHREAD_PREFIX wgt 347 #define DLTHREAD_TYPE_T wgt_type 348 #define DLTHREAD_STATIC 1 349 #include "dlthread_reduction_headers.h" 350 #undef DLTHREAD_STATIC 351 #undef DLTHREAD_TYPE_T 352 #undef DLTHREAD_PREFIX 356 #define DLTHREAD_PREFIX twgt 357 #define DLTHREAD_TYPE_T twgt_type 358 #define DLTHREAD_STATIC 1 359 #include "dlthread_reduction_headers.h" 360 #undef DLTHREAD_STATIC 361 #undef DLTHREAD_TYPE_T 362 #undef DLTHREAD_PREFIX 365 #define DLMATH_PREFIX twgt 366 #define DLMATH_TYPE_T twgt_type 367 #define DLMATH_DLTYPE DLTYPE_INTEGRAL 368 #define DLMATH_STATIC 369 #include "dlmath_headers.h" 377 #define DLMEM_PREFIX real 378 #define DLMEM_TYPE_T real_type 379 #define DLMEM_DLTYPE DLTYPE_FLOAT 381 #include "dlmem_headers.h" 388 #define DLMATH_PREFIX real 389 #define DLMATH_TYPE_T real_type 390 #define DLMATH_DLTYPE DLTYPE_FLOAT 391 #define DLMATH_STATIC 392 #include "dlmath_headers.h" 399 #define DLTHREAD_PREFIX double 400 #define DLTHREAD_TYPE_T double 401 #define DLTHREAD_STATIC 1 402 #include "dlthread_reduction_headers.h" 403 #undef DLTHREAD_STATIC 404 #undef DLTHREAD_TYPE_T 405 #undef DLTHREAD_PREFIX 410 #define DLTHREAD_PREFIX int 411 #define DLTHREAD_TYPE_T int 412 #define DLTHREAD_STATIC 1 413 #include "dlthread_reduction_headers.h" 414 #undef DLTHREAD_STATIC 415 #undef DLTHREAD_TYPE_T 416 #undef DLTHREAD_PREFIX 421 #define DLMEM_PREFIX offset 422 #define DLMEM_TYPE_T offset_type 423 #define DLMEM_STATIC 1 424 #include "dlmem_headers.h" 438 #define par_dprintf(...) \ 440 _Pragma("omp master") \ 442 dprintf( __VA_ARGS__ ); \ 446 #define par_dprintf(...) 449 #define par_vprintf(...) \ 451 _Pragma("omp master") \ 453 vprintf( __VA_ARGS__ ); \ 465 static inline vtx_type gvtx_to_lvtx(
469 DL_ASSERT(mask > 0,
"The mask is set to 0!\n");
470 DL_ASSERT(v > mask,
"Global vertex number is smaller than mask (gvtx = %" 471 PF_VTX_T
", mask = %"PF_VTX_T
")\n",v,mask);
476 static inline vtx_type lvtx_to_gvtx(
481 DL_ASSERT(shift > 0,
"The mask size is set to 0!\n");
482 DL_ASSERT(v < (vtx_type)(1 << shift),
"Local vertex number is greater than " 483 "shift (lvtx = %"PF_VTX_T
", shift = %d)\n",v,shift);
484 return ((t+1) << shift) | v;
488 static inline tid_type gvtx_to_tid(
492 DL_ASSERT(shift > 0,
"The shift size is set to %d!\n",shift);
493 DL_ASSERT(v >= (vtx_type)(1 << shift),
"Global vertex number is too small " 494 "(gvtx = %"PF_VTX_T
", shift = %d)\n",v,shift);
495 return (v >> shift)-1;
499 static inline vtx_type max_gvtx(
501 tid_type
const nthreads)
503 return (vtx_type)(1 << shift)*(nthreads+1);
507 static inline int is_bnd(
515 return (ed > 0) || (
id == 0);
521 #define gvtx_to_lvtx(v,dist) gvtx_to_lvtx(v,(dist).mask) 522 #define lvtx_to_gvtx(v,t,dist) lvtx_to_gvtx(v,t,(dist).shift) 523 #define gvtx_to_tid(v,dist) gvtx_to_tid(v,(dist).shift) 524 #define max_gvtx(graph) max_gvtx((graph)->dist.shift,(graph)->dist.nthreads) String defines for mt-Metis.
Macros and some micro-Macros...