annotate fft/fftw/fftw-3.3.4/kernel/planner.c @ 40:223f770b5341 kissfft-double tip

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