Ejemplo n.º 1
0
static GHashTable *
build_task_groups (UfoBaseScheduler *scheduler, UfoTaskGraph *graph, UfoResources *resources, GList *nodes)
{
    GHashTable *tasks_to_groups;
    GList *it;

    tasks_to_groups = g_hash_table_new (g_direct_hash, g_direct_equal);

    /* Create a group with a single member for each node */
    g_list_for (nodes, it) {
        TaskGroup *group;
        UfoNode *task;
        UfoNode *node;

        task = UFO_NODE (it->data);
        group = g_new0 (TaskGroup, 1);
        group->context = ufo_resources_get_context (resources);
        group->parents = NULL;
        group->tasks = g_list_append (NULL, it->data);
        group->queue = ufo_two_way_queue_new (NULL);
        group->is_leaf = ufo_graph_get_num_successors (UFO_GRAPH (graph), task) == 0;

        if (ufo_task_get_mode (UFO_TASK (task)) & UFO_TASK_MODE_SHARE_DATA) {
            group->mode = TASK_GROUP_SHARED;
        }
        else {
            group->mode = TASK_GROUP_ROUND_ROBIN;
        }

        node = ufo_node_new (group);
        g_hash_table_insert (tasks_to_groups, it->data, node);
    }
Ejemplo n.º 2
0
static void
test_create_lots_of_buffers (Fixture *fixture,
                             gconstpointer unused)
{
    gint num_buffers = 10000;
    UfoConfig *config = ufo_config_new ();
    UfoResources *resources = ufo_resources_new (config, NULL);
    gpointer context = ufo_resources_get_context (resources);

    UfoRequisition requisition = {
        .n_dims = 2,
        .dims[0] = 800,
        .dims[1] = 800
    };

    while (num_buffers-- > 0) {
        UfoBuffer *buffer = ufo_buffer_new (&requisition, NULL, context);
        gpointer device_array = ufo_buffer_get_device_array (buffer, NULL);
        ufo_buffer_discard_location (buffer);
        g_assert (device_array != NULL);
        g_object_unref (buffer);
    }
}

static void
test_copy_lots_of_buffers (Fixture *fixture,
                           gconstpointer *unused)
{
    gint num_buffers = 10000;
    UfoConfig *config = ufo_config_new ();
    UfoResources *resources = ufo_resources_new (config, NULL);
    gpointer context = ufo_resources_get_context (resources);

    UfoRequisition requisition = {
        .n_dims = 2,
        .dims[0] = 800,
        .dims[1] = 800
    };

    // TODO enforce copy between GPUs
    UfoBuffer *src = ufo_buffer_new (&requisition, NULL, context);
    UfoBuffer *dest = ufo_buffer_new (&requisition, NULL, context);

    while (num_buffers-- > 0) {
        g_debug("copy");
        ufo_buffer_copy (src, dest);
    }

}
static void
test_convert_8 (Fixture *fixture,
                gconstpointer unused)
{
    gfloat *host_data;

    host_data = ufo_buffer_get_host_array (fixture->buffer, NULL);
    g_memmove (host_data, fixture->data8, fixture->n_data);

    ufo_buffer_convert (fixture->buffer, UFO_BUFFER_DEPTH_8U);
    host_data = ufo_buffer_get_host_array (fixture->buffer, NULL);

    for (guint i = 0; i < fixture->n_data; i++)
        g_assert (host_data[i] == ((gfloat) fixture->data8[i]));
}