Ejemplo n.º 1
0
int rsreader_hwloc_load (resrc_api_ctx_t *rsapi, const char *buf, size_t len,
        uint32_t rank, rsreader_t r_mode, machs_t *machs, char **err_str)
{
    int rc = -1;
    rssig_t *sig = NULL;
    hwloc_topology_t topo;

    if (!machs)
        goto done;

    if (hwloc_topology_init (&topo) != 0)
        goto done;
    if (hwloc_topology_set_xmlbuffer (topo, buf, len) != 0)
        goto err;
    if (hwloc_topology_load (topo) != 0)
        goto err;
    if (rs2rank_set_signature ((char*)buf, len, topo, &sig) != 0)
        goto err;
    if (rs2rank_tab_update (machs, get_hn (topo), sig, rank) != 0)
        goto err;

    if (r_mode == RSREADER_HWLOC) {
        const char *s = rs2rank_get_digest (sig);
        if (!resrc_generate_hwloc_resources (rsapi, topo, s, err_str))
            goto err;
    }

    rc = 0;
err:
    hwloc_topology_destroy (topo);
done:
    return rc;
}
Ejemplo n.º 2
0
static int test_using_reader_hwloc ()
{
    int rc = 1;
    hwloc_topology_t topology;
    resrc_api_ctx_t *rsapi = NULL;
    resrc_tree_t *phys_tree = NULL;

    init_time();

    if (!(rsapi = resrc_api_init ()))
        goto ret;

    ok ((hwloc_topology_init (&topology) == 0),
        "hwloc topology init succeeded");
    ok ((hwloc_topology_load (topology) == 0),
        "hwloc topology load succeeded");
    /* Generate the hardware hierarchy of resources using hwloc reader */
    ok ((resrc_generate_hwloc_resources (rsapi, topology, NULL, NULL) != 0),
        "resource generation from hwloc took: %lf",
        ((double)get_time())/1000000);
    hwloc_topology_destroy (topology);

    phys_tree = resrc_tree_root (rsapi);
    if (!phys_tree)
        goto ret;

    rc = test_a_resrc (rsapi, resrc_tree_resrc (phys_tree), false);

ret:
    if (rsapi) {
        if (phys_tree)
            resrc_tree_destroy (rsapi, phys_tree, true, true);
        resrc_api_fini (rsapi);
    }
    return rc;
}
Ejemplo n.º 3
0
/*
 * These is a test of the resrc library.  The test uses two methods
 * for generating a resrc object.  The first loads an RDL-formatted
 * resource identified by the TESTRESRC_INPUT_FILE environment
 * variable.  The second option generates a resrc object from the node
 * it is running on using the hwloc library.  The test then conducts a
 * number of resrc library operations on each of these resrc objects.
 */
int main (int argc, char *argv[])
{
    char *filename = NULL;
    hwloc_topology_t topology;
    int rc1 = 1, rc2 = 1;
    resrc_t *resrc = NULL;
    resrc_flow_t *power_flow = NULL;
    resrc_flow_t *bw_flow = NULL;

    plan (26 + num_temporal_allocation_tests);
    test_temporal_allocation ();

    if ((filename = getenv ("TESTRESRC_INPUT_FILE"))) {
        ok (!(filename == NULL || *filename == '\0'), "resource file provided");
        ok ((access (filename, F_OK) == 0), "resource file exists");
        ok ((access (filename, R_OK) == 0), "resource file readable");

        init_time();
        resrc_init ();
        resrc = resrc_generate_rdl_resources (filename, "default");
        ok ((resrc != NULL), "resource generation from config file took: %lf",
            ((double)get_time())/1000000);
        if (resrc) {
            power_flow = resrc_flow_generate_rdl (filename, "power");
            if (power_flow) {
                if (verbose) {
                    printf ("Listing power tree\n");
                    resrc_flow_print (power_flow);
                    printf ("End of power tree\n");
                }
                bw_flow = resrc_flow_generate_rdl (filename, "bandwidth");
                if (bw_flow) {
                    if (verbose) {
                        printf ("Listing bandwidth tree\n");
                        resrc_flow_print (bw_flow);
                        printf ("End of bandwidth tree\n");
                    }
                } else
                    goto ret;
            } else
                goto ret;

            rc1 = test_a_resrc (resrc, true);
            resrc_flow_destroy (bw_flow);
            resrc_flow_destroy (power_flow);
            resrc_tree_destroy (resrc_phys_tree (resrc), true);
            resrc_fini ();
        }
    }

    init_time();
    resrc_init ();
    ok ((hwloc_topology_init (&topology) == 0),
        "hwloc topology init succeeded");
    ok ((hwloc_topology_load (topology) == 0),
        "hwloc topology load succeeded");
    ok (((resrc = resrc_create_cluster ("cluster")) != 0),
        "cluster resource creation succeeded");
    ok ((resrc_generate_hwloc_resources (resrc, topology, NULL, NULL) != 0),
        "resource generation from hwloc took: %lf",
        ((double)get_time())/1000000);
    hwloc_topology_destroy (topology);
    if (resrc) {
        rc2 = test_a_resrc (resrc, false);
        resrc_tree_destroy (resrc_phys_tree (resrc), true);
        resrc_fini ();
    }
ret:
    done_testing ();
    return (rc1 | rc2);
}