annotate src/fftw-3.3.3/kernel/planner.c @ 19:891f60ab2af1

Ranlib
author Chris Cannam
date Mon, 25 Mar 2013 16:27:30 +0000
parents 37bf6b4a2645
children
rev   line source
Chris@10 1 /*
Chris@10 2 * Copyright (c) 2000 Matteo Frigo
Chris@10 3 * Copyright (c) 2000 Massachusetts Institute of Technology
Chris@10 4 *
Chris@10 5 * This program is free software; you can redistribute it and/or modify
Chris@10 6 * it under the terms of the GNU General Public License as published by
Chris@10 7 * the Free Software Foundation; either version 2 of the License, or
Chris@10 8 * (at your option) any later version.
Chris@10 9 *
Chris@10 10 * This program is distributed in the hope that it will be useful,
Chris@10 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@10 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@10 13 * GNU General Public License for more details.
Chris@10 14 *
Chris@10 15 * You should have received a copy of the GNU General Public License
Chris@10 16 * along with this program; if not, write to the Free Software
Chris@10 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Chris@10 18 *
Chris@10 19 */
Chris@10 20
Chris@10 21 #include "ifftw.h"
Chris@10 22 #include <string.h>
Chris@10 23
Chris@10 24 /* GNU Coding Standards, Sec. 5.2: "Please write the comments in a GNU
Chris@10 25 program in English, because English is the one language that nearly
Chris@10 26 all programmers in all countries can read."
Chris@10 27
Chris@10 28 ingemisco tanquam reus
Chris@10 29 culpa rubet vultus meus
Chris@10 30 supplicanti parce [rms]
Chris@10 31 */
Chris@10 32
Chris@10 33 #define VALIDP(solution) ((solution)->flags.hash_info & H_VALID)
Chris@10 34 #define LIVEP(solution) ((solution)->flags.hash_info & H_LIVE)
Chris@10 35 #define SLVNDX(solution) ((solution)->flags.slvndx)
Chris@10 36 #define BLISS(flags) (((flags).hash_info) & BLESSING)
Chris@10 37 #define INFEASIBLE_SLVNDX ((1U<<BITS_FOR_SLVNDX)-1)
Chris@10 38
Chris@10 39
Chris@10 40 #define MAXNAM 64 /* maximum length of registrar's name.
Chris@10 41 Used for reading wisdom. There is no point
Chris@10 42 in doing this right */
Chris@10 43
Chris@10 44
Chris@10 45 #ifdef FFTW_DEBUG
Chris@10 46 static void check(hashtab *ht);
Chris@10 47 #endif
Chris@10 48
Chris@10 49 /* x <= y */
Chris@10 50 #define LEQ(x, y) (((x) & (y)) == (x))
Chris@10 51
Chris@10 52 /* A subsumes B */
Chris@10 53 static int subsumes(const flags_t *a, unsigned slvndx_a, const flags_t *b)
Chris@10 54 {
Chris@10 55 if (slvndx_a != INFEASIBLE_SLVNDX) {
Chris@10 56 A(a->timelimit_impatience == 0);
Chris@10 57 return (LEQ(a->u, b->u) && LEQ(b->l, a->l));
Chris@10 58 } else {
Chris@10 59 return (LEQ(a->l, b->l)
Chris@10 60 && a->timelimit_impatience <= b->timelimit_impatience);
Chris@10 61 }
Chris@10 62 }
Chris@10 63
Chris@10 64 static unsigned addmod(unsigned a, unsigned b, unsigned p)
Chris@10 65 {
Chris@10 66 /* gcc-2.95/sparc produces incorrect code for the fast version below. */
Chris@10 67 #if defined(__sparc__) && defined(__GNUC__)
Chris@10 68 /* slow version */
Chris@10 69 return (a + b) % p;
Chris@10 70 #else
Chris@10 71 /* faster version */
Chris@10 72 unsigned c = a + b;
Chris@10 73 return c >= p ? c - p : c;
Chris@10 74 #endif
Chris@10 75 }
Chris@10 76
Chris@10 77 /*
Chris@10 78 slvdesc management:
Chris@10 79 */
Chris@10 80 static void sgrow(planner *ego)
Chris@10 81 {
Chris@10 82 unsigned osiz = ego->slvdescsiz, nsiz = 1 + osiz + osiz / 4;
Chris@10 83 slvdesc *ntab = (slvdesc *)MALLOC(nsiz * sizeof(slvdesc), SLVDESCS);
Chris@10 84 slvdesc *otab = ego->slvdescs;
Chris@10 85 unsigned i;
Chris@10 86
Chris@10 87 ego->slvdescs = ntab;
Chris@10 88 ego->slvdescsiz = nsiz;
Chris@10 89 for (i = 0; i < osiz; ++i)
Chris@10 90 ntab[i] = otab[i];
Chris@10 91 X(ifree0)(otab);
Chris@10 92 }
Chris@10 93
Chris@10 94 static void register_solver(planner *ego, solver *s)
Chris@10 95 {
Chris@10 96 slvdesc *n;
Chris@10 97 int kind;
Chris@10 98
Chris@10 99 if (s) { /* add s to solver list */
Chris@10 100 X(solver_use)(s);
Chris@10 101
Chris@10 102 A(ego->nslvdesc < INFEASIBLE_SLVNDX);
Chris@10 103 if (ego->nslvdesc >= ego->slvdescsiz)
Chris@10 104 sgrow(ego);
Chris@10 105
Chris@10 106 n = ego->slvdescs + ego->nslvdesc;
Chris@10 107
Chris@10 108 n->slv = s;
Chris@10 109 n->reg_nam = ego->cur_reg_nam;
Chris@10 110 n->reg_id = ego->cur_reg_id++;
Chris@10 111
Chris@10 112 A(strlen(n->reg_nam) < MAXNAM);
Chris@10 113 n->nam_hash = X(hash)(n->reg_nam);
Chris@10 114
Chris@10 115 kind = s->adt->problem_kind;
Chris@10 116 n->next_for_same_problem_kind = ego->slvdescs_for_problem_kind[kind];
Chris@10 117 ego->slvdescs_for_problem_kind[kind] = ego->nslvdesc;
Chris@10 118
Chris@10 119 ego->nslvdesc++;
Chris@10 120 }
Chris@10 121 }
Chris@10 122
Chris@10 123 static unsigned slookup(planner *ego, char *nam, int id)
Chris@10 124 {
Chris@10 125 unsigned h = X(hash)(nam); /* used to avoid strcmp in the common case */
Chris@10 126 FORALL_SOLVERS(ego, s, sp, {
Chris@10 127 UNUSED(s);
Chris@10 128 if (sp->reg_id == id && sp->nam_hash == h
Chris@10 129 && !strcmp(sp->reg_nam, nam))
Chris@10 130 return sp - ego->slvdescs;
Chris@10 131 });
Chris@10 132 return INFEASIBLE_SLVNDX;
Chris@10 133 }
Chris@10 134
Chris@10 135 /* Compute a MD5 hash of the configuration of the planner.
Chris@10 136 We store it into the wisdom file to make absolutely sure that
Chris@10 137 we are reading wisdom that is applicable */
Chris@10 138 static void signature_of_configuration(md5 *m, planner *ego)
Chris@10 139 {
Chris@10 140 X(md5begin)(m);
Chris@10 141 X(md5unsigned)(m, sizeof(R)); /* so we don't mix different precisions */
Chris@10 142 FORALL_SOLVERS(ego, s, sp, {
Chris@10 143 UNUSED(s);
Chris@10 144 X(md5int)(m, sp->reg_id);
Chris@10 145 X(md5puts)(m, sp->reg_nam);
Chris@10 146 });
Chris@10 147 X(md5end)(m);
Chris@10 148 }
Chris@10 149
Chris@10 150 /*
Chris@10 151 md5-related stuff:
Chris@10 152 */
Chris@10 153
Chris@10 154 /* first hash function */
Chris@10 155 static unsigned h1(const hashtab *ht, const md5sig s)
Chris@10 156 {
Chris@10 157 unsigned h = s[0] % ht->hashsiz;
Chris@10 158 A(h == (s[0] % ht->hashsiz));
Chris@10 159 return h;
Chris@10 160 }
Chris@10 161
Chris@10 162 /* second hash function (for double hashing) */
Chris@10 163 static unsigned h2(const hashtab *ht, const md5sig s)
Chris@10 164 {
Chris@10 165 unsigned h = 1U + s[1] % (ht->hashsiz - 1);
Chris@10 166 A(h == (1U + s[1] % (ht->hashsiz - 1)));
Chris@10 167 return h;
Chris@10 168 }
Chris@10 169
Chris@10 170 static void md5hash(md5 *m, const problem *p, const planner *plnr)
Chris@10 171 {
Chris@10 172 X(md5begin)(m);
Chris@10 173 X(md5unsigned)(m, sizeof(R)); /* so we don't mix different precisions */
Chris@10 174 X(md5int)(m, plnr->nthr);
Chris@10 175 p->adt->hash(p, m);
Chris@10 176 X(md5end)(m);
Chris@10 177 }
Chris@10 178
Chris@10 179 static int md5eq(const md5sig a, const md5sig b)
Chris@10 180 {
Chris@10 181 return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3];
Chris@10 182 }
Chris@10 183
Chris@10 184 static void sigcpy(const md5sig a, md5sig b)
Chris@10 185 {
Chris@10 186 b[0] = a[0]; b[1] = a[1]; b[2] = a[2]; b[3] = a[3];
Chris@10 187 }
Chris@10 188
Chris@10 189 /*
Chris@10 190 memoization routines :
Chris@10 191 */
Chris@10 192
Chris@10 193 /*
Chris@10 194 liber scriptus proferetur
Chris@10 195 in quo totum continetur
Chris@10 196 unde mundus iudicetur
Chris@10 197 */
Chris@10 198 struct solution_s {
Chris@10 199 md5sig s;
Chris@10 200 flags_t flags;
Chris@10 201 };
Chris@10 202
Chris@10 203 static solution *htab_lookup(hashtab *ht, const md5sig s,
Chris@10 204 const flags_t *flagsp)
Chris@10 205 {
Chris@10 206 unsigned g, h = h1(ht, s), d = h2(ht, s);
Chris@10 207 solution *best = 0;
Chris@10 208
Chris@10 209 ++ht->lookup;
Chris@10 210
Chris@10 211 /* search all entries that match; select the one with
Chris@10 212 the lowest flags.u */
Chris@10 213 /* This loop may potentially traverse the whole table, since at
Chris@10 214 least one element is guaranteed to be !LIVEP, but all elements
Chris@10 215 may be VALIDP. Hence, we stop after at the first invalid
Chris@10 216 element or after traversing the whole table. */
Chris@10 217 g = h;
Chris@10 218 do {
Chris@10 219 solution *l = ht->solutions + g;
Chris@10 220 ++ht->lookup_iter;
Chris@10 221 if (VALIDP(l)) {
Chris@10 222 if (LIVEP(l)
Chris@10 223 && md5eq(s, l->s)
Chris@10 224 && subsumes(&l->flags, SLVNDX(l), flagsp) ) {
Chris@10 225 if (!best || LEQ(l->flags.u, best->flags.u))
Chris@10 226 best = l;
Chris@10 227 }
Chris@10 228 } else
Chris@10 229 break;
Chris@10 230
Chris@10 231 g = addmod(g, d, ht->hashsiz);
Chris@10 232 } while (g != h);
Chris@10 233
Chris@10 234 if (best)
Chris@10 235 ++ht->succ_lookup;
Chris@10 236 return best;
Chris@10 237 }
Chris@10 238
Chris@10 239 static solution *hlookup(planner *ego, const md5sig s,
Chris@10 240 const flags_t *flagsp)
Chris@10 241 {
Chris@10 242 solution *sol = htab_lookup(&ego->htab_blessed, s, flagsp);
Chris@10 243 if (!sol) sol = htab_lookup(&ego->htab_unblessed, s, flagsp);
Chris@10 244 return sol;
Chris@10 245 }
Chris@10 246
Chris@10 247 static void fill_slot(hashtab *ht, const md5sig s, const flags_t *flagsp,
Chris@10 248 unsigned slvndx, solution *slot)
Chris@10 249 {
Chris@10 250 ++ht->insert;
Chris@10 251 ++ht->nelem;
Chris@10 252 A(!LIVEP(slot));
Chris@10 253 slot->flags.u = flagsp->u;
Chris@10 254 slot->flags.l = flagsp->l;
Chris@10 255 slot->flags.timelimit_impatience = flagsp->timelimit_impatience;
Chris@10 256 slot->flags.hash_info |= H_VALID | H_LIVE;
Chris@10 257 SLVNDX(slot) = slvndx;
Chris@10 258
Chris@10 259 /* keep this check enabled in case we add so many solvers
Chris@10 260 that the bitfield overflows */
Chris@10 261 CK(SLVNDX(slot) == slvndx);
Chris@10 262 sigcpy(s, slot->s);
Chris@10 263 }
Chris@10 264
Chris@10 265 static void kill_slot(hashtab *ht, solution *slot)
Chris@10 266 {
Chris@10 267 A(LIVEP(slot)); /* ==> */ A(VALIDP(slot));
Chris@10 268
Chris@10 269 --ht->nelem;
Chris@10 270 slot->flags.hash_info = H_VALID;
Chris@10 271 }
Chris@10 272
Chris@10 273 static void hinsert0(hashtab *ht, const md5sig s, const flags_t *flagsp,
Chris@10 274 unsigned slvndx)
Chris@10 275 {
Chris@10 276 solution *l;
Chris@10 277 unsigned g, h = h1(ht, s), d = h2(ht, s);
Chris@10 278
Chris@10 279 ++ht->insert_unknown;
Chris@10 280
Chris@10 281 /* search for nonfull slot */
Chris@10 282 for (g = h; ; g = addmod(g, d, ht->hashsiz)) {
Chris@10 283 ++ht->insert_iter;
Chris@10 284 l = ht->solutions + g;
Chris@10 285 if (!LIVEP(l)) break;
Chris@10 286 A((g + d) % ht->hashsiz != h);
Chris@10 287 }
Chris@10 288
Chris@10 289 fill_slot(ht, s, flagsp, slvndx, l);
Chris@10 290 }
Chris@10 291
Chris@10 292 static void rehash(hashtab *ht, unsigned nsiz)
Chris@10 293 {
Chris@10 294 unsigned osiz = ht->hashsiz, h;
Chris@10 295 solution *osol = ht->solutions, *nsol;
Chris@10 296
Chris@10 297 nsiz = (unsigned)X(next_prime)((INT)nsiz);
Chris@10 298 nsol = (solution *)MALLOC(nsiz * sizeof(solution), HASHT);
Chris@10 299 ++ht->nrehash;
Chris@10 300
Chris@10 301 /* init new table */
Chris@10 302 for (h = 0; h < nsiz; ++h)
Chris@10 303 nsol[h].flags.hash_info = 0;
Chris@10 304
Chris@10 305 /* install new table */
Chris@10 306 ht->hashsiz = nsiz;
Chris@10 307 ht->solutions = nsol;
Chris@10 308 ht->nelem = 0;
Chris@10 309
Chris@10 310 /* copy table */
Chris@10 311 for (h = 0; h < osiz; ++h) {
Chris@10 312 solution *l = osol + h;
Chris@10 313 if (LIVEP(l))
Chris@10 314 hinsert0(ht, l->s, &l->flags, SLVNDX(l));
Chris@10 315 }
Chris@10 316
Chris@10 317 X(ifree0)(osol);
Chris@10 318 }
Chris@10 319
Chris@10 320 static unsigned minsz(unsigned nelem)
Chris@10 321 {
Chris@10 322 return 1U + nelem + nelem / 8U;
Chris@10 323 }
Chris@10 324
Chris@10 325 static unsigned nextsz(unsigned nelem)
Chris@10 326 {
Chris@10 327 return minsz(minsz(nelem));
Chris@10 328 }
Chris@10 329
Chris@10 330 static void hgrow(hashtab *ht)
Chris@10 331 {
Chris@10 332 unsigned nelem = ht->nelem;
Chris@10 333 if (minsz(nelem) >= ht->hashsiz)
Chris@10 334 rehash(ht, nextsz(nelem));
Chris@10 335 }
Chris@10 336
Chris@10 337 #if 0
Chris@10 338 /* shrink the hash table, never used */
Chris@10 339 static void hshrink(hashtab *ht)
Chris@10 340 {
Chris@10 341 unsigned nelem = ht->nelem;
Chris@10 342 /* always rehash after deletions */
Chris@10 343 rehash(ht, nextsz(nelem));
Chris@10 344 }
Chris@10 345 #endif
Chris@10 346
Chris@10 347 static void htab_insert(hashtab *ht, const md5sig s, const flags_t *flagsp,
Chris@10 348 unsigned slvndx)
Chris@10 349 {
Chris@10 350 unsigned g, h = h1(ht, s), d = h2(ht, s);
Chris@10 351 solution *first = 0;
Chris@10 352
Chris@10 353 /* Remove all entries that are subsumed by the new one. */
Chris@10 354 /* This loop may potentially traverse the whole table, since at
Chris@10 355 least one element is guaranteed to be !LIVEP, but all elements
Chris@10 356 may be VALIDP. Hence, we stop after at the first invalid
Chris@10 357 element or after traversing the whole table. */
Chris@10 358 g = h;
Chris@10 359 do {
Chris@10 360 solution *l = ht->solutions + g;
Chris@10 361 ++ht->insert_iter;
Chris@10 362 if (VALIDP(l)) {
Chris@10 363 if (LIVEP(l) && md5eq(s, l->s)) {
Chris@10 364 if (subsumes(flagsp, slvndx, &l->flags)) {
Chris@10 365 if (!first) first = l;
Chris@10 366 kill_slot(ht, l);
Chris@10 367 } else {
Chris@10 368 /* It is an error to insert an element that
Chris@10 369 is subsumed by an existing entry. */
Chris@10 370 A(!subsumes(&l->flags, SLVNDX(l), flagsp));
Chris@10 371 }
Chris@10 372 }
Chris@10 373 } else
Chris@10 374 break;
Chris@10 375
Chris@10 376 g = addmod(g, d, ht->hashsiz);
Chris@10 377 } while (g != h);
Chris@10 378
Chris@10 379 if (first) {
Chris@10 380 /* overwrite FIRST */
Chris@10 381 fill_slot(ht, s, flagsp, slvndx, first);
Chris@10 382 } else {
Chris@10 383 /* create a new entry */
Chris@10 384 hgrow(ht);
Chris@10 385 hinsert0(ht, s, flagsp, slvndx);
Chris@10 386 }
Chris@10 387 }
Chris@10 388
Chris@10 389 static void hinsert(planner *ego, const md5sig s, const flags_t *flagsp,
Chris@10 390 unsigned slvndx)
Chris@10 391 {
Chris@10 392 htab_insert(BLISS(*flagsp) ? &ego->htab_blessed : &ego->htab_unblessed,
Chris@10 393 s, flagsp, slvndx );
Chris@10 394 }
Chris@10 395
Chris@10 396
Chris@10 397 static void invoke_hook(planner *ego, plan *pln, const problem *p,
Chris@10 398 int optimalp)
Chris@10 399 {
Chris@10 400 if (ego->hook)
Chris@10 401 ego->hook(ego, pln, p, optimalp);
Chris@10 402 }
Chris@10 403
Chris@10 404 #ifdef FFTW_RANDOM_ESTIMATOR
Chris@10 405 /* a "random" estimate, used for debugging to generate "random"
Chris@10 406 plans, albeit from a deterministic seed. */
Chris@10 407
Chris@10 408 unsigned X(random_estimate_seed) = 0;
Chris@10 409
Chris@10 410 static double random_estimate(const planner *ego, const plan *pln,
Chris@10 411 const problem *p)
Chris@10 412 {
Chris@10 413 md5 m;
Chris@10 414 X(md5begin)(&m);
Chris@10 415 X(md5unsigned)(&m, X(random_estimate_seed));
Chris@10 416 X(md5int)(&m, ego->nthr);
Chris@10 417 p->adt->hash(p, &m);
Chris@10 418 X(md5putb)(&m, &pln->ops, sizeof(pln->ops));
Chris@10 419 X(md5putb)(&m, &pln->adt, sizeof(pln->adt));
Chris@10 420 X(md5end)(&m);
Chris@10 421 return ego->cost_hook ? ego->cost_hook(p, m.s[0], COST_MAX) : m.s[0];
Chris@10 422 }
Chris@10 423
Chris@10 424 #endif
Chris@10 425
Chris@10 426 double X(iestimate_cost)(const planner *ego, const plan *pln, const problem *p)
Chris@10 427 {
Chris@10 428 double cost =
Chris@10 429 + pln->ops.add
Chris@10 430 + pln->ops.mul
Chris@10 431
Chris@10 432 #if HAVE_FMA
Chris@10 433 + pln->ops.fma
Chris@10 434 #else
Chris@10 435 + 2 * pln->ops.fma
Chris@10 436 #endif
Chris@10 437
Chris@10 438 + pln->ops.other;
Chris@10 439 if (ego->cost_hook)
Chris@10 440 cost = ego->cost_hook(p, cost, COST_MAX);
Chris@10 441 return cost;
Chris@10 442 }
Chris@10 443
Chris@10 444 static void evaluate_plan(planner *ego, plan *pln, const problem *p)
Chris@10 445 {
Chris@10 446 if (ESTIMATEP(ego) || !BELIEVE_PCOSTP(ego) || pln->pcost == 0.0) {
Chris@10 447 ego->nplan++;
Chris@10 448
Chris@10 449 if (ESTIMATEP(ego)) {
Chris@10 450 estimate:
Chris@10 451 /* heuristic */
Chris@10 452 #ifdef FFTW_RANDOM_ESTIMATOR
Chris@10 453 pln->pcost = random_estimate(ego, pln, p);
Chris@10 454 ego->epcost += X(iestimate_cost)(ego, pln, p);
Chris@10 455 #else
Chris@10 456 pln->pcost = X(iestimate_cost)(ego, pln, p);
Chris@10 457 ego->epcost += pln->pcost;
Chris@10 458 #endif
Chris@10 459 } else {
Chris@10 460 double t = X(measure_execution_time)(ego, pln, p);
Chris@10 461
Chris@10 462 if (t < 0) { /* unavailable cycle counter */
Chris@10 463 /* Real programmers can write FORTRAN in any language */
Chris@10 464 goto estimate;
Chris@10 465 }
Chris@10 466
Chris@10 467 pln->pcost = t;
Chris@10 468 ego->pcost += t;
Chris@10 469 ego->need_timeout_check = 1;
Chris@10 470 }
Chris@10 471 }
Chris@10 472
Chris@10 473 invoke_hook(ego, pln, p, 0);
Chris@10 474 }
Chris@10 475
Chris@10 476 /* maintain dynamic scoping of flags, nthr: */
Chris@10 477 static plan *invoke_solver(planner *ego, const problem *p, solver *s,
Chris@10 478 const flags_t *nflags)
Chris@10 479 {
Chris@10 480 flags_t flags = ego->flags;
Chris@10 481 int nthr = ego->nthr;
Chris@10 482 plan *pln;
Chris@10 483 ego->flags = *nflags;
Chris@10 484 PLNR_TIMELIMIT_IMPATIENCE(ego) = 0;
Chris@10 485 A(p->adt->problem_kind == s->adt->problem_kind);
Chris@10 486 pln = s->adt->mkplan(s, p, ego);
Chris@10 487 ego->nthr = nthr;
Chris@10 488 ego->flags = flags;
Chris@10 489 return pln;
Chris@10 490 }
Chris@10 491
Chris@10 492 /* maintain the invariant TIMED_OUT ==> NEED_TIMEOUT_CHECK */
Chris@10 493 static int timeout_p(planner *ego, const problem *p)
Chris@10 494 {
Chris@10 495 /* do not timeout when estimating. First, the estimator is the
Chris@10 496 planner of last resort. Second, calling X(elapsed_since)() is
Chris@10 497 slower than estimating */
Chris@10 498 if (!ESTIMATEP(ego)) {
Chris@10 499 /* do not assume that X(elapsed_since)() is monotonic */
Chris@10 500 if (ego->timed_out) {
Chris@10 501 A(ego->need_timeout_check);
Chris@10 502 return 1;
Chris@10 503 }
Chris@10 504
Chris@10 505 if (ego->timelimit >= 0 &&
Chris@10 506 X(elapsed_since)(ego, p, ego->start_time) >= ego->timelimit) {
Chris@10 507 ego->timed_out = 1;
Chris@10 508 ego->need_timeout_check = 1;
Chris@10 509 return 1;
Chris@10 510 }
Chris@10 511 }
Chris@10 512
Chris@10 513 A(!ego->timed_out);
Chris@10 514 ego->need_timeout_check = 0;
Chris@10 515 return 0;
Chris@10 516 }
Chris@10 517
Chris@10 518 static plan *search0(planner *ego, const problem *p, unsigned *slvndx,
Chris@10 519 const flags_t *flagsp)
Chris@10 520 {
Chris@10 521 plan *best = 0;
Chris@10 522 int best_not_yet_timed = 1;
Chris@10 523
Chris@10 524 /* Do not start a search if the planner timed out. This check is
Chris@10 525 necessary, lest the relaxation mechanism kick in */
Chris@10 526 if (timeout_p(ego, p))
Chris@10 527 return 0;
Chris@10 528
Chris@10 529 FORALL_SOLVERS_OF_KIND(p->adt->problem_kind, ego, s, sp, {
Chris@10 530 plan *pln;
Chris@10 531
Chris@10 532 pln = invoke_solver(ego, p, s, flagsp);
Chris@10 533
Chris@10 534 if (ego->need_timeout_check)
Chris@10 535 if (timeout_p(ego, p)) {
Chris@10 536 X(plan_destroy_internal)(pln);
Chris@10 537 X(plan_destroy_internal)(best);
Chris@10 538 return 0;
Chris@10 539 }
Chris@10 540
Chris@10 541 if (pln) {
Chris@10 542 /* read COULD_PRUNE_NOW_P because PLN may be destroyed
Chris@10 543 before we use COULD_PRUNE_NOW_P */
Chris@10 544 int could_prune_now_p = pln->could_prune_now_p;
Chris@10 545
Chris@10 546 if (best) {
Chris@10 547 if (best_not_yet_timed) {
Chris@10 548 evaluate_plan(ego, best, p);
Chris@10 549 best_not_yet_timed = 0;
Chris@10 550 }
Chris@10 551 evaluate_plan(ego, pln, p);
Chris@10 552 if (pln->pcost < best->pcost) {
Chris@10 553 X(plan_destroy_internal)(best);
Chris@10 554 best = pln;
Chris@10 555 *slvndx = sp - ego->slvdescs;
Chris@10 556 } else {
Chris@10 557 X(plan_destroy_internal)(pln);
Chris@10 558 }
Chris@10 559 } else {
Chris@10 560 best = pln;
Chris@10 561 *slvndx = sp - ego->slvdescs;
Chris@10 562 }
Chris@10 563
Chris@10 564 if (ALLOW_PRUNINGP(ego) && could_prune_now_p)
Chris@10 565 break;
Chris@10 566 }
Chris@10 567 });
Chris@10 568
Chris@10 569 return best;
Chris@10 570 }
Chris@10 571
Chris@10 572 static plan *search(planner *ego, const problem *p, unsigned *slvndx,
Chris@10 573 flags_t *flagsp)
Chris@10 574 {
Chris@10 575 plan *pln = 0;
Chris@10 576 unsigned i;
Chris@10 577
Chris@10 578 /* relax impatience in this order: */
Chris@10 579 static const unsigned relax_tab[] = {
Chris@10 580 0, /* relax nothing */
Chris@10 581 NO_VRECURSE,
Chris@10 582 NO_FIXED_RADIX_LARGE_N,
Chris@10 583 NO_SLOW,
Chris@10 584 NO_UGLY
Chris@10 585 };
Chris@10 586
Chris@10 587 unsigned l_orig = flagsp->l;
Chris@10 588 unsigned x = flagsp->u;
Chris@10 589
Chris@10 590 /* guaranteed to be different from X */
Chris@10 591 unsigned last_x = ~x;
Chris@10 592
Chris@10 593 for (i = 0; i < sizeof(relax_tab) / sizeof(relax_tab[0]); ++i) {
Chris@10 594 if (LEQ(l_orig, x & ~relax_tab[i]))
Chris@10 595 x = x & ~relax_tab[i];
Chris@10 596
Chris@10 597 if (x != last_x) {
Chris@10 598 last_x = x;
Chris@10 599 flagsp->l = x;
Chris@10 600 pln = search0(ego, p, slvndx, flagsp);
Chris@10 601 if (pln) break;
Chris@10 602 }
Chris@10 603 }
Chris@10 604
Chris@10 605 if (!pln) {
Chris@10 606 /* search [L_ORIG, U] */
Chris@10 607 if (l_orig != last_x) {
Chris@10 608 last_x = l_orig;
Chris@10 609 flagsp->l = l_orig;
Chris@10 610 pln = search0(ego, p, slvndx, flagsp);
Chris@10 611 }
Chris@10 612 }
Chris@10 613
Chris@10 614 return pln;
Chris@10 615 }
Chris@10 616
Chris@10 617 #define CHECK_FOR_BOGOSITY \
Chris@10 618 if ((ego->bogosity_hook ? \
Chris@10 619 (ego->wisdom_state = ego->bogosity_hook(ego->wisdom_state, p)) \
Chris@10 620 : ego->wisdom_state) == WISDOM_IS_BOGUS) \
Chris@10 621 goto wisdom_is_bogus;
Chris@10 622
Chris@10 623 static plan *mkplan(planner *ego, const problem *p)
Chris@10 624 {
Chris@10 625 plan *pln;
Chris@10 626 md5 m;
Chris@10 627 unsigned slvndx;
Chris@10 628 flags_t flags_of_solution;
Chris@10 629 solution *sol;
Chris@10 630 solver *s;
Chris@10 631
Chris@10 632 ASSERT_ALIGNED_DOUBLE;
Chris@10 633 A(LEQ(PLNR_L(ego), PLNR_U(ego)));
Chris@10 634
Chris@10 635 if (ESTIMATEP(ego))
Chris@10 636 PLNR_TIMELIMIT_IMPATIENCE(ego) = 0; /* canonical form */
Chris@10 637
Chris@10 638
Chris@10 639 #ifdef FFTW_DEBUG
Chris@10 640 check(&ego->htab_blessed);
Chris@10 641 check(&ego->htab_unblessed);
Chris@10 642 #endif
Chris@10 643
Chris@10 644 pln = 0;
Chris@10 645
Chris@10 646 CHECK_FOR_BOGOSITY;
Chris@10 647
Chris@10 648 ego->timed_out = 0;
Chris@10 649
Chris@10 650 ++ego->nprob;
Chris@10 651 md5hash(&m, p, ego);
Chris@10 652
Chris@10 653 flags_of_solution = ego->flags;
Chris@10 654
Chris@10 655 if (ego->wisdom_state != WISDOM_IGNORE_ALL) {
Chris@10 656 if ((sol = hlookup(ego, m.s, &flags_of_solution))) {
Chris@10 657 /* wisdom is acceptable */
Chris@10 658 wisdom_state_t owisdom_state = ego->wisdom_state;
Chris@10 659
Chris@10 660 /* this hook is mainly for MPI, to make sure that
Chris@10 661 wisdom is in sync across all processes for MPI problems */
Chris@10 662 if (ego->wisdom_ok_hook && !ego->wisdom_ok_hook(p, sol->flags))
Chris@10 663 goto do_search; /* ignore not-ok wisdom */
Chris@10 664
Chris@10 665 slvndx = SLVNDX(sol);
Chris@10 666
Chris@10 667 if (slvndx == INFEASIBLE_SLVNDX) {
Chris@10 668 if (ego->wisdom_state == WISDOM_IGNORE_INFEASIBLE)
Chris@10 669 goto do_search;
Chris@10 670 else
Chris@10 671 return 0; /* known to be infeasible */
Chris@10 672 }
Chris@10 673
Chris@10 674 flags_of_solution = sol->flags;
Chris@10 675
Chris@10 676 /* inherit blessing either from wisdom
Chris@10 677 or from the planner */
Chris@10 678 flags_of_solution.hash_info |= BLISS(ego->flags);
Chris@10 679
Chris@10 680 ego->wisdom_state = WISDOM_ONLY;
Chris@10 681
Chris@10 682 s = ego->slvdescs[slvndx].slv;
Chris@10 683 if (p->adt->problem_kind != s->adt->problem_kind)
Chris@10 684 goto wisdom_is_bogus;
Chris@10 685
Chris@10 686 pln = invoke_solver(ego, p, s, &flags_of_solution);
Chris@10 687
Chris@10 688 CHECK_FOR_BOGOSITY; /* catch error in child solvers */
Chris@10 689
Chris@10 690 sol = 0; /* Paranoia: SOL may be dangling after
Chris@10 691 invoke_solver(); make sure we don't accidentally
Chris@10 692 reuse it. */
Chris@10 693
Chris@10 694 if (!pln)
Chris@10 695 goto wisdom_is_bogus;
Chris@10 696
Chris@10 697 ego->wisdom_state = owisdom_state;
Chris@10 698
Chris@10 699 goto skip_search;
Chris@10 700 }
Chris@10 701 else if (ego->nowisdom_hook) /* for MPI, make sure lack of wisdom */
Chris@10 702 ego->nowisdom_hook(p); /* is in sync across all processes */
Chris@10 703 }
Chris@10 704
Chris@10 705 do_search:
Chris@10 706 /* cannot search in WISDOM_ONLY mode */
Chris@10 707 if (ego->wisdom_state == WISDOM_ONLY)
Chris@10 708 goto wisdom_is_bogus;
Chris@10 709
Chris@10 710 flags_of_solution = ego->flags;
Chris@10 711 pln = search(ego, p, &slvndx, &flags_of_solution);
Chris@10 712 CHECK_FOR_BOGOSITY; /* catch error in child solvers */
Chris@10 713
Chris@10 714 if (ego->timed_out) {
Chris@10 715 A(!pln);
Chris@10 716 if (PLNR_TIMELIMIT_IMPATIENCE(ego) != 0) {
Chris@10 717 /* record (below) that this plan has failed because of
Chris@10 718 timeout */
Chris@10 719 flags_of_solution.hash_info |= BLESSING;
Chris@10 720 } else {
Chris@10 721 /* this is not the top-level problem or timeout is not
Chris@10 722 active: record no wisdom. */
Chris@10 723 return 0;
Chris@10 724 }
Chris@10 725 } else {
Chris@10 726 /* canonicalize to infinite timeout */
Chris@10 727 flags_of_solution.timelimit_impatience = 0;
Chris@10 728 }
Chris@10 729
Chris@10 730 skip_search:
Chris@10 731 if (ego->wisdom_state == WISDOM_NORMAL ||
Chris@10 732 ego->wisdom_state == WISDOM_ONLY) {
Chris@10 733 if (pln) {
Chris@10 734 hinsert(ego, m.s, &flags_of_solution, slvndx);
Chris@10 735 invoke_hook(ego, pln, p, 1);
Chris@10 736 } else {
Chris@10 737 hinsert(ego, m.s, &flags_of_solution, INFEASIBLE_SLVNDX);
Chris@10 738 }
Chris@10 739 }
Chris@10 740
Chris@10 741 return pln;
Chris@10 742
Chris@10 743 wisdom_is_bogus:
Chris@10 744 X(plan_destroy_internal)(pln);
Chris@10 745 ego->wisdom_state = WISDOM_IS_BOGUS;
Chris@10 746 return 0;
Chris@10 747 }
Chris@10 748
Chris@10 749 static void htab_destroy(hashtab *ht)
Chris@10 750 {
Chris@10 751 X(ifree)(ht->solutions);
Chris@10 752 ht->solutions = 0;
Chris@10 753 ht->nelem = 0U;
Chris@10 754 }
Chris@10 755
Chris@10 756 static void mkhashtab(hashtab *ht)
Chris@10 757 {
Chris@10 758 ht->nrehash = 0;
Chris@10 759 ht->succ_lookup = ht->lookup = ht->lookup_iter = 0;
Chris@10 760 ht->insert = ht->insert_iter = ht->insert_unknown = 0;
Chris@10 761
Chris@10 762 ht->solutions = 0;
Chris@10 763 ht->hashsiz = ht->nelem = 0U;
Chris@10 764 hgrow(ht); /* so that hashsiz > 0 */
Chris@10 765 }
Chris@10 766
Chris@10 767 /* destroy hash table entries. If FORGET_EVERYTHING, destroy the whole
Chris@10 768 table. If FORGET_ACCURSED, then destroy entries that are not blessed. */
Chris@10 769 static void forget(planner *ego, amnesia a)
Chris@10 770 {
Chris@10 771 switch (a) {
Chris@10 772 case FORGET_EVERYTHING:
Chris@10 773 htab_destroy(&ego->htab_blessed);
Chris@10 774 mkhashtab(&ego->htab_blessed);
Chris@10 775 /* fall through */
Chris@10 776 case FORGET_ACCURSED:
Chris@10 777 htab_destroy(&ego->htab_unblessed);
Chris@10 778 mkhashtab(&ego->htab_unblessed);
Chris@10 779 break;
Chris@10 780 default:
Chris@10 781 break;
Chris@10 782 }
Chris@10 783 }
Chris@10 784
Chris@10 785 /* FIXME: what sort of version information should we write? */
Chris@10 786 #define WISDOM_PREAMBLE PACKAGE "-" VERSION " " STRINGIZE(X(wisdom))
Chris@10 787 static const char stimeout[] = "TIMEOUT";
Chris@10 788
Chris@10 789 /* tantus labor non sit cassus */
Chris@10 790 static void exprt(planner *ego, printer *p)
Chris@10 791 {
Chris@10 792 unsigned h;
Chris@10 793 hashtab *ht = &ego->htab_blessed;
Chris@10 794 md5 m;
Chris@10 795
Chris@10 796 signature_of_configuration(&m, ego);
Chris@10 797
Chris@10 798 p->print(p,
Chris@10 799 "(" WISDOM_PREAMBLE " #x%M #x%M #x%M #x%M\n",
Chris@10 800 m.s[0], m.s[1], m.s[2], m.s[3]);
Chris@10 801
Chris@10 802 for (h = 0; h < ht->hashsiz; ++h) {
Chris@10 803 solution *l = ht->solutions + h;
Chris@10 804 if (LIVEP(l)) {
Chris@10 805 const char *reg_nam;
Chris@10 806 int reg_id;
Chris@10 807
Chris@10 808 if (SLVNDX(l) == INFEASIBLE_SLVNDX) {
Chris@10 809 reg_nam = stimeout;
Chris@10 810 reg_id = 0;
Chris@10 811 } else {
Chris@10 812 slvdesc *sp = ego->slvdescs + SLVNDX(l);
Chris@10 813 reg_nam = sp->reg_nam;
Chris@10 814 reg_id = sp->reg_id;
Chris@10 815 }
Chris@10 816
Chris@10 817 /* qui salvandos salvas gratis
Chris@10 818 salva me fons pietatis */
Chris@10 819 p->print(p, " (%s %d #x%x #x%x #x%x #x%M #x%M #x%M #x%M)\n",
Chris@10 820 reg_nam, reg_id,
Chris@10 821 l->flags.l, l->flags.u, l->flags.timelimit_impatience,
Chris@10 822 l->s[0], l->s[1], l->s[2], l->s[3]);
Chris@10 823 }
Chris@10 824 }
Chris@10 825 p->print(p, ")\n");
Chris@10 826 }
Chris@10 827
Chris@10 828 /* mors stupebit et natura
Chris@10 829 cum resurget creatura */
Chris@10 830 static int imprt(planner *ego, scanner *sc)
Chris@10 831 {
Chris@10 832 char buf[MAXNAM + 1];
Chris@10 833 md5uint sig[4];
Chris@10 834 unsigned l, u, timelimit_impatience;
Chris@10 835 flags_t flags;
Chris@10 836 int reg_id;
Chris@10 837 unsigned slvndx;
Chris@10 838 hashtab *ht = &ego->htab_blessed;
Chris@10 839 hashtab old;
Chris@10 840 md5 m;
Chris@10 841
Chris@10 842 if (!sc->scan(sc,
Chris@10 843 "(" WISDOM_PREAMBLE " #x%M #x%M #x%M #x%M\n",
Chris@10 844 sig + 0, sig + 1, sig + 2, sig + 3))
Chris@10 845 return 0; /* don't need to restore hashtable */
Chris@10 846
Chris@10 847 signature_of_configuration(&m, ego);
Chris@10 848 if (m.s[0] != sig[0] || m.s[1] != sig[1] ||
Chris@10 849 m.s[2] != sig[2] || m.s[3] != sig[3]) {
Chris@10 850 /* invalid configuration */
Chris@10 851 return 0;
Chris@10 852 }
Chris@10 853
Chris@10 854 /* make a backup copy of the hash table (cache the hash) */
Chris@10 855 {
Chris@10 856 unsigned h, hsiz = ht->hashsiz;
Chris@10 857 old = *ht;
Chris@10 858 old.solutions = (solution *)MALLOC(hsiz * sizeof(solution), HASHT);
Chris@10 859 for (h = 0; h < hsiz; ++h)
Chris@10 860 old.solutions[h] = ht->solutions[h];
Chris@10 861 }
Chris@10 862
Chris@10 863 while (1) {
Chris@10 864 if (sc->scan(sc, ")"))
Chris@10 865 break;
Chris@10 866
Chris@10 867 /* qua resurget ex favilla */
Chris@10 868 if (!sc->scan(sc, "(%*s %d #x%x #x%x #x%x #x%M #x%M #x%M #x%M)",
Chris@10 869 MAXNAM, buf, &reg_id, &l, &u, &timelimit_impatience,
Chris@10 870 sig + 0, sig + 1, sig + 2, sig + 3))
Chris@10 871 goto bad;
Chris@10 872
Chris@10 873 if (!strcmp(buf, stimeout) && reg_id == 0) {
Chris@10 874 slvndx = INFEASIBLE_SLVNDX;
Chris@10 875 } else {
Chris@10 876 if (timelimit_impatience != 0)
Chris@10 877 goto bad;
Chris@10 878
Chris@10 879 slvndx = slookup(ego, buf, reg_id);
Chris@10 880 if (slvndx == INFEASIBLE_SLVNDX)
Chris@10 881 goto bad;
Chris@10 882 }
Chris@10 883
Chris@10 884 /* inter oves locum praesta */
Chris@10 885 flags.l = l;
Chris@10 886 flags.u = u;
Chris@10 887 flags.timelimit_impatience = timelimit_impatience;
Chris@10 888 flags.hash_info = BLESSING;
Chris@10 889
Chris@10 890 CK(flags.l == l);
Chris@10 891 CK(flags.u == u);
Chris@10 892 CK(flags.timelimit_impatience == timelimit_impatience);
Chris@10 893
Chris@10 894 if (!hlookup(ego, sig, &flags))
Chris@10 895 hinsert(ego, sig, &flags, slvndx);
Chris@10 896 }
Chris@10 897
Chris@10 898 X(ifree0)(old.solutions);
Chris@10 899 return 1;
Chris@10 900
Chris@10 901 bad:
Chris@10 902 /* ``The wisdom of FFTW must be above suspicion.'' */
Chris@10 903 X(ifree0)(ht->solutions);
Chris@10 904 *ht = old;
Chris@10 905 return 0;
Chris@10 906 }
Chris@10 907
Chris@10 908 /*
Chris@10 909 * create a planner
Chris@10 910 */
Chris@10 911 planner *X(mkplanner)(void)
Chris@10 912 {
Chris@10 913 int i;
Chris@10 914
Chris@10 915 static const planner_adt padt = {
Chris@10 916 register_solver, mkplan, forget, exprt, imprt
Chris@10 917 };
Chris@10 918
Chris@10 919 planner *p = (planner *) MALLOC(sizeof(planner), PLANNERS);
Chris@10 920
Chris@10 921 p->adt = &padt;
Chris@10 922 p->nplan = p->nprob = 0;
Chris@10 923 p->pcost = p->epcost = 0.0;
Chris@10 924 p->hook = 0;
Chris@10 925 p->cost_hook = 0;
Chris@10 926 p->wisdom_ok_hook = 0;
Chris@10 927 p->nowisdom_hook = 0;
Chris@10 928 p->bogosity_hook = 0;
Chris@10 929 p->cur_reg_nam = 0;
Chris@10 930 p->wisdom_state = WISDOM_NORMAL;
Chris@10 931
Chris@10 932 p->slvdescs = 0;
Chris@10 933 p->nslvdesc = p->slvdescsiz = 0;
Chris@10 934
Chris@10 935 p->flags.l = 0;
Chris@10 936 p->flags.u = 0;
Chris@10 937 p->flags.timelimit_impatience = 0;
Chris@10 938 p->flags.hash_info = 0;
Chris@10 939 p->nthr = 1;
Chris@10 940 p->need_timeout_check = 1;
Chris@10 941 p->timelimit = -1;
Chris@10 942
Chris@10 943 mkhashtab(&p->htab_blessed);
Chris@10 944 mkhashtab(&p->htab_unblessed);
Chris@10 945
Chris@10 946 for (i = 0; i < PROBLEM_LAST; ++i)
Chris@10 947 p->slvdescs_for_problem_kind[i] = -1;
Chris@10 948
Chris@10 949 return p;
Chris@10 950 }
Chris@10 951
Chris@10 952 void X(planner_destroy)(planner *ego)
Chris@10 953 {
Chris@10 954 /* destroy hash table */
Chris@10 955 htab_destroy(&ego->htab_blessed);
Chris@10 956 htab_destroy(&ego->htab_unblessed);
Chris@10 957
Chris@10 958 /* destroy solvdesc table */
Chris@10 959 FORALL_SOLVERS(ego, s, sp, {
Chris@10 960 UNUSED(sp);
Chris@10 961 X(solver_destroy)(s);
Chris@10 962 });
Chris@10 963
Chris@10 964 X(ifree0)(ego->slvdescs);
Chris@10 965 X(ifree)(ego); /* dona eis requiem */
Chris@10 966 }
Chris@10 967
Chris@10 968 plan *X(mkplan_d)(planner *ego, problem *p)
Chris@10 969 {
Chris@10 970 plan *pln = ego->adt->mkplan(ego, p);
Chris@10 971 X(problem_destroy)(p);
Chris@10 972 return pln;
Chris@10 973 }
Chris@10 974
Chris@10 975 /* like X(mkplan_d), but sets/resets flags as well */
Chris@10 976 plan *X(mkplan_f_d)(planner *ego, problem *p,
Chris@10 977 unsigned l_set, unsigned u_set, unsigned u_reset)
Chris@10 978 {
Chris@10 979 flags_t oflags = ego->flags;
Chris@10 980 plan *pln;
Chris@10 981
Chris@10 982 PLNR_U(ego) &= ~u_reset;
Chris@10 983 PLNR_L(ego) &= ~u_reset;
Chris@10 984 PLNR_L(ego) |= l_set;
Chris@10 985 PLNR_U(ego) |= u_set | l_set;
Chris@10 986 pln = X(mkplan_d)(ego, p);
Chris@10 987 ego->flags = oflags;
Chris@10 988 return pln;
Chris@10 989 }
Chris@10 990
Chris@10 991 /*
Chris@10 992 * Debugging code:
Chris@10 993 */
Chris@10 994 #ifdef FFTW_DEBUG
Chris@10 995 static void check(hashtab *ht)
Chris@10 996 {
Chris@10 997 unsigned live = 0;
Chris@10 998 unsigned i;
Chris@10 999
Chris@10 1000 A(ht->nelem < ht->hashsiz);
Chris@10 1001
Chris@10 1002 for (i = 0; i < ht->hashsiz; ++i) {
Chris@10 1003 solution *l = ht->solutions + i;
Chris@10 1004 if (LIVEP(l))
Chris@10 1005 ++live;
Chris@10 1006 }
Chris@10 1007
Chris@10 1008 A(ht->nelem == live);
Chris@10 1009
Chris@10 1010 for (i = 0; i < ht->hashsiz; ++i) {
Chris@10 1011 solution *l1 = ht->solutions + i;
Chris@10 1012 int foundit = 0;
Chris@10 1013 if (LIVEP(l1)) {
Chris@10 1014 unsigned g, h = h1(ht, l1->s), d = h2(ht, l1->s);
Chris@10 1015
Chris@10 1016 g = h;
Chris@10 1017 do {
Chris@10 1018 solution *l = ht->solutions + g;
Chris@10 1019 if (VALIDP(l)) {
Chris@10 1020 if (l1 == l)
Chris@10 1021 foundit = 1;
Chris@10 1022 else if (LIVEP(l) && md5eq(l1->s, l->s)) {
Chris@10 1023 A(!subsumes(&l->flags, SLVNDX(l), &l1->flags));
Chris@10 1024 A(!subsumes(&l1->flags, SLVNDX(l1), &l->flags));
Chris@10 1025 }
Chris@10 1026 } else
Chris@10 1027 break;
Chris@10 1028 g = addmod(g, d, ht->hashsiz);
Chris@10 1029 } while (g != h);
Chris@10 1030
Chris@10 1031 A(foundit);
Chris@10 1032 }
Chris@10 1033 }
Chris@10 1034 }
Chris@10 1035 #endif