Ejemplo n.º 1
0
int 
personality (kap_config_t *kc, kap_personality_t *p)
{
    char bn[KAP_MAX_STR];

    if ( !p || !kc )
        return -1;

    p->rank = kap_commfab_rank ();
    p->size = kap_commfab_size ();
    p->iter_count = 0;
    p->role = k_none;
    p->handle = _hndl;

    kap_conf_postinit (kc, p->size);

    /*
     * Assume the rank distribution is cyclic
     * e.g., distributes rank processes to 
     * all of the nodes first before starting to
     * use the core on the first node again.
     */
    if ( p->rank < kc->nproducers ) {
        p->role = k_producer;
    } 
    if ( ((p->size-1) - p->rank) < kc->nconsumers ) {
        p->role = (p->role != k_producer) ?
                    k_consumer :
                    k_both; 
    }
    if (kc->sync_type == s_causal) {
        if ( IS_CONSUMER(p->role) ) {
            if (flux_event_subscribe (p->handle, 
                                KAP_CAUSAL_CONS_EV) < 0) {
                fprintf (stderr, 
                    "Failed: event sub.\n");
                goto error;
            }
        }
    }
    if (kc->iter_consumer > kc->iter_producer) {
        kc->iter_consumer = kc->iter_producer;
    
        fprintf (stderr, 
            "Warning: iter-consumer > than iter-producer.\n");
        fprintf (stderr, 
            "Warning: iter-consumer set to iter-producer.\n");
    }

    snprintf (bn, KAP_MAX_STR,
        "init-hb-%d",
        (int) kc->instance_num);
   
    /* to establish a clean happens-before relationship */
    if (flux_barrier (p->handle, 
            bn, kc->total_num_proc ) < 0) {
        fprintf (stderr,
            "Initial barrier failed.\n");
        goto error;
    } 

    return 0;

error:
    return -1;
}
Ejemplo n.º 2
0
int
main (int argc, char *argv[])
{
    kap_params_t param;

    if ( parse_kap_opts (argc, argv, &(param.config)) < 0 ) {
        fprintf (stderr, "Failed to parse optionsp.\n");
        goto error;
    }
    if ( kap_init (&argc, &argv,
                    &(param.pers), &(param.config)) < 0 ) {
        fprintf (stderr, "Failed to init KAP.\n");
        goto error;
    }
    if ( personality (&(param.config), &(param.pers)) < 0 ) {
        fprintf (stderr, "Failed to set personalities.\n");
        goto error;
    }
    if (param.config.list_config == 1) {
        if (param.pers.rank == 0) {
            print_config (&(param.config));
        }
    }

    /**********************************************************
     *          BEGIN KVS ACCESS PATTERN TEST                 *
     *                                                        *
     **********************************************************/
    if (param.pers.role != k_none)
        Begin_All = now ();

    if ( IS_PRODUCER(param.pers.role) ) {
        Begin_Prod_Phase = now ();
        if ( (run_producer (&param) < 0) ) {
            fprintf (stderr, "Failed to run producers.\n");
            goto error;
        }
        End_Prod_Phase = now ();
    }
    if (param.pers.role != k_none) {
        Begin_Sync_Phase = now ();
        if ( sync_prod_and_cons (&param) < 0 ) {
            fprintf (stderr,
                "Failed to synchronize between producers "
                "and consumers.\n");
            goto error;
        }
        End_Sync_Phase = now ();
    }
    if ( IS_CONSUMER(param.pers.role) ) {
        Begin_Cons_Phase = now ();
        if ( (run_consumer (&param) < 0) ) {
            fprintf (stderr,
                "Failed to run consumers\n");
            goto error;
        }
        End_Cons_Phase = now ();
    }

    if (param.pers.role != k_none)
        End_All = now ();
    /**********************************************************
     *          END KVS ACCESS PATTERN TEST                   *
     *                                                        *
     **********************************************************/

    summarize (&param, &Puts, 1);
    summarize (&param, &Commit_bn_Puts, 0);
    summarize (&param, &Sync_bn_Puts_Gets, 0);
    summarize (&param, &Gets, 1);

    kap_commfab_perf_summary (&(param.config),
                              &(param.pers));

    return EXIT_SUCCESS;
error:
    fatal ();
    return EXIT_FAILURE;
}