Пример #1
0
void
cndfs_reduce  (run_t *run, wctx_t *ctx)
{
    if (run->reduced == NULL) {
        run->reduced = RTmallocZero (sizeof (cndfs_reduced_t));
        cndfs_reduced_t        *reduced = (cndfs_reduced_t *) run->reduced;
        reduced->waittime = 0;
    }
    cndfs_reduced_t        *reduced = (cndfs_reduced_t *) run->reduced;
    cndfs_alg_local_t      *cloc = (cndfs_alg_local_t *) ctx->local;
    float                   waittime = RTrealTime(cloc->timer);
    reduced->waittime   += waittime;
    reduced->rec        += cloc->counters.rec;
    reduced->max_load   += fset_max_load (cloc->pink);

    ndfs_reduce (run, ctx);

    if (log_active(infoLong)) {
        fset_print_statistics (cloc->pink, "Pink stack set:");
    }

    if (run->shared->rec != NULL) {
        alg_global_t           *sm = ctx->global;
        alg_reduce (run->shared->rec, sm->rec);
    }
}
Пример #2
0
void
ndfs_reduce  (run_t *run, wctx_t *ctx)
{
    if (run->reduced == NULL) {
        run->reduced = RTmallocZero (sizeof (alg_reduced_t));
    }
    alg_reduced_t          *reduced = run->reduced;
    counter_t              *blue = &ctx->local->counters;
    counter_t              *red = &ctx->local->red;
    work_counter_t         *blue_work = ctx->counters;
    work_counter_t         *red_work = &ctx->local->red_work;

    add_results (&reduced->blue, blue);
    add_results (&reduced->red, red);
    work_add_results (&reduced->red_work, red_work);

    // publish local memory statistics for run class
    run->total.local_states += blue_work->level_max + red_work->level_max;

    if (W >= 4 || !log_active(infoLong)) return;

    // print some local info
    float                   runtime = RTrealTime(ctx->timer);
    Warning (info, "Nested depth-first search worker ran %.3f sec", runtime);
    work_report ("[Blue]", blue_work);
    work_report ("[Red ]", red_work);
}
Пример #3
0
static int
resize (fset_t *dbs, fset_resize_t mode)
{
    void               *key, *data;
    bool                res;
    if (dbs->resizing) return true;
    dbs->resizing = 1;

    size_t              old_size = dbs->size;
    switch (mode) {
    case GROW:
        if (dbs->size == dbs->size_max) {
            dbs->resizing = 0;
            return false;
        }
        memset (dbs->hash + dbs->size, 0, sizeof (mem_hash_t[dbs->size]));
        dbs->size <<= 1;
        dbs->size3 <<= 1;
        break;
    case SHRINK:
        if (dbs->size == dbs->init_size) {
            dbs->resizing = 0;
            return true;
        }
        dbs->size >>= 1;
        dbs->size3 >>= 1;
        break;
    case REHASH: break;
    }
    dbs->mask = dbs->size - 1;
    Debug ("%s %zu to %zu", fset_resize_names[mode], old_size, dbs->size);

    //RTstartTimer (dbs->timer);
    size_t              tombs = 0;
    size_t              todos = 0;
    for (size_t i = 0; i < old_size; i++) {
        mem_hash_t          h = *memoized(dbs,i);
        if (TOMB == h) {
            tombs++;
            *memoized(dbs, i) = EMPTY;
        } else if (h != EMPTY) {// && home_loc(h) & dbs->mask != i) {
            dbs->todo[todos] = *memoized(dbs,i);
            void               *tdata = bucket(dbs, dbs->todo_data, todos);
            void               *data  = bucket(dbs, dbs->data, i);
            memcpy (tdata, data, dbs->total_length);
            todos++;
            *memoized(dbs, i) = EMPTY;
        }
    }
    dbs->tombs -= tombs;
    dbs->load  -= todos;
    HREassert (dbs->tombs == 0);

    for (size_t i = 0; i < todos; i++) {
        mem_hash_t          h = dbs->todo[i];
        key = bucket(dbs, dbs->todo_data, i);
        res = fset_find (dbs, &h, key, &data, true); // load++
        HREassert (!res);
        memcpy (data, key + dbs->key_length, dbs->data_length);
    }

    //RTstopTimer (dbs->timer);
    Debug ("%s %zu to %zu took %zu/%zu todos and cleaned %zu/%zu tombstones in %.2f sec",
           fset_resize_names[mode], old_size, dbs->size, todos, dbs->load, tombs,
           dbs->load + tombs, RTrealTime(dbs->timer));
    dbs->max_todos = max (todos, dbs->max_todos);
    dbs->max_grow = max (dbs->max_grow, dbs->size);
    dbs->resizes++;
    dbs->resizing = 0;
    return true;
}