Exemplo n.º 1
0
void resrc_flow_print (resrc_flow_t *resrc_flow)
{
    if (resrc_flow) {
        resrc_print_resource (resrc_flow->flow_resrc);
        if (resrc_flow_num_children (resrc_flow)) {
            resrc_flow_t *child = resrc_flow_list_first (resrc_flow->children);
            while (child) {
                resrc_flow_print (child);
                child = resrc_flow_list_next (resrc_flow->children);
            }
        }
    }
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
0
static int test_using_reader_rdl ()
{
    int rc = 1;
    char *filename = NULL;
    resrc_api_ctx_t *rsapi = NULL;
    resrc_t *resrc = NULL;
    resrc_tree_t *phys_tree = NULL;
    resrc_flow_t *power_flow = NULL;
    resrc_flow_t *bw_flow = NULL;

    if (!(filename = getenv ("TESTRESRC_INPUT_FILE")))
        goto ret;

    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();

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

    /* Generate a hardware hierarchy of resources using RDL reader */
    resrc = resrc_generate_rdl_resources (rsapi, filename, "default");
    double e = (double)get_time()/1000000;
    ok ((resrc != NULL), "resource generation from config file took: %lf", e);
    if (!resrc)
        goto ret;
    phys_tree = resrc_tree_root (rsapi);

    /* Generate a power hierarchy of resources using RDL reader */
    if (!(power_flow = resrc_flow_generate_rdl (rsapi, filename, "power")))
        goto ret;
    else if (verbose) {
        printf ("Listing power tree\n");
        resrc_flow_print (power_flow);
        printf ("End of power tree\n");
    }

    /* Generate a bandwidth hierarchy of resources using RDL reader */
    if (!(bw_flow = resrc_flow_generate_rdl (rsapi, filename, "bandwidth")))
        goto ret;
    else if (verbose) {
        printf ("Listing bandwidth tree\n");
        resrc_flow_print (bw_flow);
        printf ("End of bandwidth tree\n");
    }

    rc = test_a_resrc (rsapi, resrc, true);

ret:
    if (rsapi) {
        if (bw_flow)
            resrc_flow_destroy (rsapi, bw_flow, true);
        if (power_flow)
            resrc_flow_destroy (rsapi, power_flow, true);
        if (phys_tree)
            resrc_tree_destroy (rsapi, phys_tree, true, true);
        resrc_api_fini (rsapi);
    }
    return rc;
}