Beispiel #1
0
static void source_init(struct thorium_actor *self)
{
    struct source *concrete_self;
    int argc;
    char **argv;

    concrete_self = thorium_actor_concrete_actor(self);

    concrete_self->message_count = 0;

    argc = thorium_actor_argc(self);
    argv = thorium_actor_argv(self);

    concrete_self->event_count = DEFAULT_EVENT_COUNT;

    if (core_command_has_argument(argc, argv, OPTION_EVENT_COUNT)) {
        concrete_self->event_count = core_command_get_argument_value_int(argc, argv, OPTION_EVENT_COUNT);
    }

    core_vector_init(&concrete_self->targets, sizeof(int));
    core_vector_set_memory_pool(&concrete_self->targets,
                    thorium_actor_get_persistent_memory_pool(self));

    concrete_self->target = -1;
}
Beispiel #2
0
void thorium_actor_send_range_default(struct thorium_actor *actor, struct core_vector *actors,
                int first, int last,
                struct thorium_message *message)
{
#ifdef USE_BINOMIAL_TREE
    struct core_vector destinations;
    struct core_memory_pool *ephemeral_memory;
    int name;

    ephemeral_memory = thorium_actor_get_ephemeral_memory(actor);
    core_vector_init(&destinations, sizeof(int));
    core_vector_set_memory_pool(&destinations, ephemeral_memory);
    core_vector_copy_range(actors, first, last, &destinations);

    /*
     * Set the source now.
     */
    name = thorium_actor_name(actor);
    thorium_message_set_source(message, name);

    thorium_actor_send_range_binomial_tree(actor, &destinations, message);

    core_vector_destroy(&destinations);
#else

    thorium_actor_send_range_loop(actor, actors, first, last, message);
#endif
}
Beispiel #3
0
void biosal_assembly_arc_classifier_init(struct thorium_actor *self)
{
    struct biosal_assembly_arc_classifier *concrete_self;

    concrete_self = (struct biosal_assembly_arc_classifier *)thorium_actor_concrete_actor(self);

    concrete_self->kmer_length = -1;

    thorium_actor_add_action(self, ACTION_ASK_TO_STOP,
                    thorium_actor_ask_to_stop);

    thorium_actor_add_action(self, ACTION_SET_KMER_LENGTH,
                    biosal_assembly_arc_classifier_set_kmer_length);

    /*
     *
     * Configure the codec.
     */

    biosal_dna_codec_init(&concrete_self->codec);

    if (biosal_dna_codec_must_use_two_bit_encoding(&concrete_self->codec,
                            thorium_actor_get_node_count(self))) {
        biosal_dna_codec_enable_two_bit_encoding(&concrete_self->codec);
    }

    core_vector_init(&concrete_self->consumers, sizeof(int));

    thorium_actor_add_action(self, ACTION_ASSEMBLY_PUSH_ARC_BLOCK,
                    biosal_assembly_arc_classifier_push_arc_block);

    concrete_self->received_blocks = 0;

    core_vector_init(&concrete_self->pending_requests, sizeof(int));
    concrete_self->active_requests = 0;

    concrete_self->producer_is_waiting = 0;

    concrete_self->maximum_pending_request_count = thorium_actor_active_message_limit(self);

    concrete_self->consumer_count_above_threshold = 0;

    printf("%s/%d is now active, ACTIVE_MESSAGE_LIMIT %d\n",
                    thorium_actor_script_name(self),
                    thorium_actor_name(self),
                    concrete_self->maximum_pending_request_count);
}
Beispiel #4
0
void process_init(struct thorium_actor *self)
{
    struct process *concrete_self;
    int argc;
    char **argv;

    argc = thorium_actor_argc(self);
    argv = thorium_actor_argv(self);

    concrete_self = thorium_actor_concrete_actor(self);
    core_vector_init(&concrete_self->actors, sizeof(int));

    thorium_actor_add_action(self, ACTION_START, process_start);
    thorium_actor_add_action(self, ACTION_ASK_TO_STOP, process_stop);
    thorium_actor_add_action(self, ACTION_PING, process_ping);
    thorium_actor_add_action(self, ACTION_PING_REPLY, process_ping_reply);
    thorium_actor_add_action(self, ACTION_NOTIFY, process_notify);

    concrete_self->passed = 0;
    concrete_self->failed = 0;
    concrete_self->events = 0;

    concrete_self->minimum_buffer_size = 16;
    concrete_self->maximum_buffer_size = 512*1024;

    if (core_command_has_argument(argc, argv, MIN_BUFFER_SIZE_OPTION)) {
        concrete_self->maximum_buffer_size = core_command_get_argument_value_int(argc, argv, MIN_BUFFER_SIZE_OPTION);
    }

    if (core_command_has_argument(argc, argv, MAX_BUFFER_SIZE_OPTION)) {
        concrete_self->maximum_buffer_size = core_command_get_argument_value_int(argc, argv, MAX_BUFFER_SIZE_OPTION);
    }

    concrete_self->event_count = 100000;

    if (core_command_has_argument(argc, argv, EVENT_COUNT_OPTION)) {
        concrete_self->event_count = core_command_get_argument_value_int(argc, argv, EVENT_COUNT_OPTION);
    }

    concrete_self->concurrent_event_count = 8;

    if (core_command_has_argument(argc, argv, CONCURRENT_EVENT_COUNT_OPTION)) {
        concrete_self->concurrent_event_count = core_command_get_argument_value_int(argc, argv, CONCURRENT_EVENT_COUNT_OPTION);
    }

    concrete_self->active_messages = 0;

    printf("%s/%d using %s %d %s %d %s %d %s %d\n",
                    thorium_actor_script_name(self),
                    thorium_actor_name(self),
                    MIN_BUFFER_SIZE_OPTION,
                    concrete_self->minimum_buffer_size,
                    MAX_BUFFER_SIZE_OPTION,
                    concrete_self->maximum_buffer_size,
                    EVENT_COUNT_OPTION,
                    concrete_self->event_count,
                    CONCURRENT_EVENT_COUNT_OPTION,
                    concrete_self->concurrent_event_count);
}
Beispiel #5
0
void table_init(struct thorium_actor *actor)
{
    struct table *table1;

    table1 = (struct table *)thorium_actor_concrete_actor(actor);
    table1->done = 0;
    core_vector_init(&table1->spawners, sizeof(int));
}
Beispiel #6
0
/* hello-hello_init */
void hello_init(struct thorium_actor *actor)
{
    struct hello *concrete_self;

    concrete_self = (struct hello *)thorium_actor_concrete_actor(actor);
    core_vector_init(&concrete_self->initial_helloes, sizeof(int));

}
Beispiel #7
0
void biosal_input_command_init(struct biosal_input_command *self,
                int store_name, uint64_t store_first, uint64_t store_last)
{
    self->store_name = store_name;
    self->store_first = store_first;
    self->store_last = store_last;

    core_vector_init(&self->entries, sizeof(struct biosal_dna_sequence));
}
Beispiel #8
0
void systolic_init(struct thorium_actor *actor)
{
    struct systolic *systolic1;

    systolic1 = (struct systolic *)thorium_actor_concrete_actor(actor);

    // TODO: Replace this with actual data needed for systolic array
    core_vector_init(&systolic1->initial_data, sizeof(int));
}
Beispiel #9
0
void biosal_unitig_manager_init(struct thorium_actor *self)
{
    struct biosal_unitig_manager *concrete_self;

    concrete_self = (struct biosal_unitig_manager *)thorium_actor_concrete_actor(self);

    core_vector_init(&concrete_self->spawners, sizeof(int));
    core_vector_init(&concrete_self->graph_stores, sizeof(int));

    core_vector_init(&concrete_self->visitors, sizeof(int));
    core_vector_init(&concrete_self->walkers, sizeof(int));

    concrete_self->completed = 0;
    concrete_self->manager = THORIUM_ACTOR_NOBODY;

    core_timer_init(&concrete_self->timer);

    concrete_self->state = STATE_VISITORS;
}
Beispiel #10
0
void biosal_input_controller_receive_store_entry_counts(struct thorium_actor *actor, struct thorium_message *message)
{
    struct biosal_input_controller *concrete_actor;
    struct core_vector store_entries;
    void *buffer;
    int i;
    int store;
    uint64_t entries;
    struct thorium_message new_message;
    int name;

    core_vector_init(&store_entries, sizeof(uint64_t));

    concrete_actor = (struct biosal_input_controller *)thorium_actor_concrete_actor(actor);
    buffer = thorium_message_buffer(message);
    name = thorium_actor_name(actor);
    concrete_actor->ready_consumers = 0;

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
    printf("DEBUG biosal_input_controller_receive_store_entry_counts unpacking entries\n");
#endif

    core_vector_init(&store_entries, 0);
    core_vector_unpack(&store_entries, buffer);

    for (i = 0; i < core_vector_size(&store_entries); i++) {
        store = *(int *)core_vector_at(&concrete_actor->consumers, i);
        entries = *(uint64_t *)core_vector_at(&store_entries, i);

        printf("DEBUG controller/%d tells consumer/%d to reserve %" PRIu64 " buckets\n",
                        name, store, entries);

        thorium_message_init(&new_message, ACTION_RESERVE,
                        sizeof(entries), &entries);
        thorium_actor_send(actor, store, &new_message);
    }

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
    printf("DEBUG biosal_input_controller_receive_store_entry_counts will wait for replies\n");
#endif

    core_vector_destroy(&store_entries);
}
Beispiel #11
0
void thorium_actor_send_range_default(struct thorium_actor *actor, struct core_vector *actors,
                int first, int last,
                struct thorium_message *message)
{
    int use_binomial_tree;
    struct core_vector destinations;
    struct core_memory_pool *ephemeral_memory;
    int name;
    int action;

    action = thorium_message_action(message);
    use_binomial_tree = 0;

#ifdef USE_BINOMIAL_TREE

    /*
     * ACTION_ASK_TO_STOP basically kills actors (if they agree to).
     * It is a bad idea to use a binomial tree to send this death signal
     * since intermediate actors can die before acting as relays.
     */
    if (action != ACTION_ASK_TO_STOP)
        use_binomial_tree = 1;
#endif

    if (!use_binomial_tree) {
        thorium_actor_send_range_loop(actor, actors, first, last, message);
        return;
    }

    tracepoint(thorium_binomial_tree, send_range, message, (int)core_vector_size(actors));

    /*
     * Otherwise, use the binomial tree code path. This algorithm is better since it distributed
     * the sending operations intot a binomial tree where there are a lot of intermediate
     * actors (to be exact, the number of intermediate actors is close to log2(actors.size)).
     */
    ephemeral_memory = thorium_actor_get_ephemeral_memory(actor);
    core_vector_init(&destinations, sizeof(int));
    core_vector_set_memory_pool(&destinations, ephemeral_memory);

    CORE_DEBUGGER_ASSERT(core_vector_empty(&destinations));

    core_vector_copy_range(actors, first, last, &destinations);

    /*
     * Set the source now.
     */
    name = thorium_actor_name(actor);
    thorium_message_set_source(message, name);

    thorium_actor_send_range_binomial_tree(actor, &destinations, message);

    core_vector_destroy(&destinations);
}
Beispiel #12
0
int core_vector_pack_unpack(struct core_vector *self, void *buffer, int operation)
{
    struct core_packer packer;
    int64_t bytes;
    int size;
    struct core_memory_pool *memory;

    core_packer_init(&packer, operation, buffer);

    core_packer_process(&packer, &self->size, sizeof(self->size));

#ifdef CORE_VECTOR_DEBUG
    printf("DEBUG core_vector_pack_unpack operation %d size %d\n",
                    operation, self->size);
#endif

    core_packer_process(&packer, &self->element_size, sizeof(self->element_size));

#ifdef CORE_VECTOR_DEBUG
    printf("DEBUG core_vector_pack_unpack operation %d element_size %d\n",
                    operation, self->element_size);
#endif

    if (operation == CORE_PACKER_OPERATION_UNPACK) {

        size = self->size;
        memory = self->memory;
        core_vector_init(self, self->element_size);

        /*
         * Restore attributes.
         */
        self->size = size;
        self->maximum_size = self->size;
        self->memory = memory;

        if (self->size > 0) {
            self->data = core_memory_pool_allocate(self->memory, self->maximum_size * self->element_size);
            ++self->profile_allocate_calls;
        } else {
            self->data = NULL;
        }
    }

    if (self->size > 0) {

        core_packer_process(&packer, self->data, self->size * self->element_size);
    }

    bytes = core_packer_get_byte_count(&packer);
    core_packer_destroy(&packer);

    return bytes;
}
Beispiel #13
0
void reader_init(struct thorium_actor *actor)
{
    struct reader *reader1;

    reader1 = (struct reader *)thorium_actor_concrete_actor(actor);
    reader1->counted = 0;
    reader1->pulled = 0;

    core_vector_init(&reader1->spawners, sizeof(int));
    thorium_actor_add_script(actor, SCRIPT_INPUT_STREAM,
                    &biosal_input_stream_script);
}
Beispiel #14
0
void frame_init(struct thorium_actor *actor)
{
    struct frame *concrete_actor;

    concrete_actor = (struct frame *)thorium_actor_concrete_actor(actor);
    concrete_actor->value = rand() % 12345;

    thorium_actor_send_to_self_empty(actor, ACTION_PACK_ENABLE);

    concrete_actor->migrated_other = 0;
    concrete_actor->pings = 0;
    core_vector_init(&concrete_actor->acquaintance_vector, sizeof(int));
}
Beispiel #15
0
void biosal_sequence_partitioner_init(struct thorium_actor *actor)
{
    struct biosal_sequence_partitioner *concrete_actor;

    concrete_actor = (struct biosal_sequence_partitioner *)thorium_actor_concrete_actor(actor);

    core_vector_init(&concrete_actor->stream_entries, sizeof(uint64_t));
    core_vector_init(&concrete_actor->stream_positions, sizeof(uint64_t));
    core_vector_init(&concrete_actor->stream_global_positions, sizeof(uint64_t));
    core_vector_init(&concrete_actor->store_entries, sizeof(uint64_t));

    core_queue_init(&concrete_actor->available_commands, sizeof(struct biosal_partition_command));
    core_map_init(&concrete_actor->active_commands, sizeof(int),
                    sizeof(struct biosal_partition_command));

    concrete_actor->store_count = -1;
    concrete_actor->block_size = -1;

    concrete_actor->command_number = 0;

    concrete_actor->last_progress = -1;
}
Beispiel #16
0
void thorium_worker_pool_create_workers(struct thorium_worker_pool *pool)
{
    int i;
    struct thorium_worker *worker;

    if (pool->worker_count <= 0) {
        return;
    }

    core_vector_init(&pool->worker_array, sizeof(struct thorium_worker));
#ifdef THORIUM_WORKER_POOL_USE_COUNT_CACHE
    core_vector_init(&pool->message_count_cache, sizeof(int));
#endif

    core_vector_resize(&pool->worker_array, pool->worker_count);
#ifdef THORIUM_WORKER_POOL_USE_COUNT_CACHE
    core_vector_resize(&pool->message_count_cache, pool->worker_count);
#endif

    pool->worker_cache = (struct thorium_worker *)core_vector_at(&pool->worker_array, 0);
#ifdef THORIUM_WORKER_POOL_USE_COUNT_CACHE
    pool->message_cache = (int *)core_vector_at(&pool->message_count_cache, 0);
#endif

    for (i = 0; i < pool->worker_count; i++) {

        worker = thorium_worker_pool_get_worker(pool, i);
        thorium_worker_init(worker, i, pool->node);

        if (pool->waiting_is_enabled) {
            thorium_worker_enable_waiting(worker);
        }

#ifdef THORIUM_WORKER_POOL_USE_COUNT_CACHE
        core_vector_set_int(&pool->message_count_cache, i, 0);
#endif
    }
}
void test_allocator(struct core_memory_pool *memory)
{
    int i;
    int size;
    void *pointer;
    struct core_vector vector;
    struct core_timer timer;
    uint64_t elapsed;

    i = 1000000;
    size = 45;

    core_vector_init(&vector, sizeof(void *));
    core_timer_init(&timer);

    core_timer_start(&timer);

    while (i--) {
        if (memory != NULL) {
            pointer = core_memory_pool_allocate(memory, size);
        } else {
            pointer = core_memory_allocate(size, -1);
        }

        core_vector_push_back(&vector, &pointer);
    }

    core_timer_stop(&timer);
    elapsed = core_timer_get_elapsed_nanoseconds(&timer);

    if (memory == NULL) {
        printf("Not using memory pool... ");
    } else {
        printf("Using memory pool... ");
    }
    printf("Elapsed : %" PRIu64 " milliseconds\n", elapsed / 1000 / 1000);

    size = core_vector_size(&vector);
    for (i = 0; i < size; ++i) {
        pointer = core_vector_at_as_void_pointer(&vector, i);

        if (memory != NULL) {
            core_memory_pool_free(memory, pointer);
        } else {
            core_memory_free(pointer, -1);
        }
    }
    core_vector_destroy(&vector);
    core_timer_destroy(&timer);
}
Beispiel #18
0
void framr_init(actor_t *actor)
{
    framr_t *self;
    self = thorium_actor_concrete_actor(actor);
    core_vector_init(&self->spawners, sizeof(int));

    self->completed = 0;

    thorium_actor_add_action(actor, ACTION_START, framr_start);
    thorium_actor_add_action(actor, ACTION_FRAMR_HELLO, framr_hello);
    thorium_actor_add_action(actor, ACTION_FRAMR_HELLO_REPLY, framr_hello_reply);
    thorium_actor_add_action(actor, ACTION_NOTIFY, framr_notify);
    thorium_actor_add_action(actor, ACTION_ASK_TO_STOP, framr_ask_to_stop);
}
Beispiel #19
0
void ring_init(struct thorium_actor *actor)
{
    struct ring *concrete_actor;

    concrete_actor = (struct ring *)thorium_actor_concrete_actor(actor);

    concrete_actor->spawned_senders = 0;
    concrete_actor->senders = 100000;

#if 1
    concrete_actor->senders = 10000;
#endif
    concrete_actor->first = -1;
    concrete_actor->last = -1;
    concrete_actor->step = RING_STEP_RECEIVE_SPAWNERS;
    concrete_actor->ready_rings = 0;
    concrete_actor->ready_senders = 0;

    core_vector_init(&concrete_actor->spawners, sizeof(int));

    thorium_actor_add_script(actor, SCRIPT_SENDER, &sender_script);

    core_vector_init(&concrete_actor->spawners, 0);
}
Beispiel #20
0
void biosal_input_stream_count_reply_mock(struct thorium_actor *self, struct thorium_message *message)
{
    struct biosal_input_stream *concrete_self;
    void *buffer;
    int count;
    struct core_vector mega_blocks;
    char *file;
    struct core_memory_pool *ephemeral_memory;
    uint64_t result;
    struct biosal_mega_block *block;

    concrete_self = (struct biosal_input_stream *)thorium_actor_concrete_actor(self);
    buffer = thorium_message_buffer(message);
    count = thorium_message_count(message);
    ephemeral_memory = thorium_actor_get_ephemeral_memory(self);

    core_vector_init(&mega_blocks, 0);
    core_vector_set_memory_pool(&mega_blocks, ephemeral_memory);
    core_vector_unpack(&mega_blocks, buffer);

    block = core_vector_at_last(&mega_blocks);

    result = biosal_mega_block_get_entries(block);

#if 0
    file = core_string_get(&concrete_self->file_for_parallel_counting);
#endif

    file = concrete_self->file_name;

    printf("%s/%d COUNT_IN_PARALLEL result for %s is %" PRIu64 "\n",
                    thorium_actor_script_name(self),
                    thorium_actor_name(self),
                    file,
                    result);

    core_vector_destroy(&mega_blocks);

    thorium_actor_send_buffer(self, concrete_self->controller,
                    ACTION_INPUT_COUNT_IN_PARALLEL_REPLY, count, buffer);
}
Beispiel #21
0
void biosal_coverage_distribution_ask_to_stop(struct thorium_actor *self, struct thorium_message *message)
{
    struct core_map_iterator iterator;
    struct core_vector coverage_values;
    struct biosal_coverage_distribution *concrete_actor;

    uint64_t *frequency;
    int *coverage;

    concrete_actor = (struct biosal_coverage_distribution *)thorium_actor_concrete_actor(self);
    core_map_iterator_init(&iterator, &concrete_actor->distribution);

    core_vector_init(&coverage_values, sizeof(int));

    while (core_map_iterator_has_next(&iterator)) {

#if 0
        thorium_actor_log(self, "DEBUG EMIT iterator\n");
#endif
        core_map_iterator_next(&iterator, (void **)&coverage,
                        (void **)&frequency);

#ifdef CORE_DEBUGGER_ASSERT_ENABLED
        if (coverage == NULL) {
            thorium_actor_log(self, "DEBUG map has %d buckets\n", (int)core_map_size(&concrete_actor->distribution));
        }
#endif
        CORE_DEBUGGER_ASSERT(coverage != NULL);

        core_vector_push_back(&coverage_values, coverage);
    }

    core_vector_sort_int(&coverage_values);

    core_map_iterator_destroy(&iterator);

    core_vector_destroy(&coverage_values);

    thorium_actor_ask_to_stop(self, message);
}
Beispiel #22
0
void biosal_input_stream_open_reply(struct thorium_actor *self, struct thorium_message *message)
{
    struct biosal_input_stream *concrete_self;
    int i;
    int size;
    struct core_vector *vector;

    concrete_self = (struct biosal_input_stream *)thorium_actor_concrete_actor(self);

    ++concrete_self->finished_parallel_stream_count;

#if 0
    printf("DEBUG open_reply\n");
#endif

    if (concrete_self->finished_parallel_stream_count ==
                    core_vector_size(&concrete_self->parallel_streams)) {

        concrete_self->finished_parallel_stream_count = 0;

        size = core_vector_size(&concrete_self->parallel_streams);

        core_vector_resize(&concrete_self->parallel_mega_blocks,
                       size);

        for (i = 0; i < size; i++) {

            vector = core_vector_at(&concrete_self->parallel_mega_blocks, i);

            core_vector_init(vector, sizeof(struct biosal_mega_block));
        }

        thorium_actor_send_range_empty(self, &concrete_self->parallel_streams,
                        ACTION_INPUT_COUNT);
    }
}
Beispiel #23
0
void spate_start_reply_manager(struct thorium_actor *self, struct thorium_message *message)
{
    struct core_vector consumers;
    struct spate *concrete_self;
    void *buffer;

    concrete_self = (struct spate *)thorium_actor_concrete_actor(self);
    core_vector_init(&consumers, sizeof(int));

    buffer = thorium_message_buffer(message);

    core_vector_unpack(&consumers, buffer);

    thorium_actor_log(self, "spate %d sends the names of %d consumers to controller %d",
                    thorium_actor_name(self),
                    (int)core_vector_size(&consumers),
                    concrete_self->input_controller);

    thorium_actor_send_vector(self, concrete_self->input_controller, ACTION_SET_CONSUMERS, &consumers);

    core_vector_push_back_vector(&concrete_self->sequence_stores, &consumers);

    core_vector_destroy(&consumers);
}
Beispiel #24
0
void table_receive(struct thorium_actor *actor, struct thorium_message *message)
{
    int tag;
    int source;
    int name;
    int remote;
    struct thorium_message spawn_message;
    int script;
    int new_actor;
    void *buffer;
    struct table *table1;

    table1 = (struct table *)thorium_actor_concrete_actor(actor);
    source = thorium_message_source(message);
    tag = thorium_message_action(message);
    name = thorium_actor_name(actor);
    buffer = thorium_message_buffer(message);

    if (tag == ACTION_START) {
        printf("Actor %i receives ACTION_START from actor %i\n",
               name,  source);

        core_vector_init(&table1->spawners, 0);
        core_vector_unpack(&table1->spawners, buffer);

        remote = core_vector_index_of(&table1->spawners, &name) + 1;
        remote %= core_vector_size(&table1->spawners);

        script = SCRIPT_TABLE;
        thorium_message_init(&spawn_message, ACTION_SPAWN, sizeof(script), &script);
        thorium_actor_send(actor, *(int *)core_vector_at(&table1->spawners, remote), &spawn_message);

        /*
        printf("sending notification\n");
        thorium_message_init(message, ACTION_TABLE_NOTIFY, 0, NULL);
        thorium_actor_send(actor, 0, message);
        */
    } else if (tag == ACTION_SPAWN_REPLY) {

        new_actor= *(int *)buffer;

        printf("Actor %i receives ACTION_SPAWN_REPLY from actor %i,"
               " new actor is %d\n",
               name,  source, new_actor);

        thorium_message_init(message, ACTION_TABLE_DIE2, 0, NULL);
        thorium_actor_send(actor, new_actor, message);

        thorium_message_init(message, ACTION_TABLE_NOTIFY, 0, NULL);
        thorium_actor_send(actor, core_vector_at_as_int(&table1->spawners, 0), message);

    } else if (tag == ACTION_TABLE_DIE2) {

        printf("Actor %i receives ACTION_TABLE_DIE2 from actor %i\n",
               name,  source);

        if (name < core_vector_size(&table1->spawners)) {
            return;
        }

        thorium_message_init(message, ACTION_STOP, 0, NULL);
        thorium_actor_send(actor, name, message);

    } else if (tag == ACTION_TABLE_DIE) {

        printf("Actor %i receives ACTION_TABLE_DIE from actor %i\n",
               name,  source);

        thorium_message_init(message, ACTION_STOP, 0, NULL);
        thorium_actor_send(actor, name, message);

    } else if (tag == ACTION_TABLE_NOTIFY) {

        printf("Actor %i receives ACTION_TABLE_NOTIFY from actor %i\n",
               name,  source);

        table1->done++;

        if (table1->done == core_vector_size(&table1->spawners)) {
            printf("actor %d kills %d to %d\n",
                   name, 0, (int)core_vector_size(&table1->spawners) - 1);
            thorium_message_init(message, ACTION_TABLE_DIE, 0, NULL);
            thorium_actor_send_range(actor, &table1->spawners, message);
        }
    }
}
Beispiel #25
0
void biosal_input_controller_init(struct thorium_actor *actor)
{
    struct biosal_input_controller *concrete_actor;

    concrete_actor = (struct biosal_input_controller *)thorium_actor_concrete_actor(actor);

    core_map_init(&concrete_actor->mega_blocks, sizeof(int), sizeof(struct core_vector));
    core_map_init(&concrete_actor->assigned_blocks, sizeof(int), sizeof(int));
    core_vector_init(&concrete_actor->mega_block_vector, sizeof(struct biosal_mega_block));

    core_vector_init(&concrete_actor->counting_streams, sizeof(int));
    core_vector_init(&concrete_actor->reading_streams, sizeof(int));
    core_vector_init(&concrete_actor->partition_commands, sizeof(int));
    core_vector_init(&concrete_actor->stream_consumers, sizeof(int));
    core_vector_init(&concrete_actor->consumer_active_requests, sizeof(int));
    core_vector_init(&concrete_actor->files, sizeof(char *));
    core_vector_init(&concrete_actor->spawners, sizeof(int));
    core_vector_init(&concrete_actor->counts, sizeof(int64_t));
    core_vector_init(&concrete_actor->consumers, sizeof(int));
    core_vector_init(&concrete_actor->stores_per_spawner, sizeof(int));

    core_timer_init(&concrete_actor->input_timer);
    core_timer_init(&concrete_actor->counting_timer);
    core_timer_init(&concrete_actor->distribution_timer);

    biosal_dna_codec_init(&concrete_actor->codec);

    if (biosal_dna_codec_must_use_two_bit_encoding(&concrete_actor->codec,
                            thorium_actor_get_node_count(actor))) {
        biosal_dna_codec_enable_two_bit_encoding(&concrete_actor->codec);
    }

    core_queue_init(&concrete_actor->unprepared_spawners, sizeof(int));

    concrete_actor->opened_streams = 0;
    concrete_actor->state = BIOSAL_INPUT_CONTROLLER_STATE_NONE;

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_10355
    printf("DEBUG actor %d register ACTION_INPUT_CONTROLLER_CREATE_STORES\n",
                    thorium_actor_name(actor));
#endif

    thorium_actor_add_action(actor, ACTION_INPUT_CONTROLLER_CREATE_STORES,
                    biosal_input_controller_create_stores);
    thorium_actor_add_action(actor, ACTION_GET_NODE_NAME_REPLY,
                    biosal_input_controller_get_node_name_reply);
    thorium_actor_add_action(actor, ACTION_GET_NODE_WORKER_COUNT_REPLY,
                    biosal_input_controller_get_node_worker_count_reply);

    thorium_actor_add_action(actor, ACTION_INPUT_CONTROLLER_PREPARE_SPAWNERS,
                    biosal_input_controller_prepare_spawners);
    thorium_actor_add_action(actor, ACTION_INPUT_CONTROLLER_SPAWN_READING_STREAMS,
                    biosal_input_controller_spawn_streams);

    thorium_actor_add_action(actor, ACTION_INPUT_STREAM_SET_START_OFFSET_REPLY,
                    biosal_input_controller_set_offset_reply);
    thorium_actor_add_script(actor, SCRIPT_INPUT_STREAM, &biosal_input_stream_script);
    thorium_actor_add_script(actor, SCRIPT_SEQUENCE_STORE, &biosal_sequence_store_script);
    thorium_actor_add_script(actor, SCRIPT_SEQUENCE_PARTITIONER,
                    &biosal_sequence_partitioner_script);

    /* configuration for the input controller
     * other values for block size: 512, 1024, 2048, 4096, 8192 * /
     */
    concrete_actor->block_size = 4096;
    concrete_actor->stores_per_worker_per_spawner = 0;

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
    printf("DEBUG %d init controller\n",
                    thorium_actor_name(actor));
#endif

    concrete_actor->ready_spawners = 0;
    concrete_actor->ready_consumers = 0;
    concrete_actor->partitioner = THORIUM_ACTOR_NOBODY;
    concrete_actor->filled_consumers = 0;

    concrete_actor->counted = 0;
}
Beispiel #26
0
void biosal_input_controller_receive(struct thorium_actor *actor, struct thorium_message *message)
{
    int tag;
    int count;
    char *file;
    void *buffer;
    struct biosal_input_controller *controller;
    struct biosal_input_controller *concrete_actor;
    int destination;
    int script;
    int stream;
    char *local_file;
    int i;
    int name;
    int source;
    int destination_index;
    struct thorium_message new_message;
    int error;
    int stream_index;
    int64_t entries;
    int64_t *bucket;
    int *int_bucket;
    int spawner;
    int command_name;
    int stream_name;
    int consumer;
    int consumer_index;
    int *bucket_for_requests;
    char *new_buffer;
    int new_count;
    int file_index;
    struct core_vector mega_blocks;
    struct core_vector_iterator vector_iterator;
    struct biosal_mega_block *mega_block;
    struct core_vector *vector_bucket;
    struct core_vector block_counts;
    uint64_t block_entries;
    int mega_block_index;
    uint64_t offset;
    struct biosal_mega_block *block;
    int acquaintance_index;

    if (thorium_actor_take_action(actor, message)) {
        return;
    }

    thorium_message_get_all(message, &tag, &count, &buffer, &source);

    name = thorium_actor_name(actor);
    controller = (struct biosal_input_controller *)thorium_actor_concrete_actor(actor);
    concrete_actor = controller;

    if (tag == ACTION_START) {

        core_vector_init(&concrete_actor->spawners, 0);
        core_vector_unpack(&concrete_actor->spawners, buffer);

        core_vector_resize(&concrete_actor->stores_per_spawner,
                        core_vector_size(&concrete_actor->spawners));

        for (i = 0; i < core_vector_size(&concrete_actor->spawners); i++) {
            int_bucket = (int *)core_vector_at(&concrete_actor->stores_per_spawner, i);
            *int_bucket = 0;

            spawner = core_vector_at_as_int(&concrete_actor->spawners, i);

            core_queue_enqueue(&concrete_actor->unprepared_spawners, &spawner);
        }

        concrete_actor->state = BIOSAL_INPUT_CONTROLLER_STATE_PREPARE_SPAWNERS;

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL
        printf("DEBUG preparing first spawner\n");
#endif

        thorium_actor_send_to_self_empty(actor, ACTION_INPUT_CONTROLLER_PREPARE_SPAWNERS);

        /*
        thorium_dispatcher_print(thorium_actor_dispatcher(actor));
        */

    } else if (tag == ACTION_ADD_FILE) {

        file = (char *)buffer;

        local_file = core_memory_allocate(strlen(file) + 1, MEMORY_CONTROLLER);
        strcpy(local_file, file);

        printf("controller %d ACTION_ADD_FILE %s\n",
                        thorium_actor_name(actor),
                        local_file);

        core_vector_push_back(&concrete_actor->files, &local_file);

        bucket = core_vector_at(&concrete_actor->files, core_vector_size(&concrete_actor->files) - 1);
        local_file = *(char **)bucket;

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
        printf("DEBUG11 ACTION_ADD_FILE %s %p bucket %p index %d\n",
                        local_file, local_file, (void *)bucket, core_vector_size(&concrete_actor->files) - 1);
#endif

        thorium_actor_send_reply_empty(actor, ACTION_ADD_FILE_REPLY);

    } else if (tag == ACTION_SPAWN_REPLY) {

        if (concrete_actor->state == BIOSAL_INPUT_CONTROLLER_STATE_SPAWN_STORES) {

            biosal_input_controller_add_store(actor, message);
            return;

        } else if (concrete_actor->state == BIOSAL_INPUT_CONTROLLER_STATE_PREPARE_SPAWNERS) {

            concrete_actor->ready_spawners++;
            thorium_message_unpack_int(message, 0, &name);
            thorium_actor_send_empty(actor, name, ACTION_ASK_TO_STOP);
            thorium_actor_send_to_self_empty(actor, ACTION_INPUT_CONTROLLER_PREPARE_SPAWNERS);

            if (concrete_actor->ready_spawners == (int)core_vector_size(&concrete_actor->spawners)) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
                printf("DEBUG all spawners are prepared\n");
#endif
                thorium_actor_send_to_supervisor_empty(actor, ACTION_START_REPLY);
            }

            return;

        } else if (concrete_actor->state == BIOSAL_INPUT_CONTROLLER_STATE_SPAWN_PARTITIONER) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
            printf("DEBUG received spawn reply, state is spawn_partitioner\n");
#endif

            thorium_message_unpack_int(message, 0, &concrete_actor->partitioner);

            /* configure the partitioner
             */
            destination = concrete_actor->partitioner;
            thorium_actor_send_int(actor, destination,
                            ACTION_SEQUENCE_PARTITIONER_SET_BLOCK_SIZE,
                            concrete_actor->block_size);
            thorium_actor_send_int(actor, destination,
                            ACTION_SEQUENCE_PARTITIONER_SET_ACTOR_COUNT,
                            core_vector_size(&concrete_actor->consumers));

            core_vector_init(&block_counts, sizeof(uint64_t));

            for (i = 0; i < core_vector_size(&concrete_actor->mega_block_vector); i++) {

                block = (struct biosal_mega_block *)core_vector_at(&concrete_actor->mega_block_vector, i);
                block_entries = biosal_mega_block_get_entries(block);

                core_vector_push_back_uint64_t(&block_counts, block_entries);
            }

            new_count = core_vector_pack_size(&block_counts);
            new_buffer = thorium_actor_allocate(actor, new_count);

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
            printf("DEBUG packed counts, %d bytes\n", count);
#endif

            core_vector_pack(&block_counts, new_buffer);
            thorium_message_init(&new_message, ACTION_SEQUENCE_PARTITIONER_SET_ENTRY_VECTOR,
                            new_count, new_buffer);
            thorium_actor_send(actor, destination, &new_message);
            core_vector_destroy(&block_counts);

            return;

        } else if (concrete_actor->state == BIOSAL_INPUT_CONTROLLER_STATE_SPAWN_READING_STREAMS) {

            thorium_message_unpack_int(message, 0, &stream);

            stream_index = stream;

            mega_block_index = core_vector_size(&concrete_actor->reading_streams);

            core_vector_push_back_int(&concrete_actor->reading_streams, stream_index);
            core_vector_push_back_int(&concrete_actor->partition_commands, -1);
            core_vector_push_back_int(&concrete_actor->stream_consumers, -1);

            stream_index = core_vector_size(&concrete_actor->reading_streams) - 1;
            mega_block = (struct biosal_mega_block *)core_vector_at(&concrete_actor->mega_block_vector,
                            mega_block_index);

            offset = biosal_mega_block_get_offset(mega_block);

            core_map_add_value(&concrete_actor->assigned_blocks,
                            &stream_index, &mega_block_index);

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_READING_STREAMS
            printf("DEBUG setting offset to %" PRIu64 " for stream/%d\n",
                            offset, stream);
#endif

            thorium_actor_send_uint64_t(actor, stream, ACTION_INPUT_STREAM_SET_START_OFFSET, offset);

            return;
        }

        stream = *(int *)buffer;

        file_index = core_vector_size(&concrete_actor->counting_streams);
        local_file = *(char **)core_vector_at(&concrete_actor->files, file_index);

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_READING_STREAMS
        printf("DEBUG actor %d receives stream %d from spawner %d for file %s\n",
                        name, stream, source,
                        local_file);
#endif

        core_vector_push_back(&concrete_actor->counting_streams, &stream);

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_READING_STREAMS
        printf("asking stream/%d to open %s\n", stream, local_file);
#endif
        thorium_message_init(&new_message, ACTION_INPUT_OPEN, strlen(local_file) + 1, local_file);

#ifdef DEBUG_ISSUE_594
        thorium_message_print(&new_message);
        printf("SEND Buffer %s\n", local_file);
#endif

        thorium_actor_send(actor, stream, &new_message);
        thorium_message_destroy(&new_message);

        if (core_vector_size(&concrete_actor->counting_streams) != core_vector_size(&concrete_actor->files)) {

            thorium_actor_send_to_self_empty(actor, ACTION_INPUT_SPAWN);

        }

#ifdef DEBUG_ISSUE_594
        printf("EXIT Buffer %s\n", local_file);
#endif

    } else if (tag == ACTION_INPUT_OPEN_REPLY) {

        if (concrete_actor->state == BIOSAL_INPUT_CONTROLLER_STATE_SPAWN_READING_STREAMS) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_READING_STREAMS
            printf("DEBUG receives open.reply for reading stream/%d\n", source);
#endif
            concrete_actor->opened_streams++;

            if (concrete_actor->opened_streams == core_vector_size(&concrete_actor->mega_block_vector)) {
                thorium_actor_send_to_self_empty(actor, ACTION_INPUT_CONTROLLER_CREATE_STORES);
            }

            return;
        }

        concrete_actor->opened_streams++;

        stream = source;
        thorium_message_unpack_int(message, 0, &error);

        if (error == BIOSAL_INPUT_ERROR_NO_ERROR) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
            printf("DEBUG actor %d asks %d ACTION_INPUT_COUNT_IN_PARALLEL\n", name, stream);
#endif

            thorium_actor_send_vector(actor, stream, ACTION_INPUT_COUNT_IN_PARALLEL,
                            &concrete_actor->spawners);
        } else {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
            printf("DEBUG actor %d received error %d from %d\n", name, error, stream);
#endif
            concrete_actor->counted++;
        }

	/* if all streams failed, notice supervisor */
        if (concrete_actor->counted == core_vector_size(&concrete_actor->files)) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
#endif
            printf("DEBUG %d: Error all streams failed.\n",
                            thorium_actor_name(actor));
            thorium_actor_send_to_supervisor_empty(actor, ACTION_INPUT_DISTRIBUTE_REPLY);
        }

/*
        if (concrete_actor->opened_streams == core_vector_size(&concrete_actor->files)) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
            printf("DEBUG controller %d sends ACTION_INPUT_DISTRIBUTE_REPLY to supervisor %d [%d/%d]\n",
                            name, thorium_actor_supervisor(actor),
                            concrete_actor->opened_streams, core_vector_size(&concrete_actor->files));
#endif

        }
*/

    } else if (tag == ACTION_INPUT_COUNT_PROGRESS) {

        stream_index = core_vector_index_of(&concrete_actor->counting_streams, &source);
        local_file = core_vector_at_as_char_pointer(&concrete_actor->files, stream_index);
        thorium_message_unpack_int64_t(message, 0, &entries);

        bucket = (int64_t *)core_vector_at(&concrete_actor->counts, stream_index);

        printf("controller/%d receives progress from stream/%d file %s %" PRIu64 " entries so far\n",
                        name, source, local_file, entries);
        *bucket = entries;

    } else if (tag == ACTION_INPUT_COUNT_IN_PARALLEL_REPLY) {

        stream_index = core_vector_index_of(&concrete_actor->counting_streams, &source);
        local_file = core_vector_at_as_char_pointer(&concrete_actor->files, stream_index);

        core_vector_init(&mega_blocks, 0);
        core_vector_unpack(&mega_blocks, buffer);

        printf("DEBUG receive mega blocks from %d\n", source);
        /*
         * Update the file index for every mega block.
         */
        core_vector_iterator_init(&vector_iterator, &mega_blocks);

        bucket = (int64_t*)core_vector_at(&concrete_actor->counts, stream_index);
        (*bucket) = 0;

        while (core_vector_iterator_has_next(&vector_iterator)) {
            core_vector_iterator_next(&vector_iterator, (void **)&mega_block);

            printf("SETTING setting file to %d for mega block\n", stream_index);
            biosal_mega_block_set_file(mega_block, stream_index);

            entries = biosal_mega_block_get_entries_from_start(mega_block);

            printf("Cataloging %d ENTRIES\n", (int)entries);

            (*bucket) = entries;

            biosal_mega_block_print(mega_block);
        }

        core_vector_iterator_destroy(&vector_iterator);

        vector_bucket = (struct core_vector *)core_map_add(&concrete_actor->mega_blocks, &stream_index);
        core_vector_init_copy(vector_bucket, &mega_blocks);

        core_vector_destroy(&mega_blocks);

        concrete_actor->counted++;

        printf("controller/%d received from stream/%d for file %s %" PRIu64 " entries (final) %d/%d\n",
                        name, source, local_file, entries,
                        concrete_actor->counted, (int)core_vector_size(&concrete_actor->files));

        thorium_actor_send_reply_empty(actor, ACTION_INPUT_CLOSE);

        /* continue work here, tell supervisor about it */
        if (concrete_actor->counted == core_vector_size(&concrete_actor->files)) {
            thorium_actor_send_to_self_empty(actor, ACTION_INPUT_CONTROLLER_SPAWN_READING_STREAMS);
        }


    } else if (tag == ACTION_INPUT_DISTRIBUTE) {

        core_timer_start(&concrete_actor->input_timer);
        core_timer_start(&concrete_actor->counting_timer);

        /* for each file, spawn a stream to count */

        /* no files, return immediately
         */
        if (core_vector_size(&concrete_actor->files) == 0) {

            printf("Error: no file to distribute...\n");
            thorium_actor_send_reply_empty(actor, ACTION_INPUT_DISTRIBUTE_REPLY);
            return;
        }

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
        printf("DEBUG actor %d receives ACTION_INPUT_DISTRIBUTE\n", name);
#endif

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
        printf("DEBUG send ACTION_INPUT_SPAWN to self\n");
#endif

        thorium_actor_send_to_self_empty(actor, ACTION_INPUT_SPAWN);

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
        printf("DEBUG resizing counts to %d\n", core_vector_size(&concrete_actor->files));
#endif

        core_vector_resize(&concrete_actor->counts, core_vector_size(&concrete_actor->files));

        for (i = 0; i < core_vector_size(&concrete_actor->counts); i++) {
            bucket = (int64_t*)core_vector_at(&concrete_actor->counts, i);
            *bucket = 0;
        }

    } else if (tag == ACTION_INPUT_SPAWN && source == name) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
        printf("DEBUG ACTION_INPUT_SPAWN\n");
#endif

        script = SCRIPT_INPUT_STREAM;

        concrete_actor->state = BIOSAL_INPUT_CONTROLLER_STATE_SPAWN_STREAMS;

        /* the next file name to send is the current number of streams */
        i = core_vector_size(&concrete_actor->counting_streams);

        destination_index = i % core_vector_size(&concrete_actor->spawners);
        destination = *(int *)core_vector_at(&concrete_actor->spawners, destination_index);

        thorium_message_init(message, ACTION_SPAWN, sizeof(script), &script);
        thorium_actor_send(actor, destination, message);

        bucket = core_vector_at(&concrete_actor->files, i);
        local_file = *(char **)core_vector_at(&concrete_actor->files, i);

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
        printf("DEBUG890 local_file %p bucket %p index %d\n", local_file, (void *)bucket,
                        i);
#endif

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
        printf("DEBUG actor %d spawns a stream for file %d/%d via spawner %d\n",
                        name, i, core_vector_size(&concrete_actor->files), destination);
#endif

        /* also, spawn 4 stores on each node */

    } else if (tag == ACTION_ASK_TO_STOP && ( source == thorium_actor_supervisor(actor)
                            || source == thorium_actor_name(actor))) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_LEVEL_2
#endif

        /* stop streams
         */
        for (i = 0; i < core_vector_size(&concrete_actor->counting_streams); i++) {
            stream = *(int *)core_vector_at(&concrete_actor->counting_streams, i);

            thorium_actor_send_empty(actor, stream, ACTION_ASK_TO_STOP);
        }
        for (i = 0; i < core_vector_size(&concrete_actor->reading_streams); i++) {
            stream = *(int *)core_vector_at(&concrete_actor->reading_streams, i);

            thorium_actor_send_empty(actor, stream, ACTION_ASK_TO_STOP);
        }



#if 0
        /* stop data stores
         */
        for (i = 0; i < core_vector_size(&concrete_actor->consumers); i++) {
            store = core_vector_at_as_int(&concrete_actor->consumers, i);

            thorium_actor_send_empty(actor, store, ACTION_ASK_TO_STOP);
        }
#endif
        /* stop partitioner
         */

        if (concrete_actor->partitioner != THORIUM_ACTOR_NOBODY) {
            thorium_actor_send_empty(actor,
                                concrete_actor->partitioner,
                        ACTION_ASK_TO_STOP);

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
            printf("DEBUG controller %d sends ACTION_ASK_TO_STOP_REPLY to %d\n",
                        thorium_actor_name(actor),
                        thorium_message_source(message));
#endif

        }

        thorium_actor_send_reply_empty(actor, ACTION_ASK_TO_STOP_REPLY);

        /* stop self
         */
        thorium_actor_send_to_self_empty(actor, ACTION_STOP);

        thorium_actor_ask_to_stop(actor, message);

        printf("DEBUG controller %d dies\n", name);
#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
#endif

    } else if (tag == ACTION_INPUT_CONTROLLER_CREATE_PARTITION && source == name) {

        spawner = *(int *)core_vector_at(&concrete_actor->spawners,
                        core_vector_size(&concrete_actor->spawners) / 2);

        thorium_actor_send_int(actor, spawner, ACTION_SPAWN,
                        SCRIPT_SEQUENCE_PARTITIONER);
        concrete_actor->state = BIOSAL_INPUT_CONTROLLER_STATE_SPAWN_PARTITIONER;

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
        printf("DEBUG input controller %d spawns a partitioner via spawner %d\n",
                        name,  spawner);
#endif

    } else if (tag == ACTION_SEQUENCE_PARTITIONER_COMMAND_IS_READY) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
        printf("DEBUG controller receives ACTION_SEQUENCE_PARTITIONER_COMMAND_IS_READY, asks for command\n");
#endif

        thorium_actor_send_reply_empty(actor, ACTION_SEQUENCE_PARTITIONER_GET_COMMAND);

    } else if (tag == ACTION_SEQUENCE_PARTITIONER_GET_COMMAND_REPLY) {

        biosal_input_controller_receive_command(actor, message);

    } else if (tag == ACTION_SEQUENCE_PARTITIONER_FINISHED) {

        thorium_actor_send_empty(actor,
                                concrete_actor->partitioner,
                        ACTION_ASK_TO_STOP);

        biosal_input_controller_verify_requests(actor, message);

    } else if (tag == ACTION_SEQUENCE_PARTITIONER_PROVIDE_STORE_ENTRY_COUNTS) {

        biosal_input_controller_receive_store_entry_counts(actor, message);

    } else if (tag == ACTION_RESERVE_REPLY) {

        concrete_actor->ready_consumers++;

        printf("DEBUG marker ACTION_RESERVE_REPLY %d/%d\n",
                        concrete_actor->ready_consumers,
                        (int)core_vector_size(&concrete_actor->consumers));

        if (concrete_actor->ready_consumers == core_vector_size(&concrete_actor->consumers)) {

            concrete_actor->ready_consumers = 0;
            printf("DEBUG all consumers are ready\n");
            thorium_actor_send_empty(actor,
                            concrete_actor->partitioner,
                            ACTION_SEQUENCE_PARTITIONER_PROVIDE_STORE_ENTRY_COUNTS_REPLY);
        }

    } else if (tag == ACTION_INPUT_PUSH_SEQUENCES_READY) {

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
        printf("DEBUG biosal_input_controller_receive received ACTION_INPUT_PUSH_SEQUENCES_READY\n");
#endif

        stream_name = source;

        acquaintance_index = stream_name;
        stream_index = core_vector_index_of(&concrete_actor->reading_streams, &acquaintance_index);
        command_name = *(int *)core_vector_at(&concrete_actor->partition_commands,
                        stream_index);

        thorium_actor_send_int(actor,
                                concrete_actor->partitioner,
                        ACTION_SEQUENCE_PARTITIONER_GET_COMMAND_REPLY_REPLY,
                        command_name);

    } else if (tag == ACTION_INPUT_PUSH_SEQUENCES_REPLY) {

        stream_name = source;

        thorium_message_unpack_int(message, 0, &consumer);

        consumer_index = core_vector_index_of(&concrete_actor->consumers,
                        &consumer);

        bucket_for_requests = (int *)core_vector_at(&concrete_actor->consumer_active_requests, consumer_index);

        (*bucket_for_requests)--;

        biosal_input_controller_verify_requests(actor, message);

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_CONSUMERS
        printf("DEBUG consumer # %d has %d active requests\n",
                        consumer_index, *bucket_for_requests);
#endif


    } else if (tag == ACTION_SET_CONSUMERS) {

        core_vector_init(&concrete_actor->consumers, 0);
        core_vector_unpack(&concrete_actor->consumers, buffer);

        printf("controller %d receives %d consumers\n",
                        thorium_actor_name(actor),
                        (int)core_vector_size(&concrete_actor->consumers));

        for (i = 0; i < core_vector_size(&concrete_actor->consumers); i++) {
            core_vector_push_back_int(&concrete_actor->consumer_active_requests, 0);
        }

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
        core_vector_print_int(&concrete_actor->consumers);
        printf("\n");
#endif
        thorium_actor_send_reply_empty(actor, ACTION_SET_CONSUMERS_REPLY);

    } else if (tag == ACTION_SET_BLOCK_SIZE) {

        thorium_message_unpack_int(message, 0, &concrete_actor->block_size);
        thorium_actor_send_reply_empty(actor, ACTION_SET_BLOCK_SIZE_REPLY);

    } else if (tag == ACTION_SEQUENCE_STORE_READY) {

        concrete_actor->filled_consumers++;

#ifdef BIOSAL_INPUT_CONTROLLER_DEBUG
        printf("DEBUG ACTION_SEQUENCE_STORE_READY %d/%d\n", concrete_actor->filled_consumers,
                        (int)core_vector_size(&concrete_actor->consumers));
#endif

        if (concrete_actor->filled_consumers == core_vector_size(&concrete_actor->consumers)) {
            concrete_actor->filled_consumers = 0;

            printf("DEBUG: all consumers are filled,  sending ACTION_INPUT_DISTRIBUTE_REPLY\n");

            core_timer_stop(&concrete_actor->input_timer);
            core_timer_stop(&concrete_actor->distribution_timer);

            core_timer_print_with_description(&concrete_actor->distribution_timer,
                            "Load input / Distribute input data");

            core_timer_print_with_description(&concrete_actor->input_timer,
                            "Load input");

            thorium_actor_send_to_supervisor_empty(actor, ACTION_INPUT_DISTRIBUTE_REPLY);
        }
    }
}
Beispiel #27
0
void reader_receive(struct thorium_actor *actor, struct thorium_message *message)
{
    int tag;
    int argc;
    char **argv;
    /*int i;*/
    int name;
    struct reader *reader1;
    int source;
    uint64_t count;
    void *buffer;
    int sequences;
    int script;
    int sequence_index;
    char *received_sequence;
    int error;

    reader1 = (struct reader *)thorium_actor_concrete_actor(actor);
    tag = thorium_message_action(message);
    source = thorium_message_source(message);
    buffer = thorium_message_buffer(message);
    name = thorium_actor_name(actor);

    if (tag == ACTION_START) {

        core_vector_init(&reader1->spawners, 0);
        core_vector_unpack(&reader1->spawners, buffer);

        argc = thorium_actor_argc(actor);
        argv = thorium_actor_argv(actor);
        name = thorium_actor_name(actor);
        reader1->last_report = 0;

        /*
        printf("actor %i received %i arguments\n", name, argc);

        for (i = 0; i < argc ;i++) {
            printf("   argument %i : %s\n", i, argv[i]);
        }
        */

        if (core_vector_index_of(&reader1->spawners, &name) != 0) {
            thorium_message_init(message, ACTION_STOP, 0, NULL);
            thorium_actor_send(actor, name, message);

            return;
        }

        if (argc == 1) {
            thorium_message_init(message, ACTION_STOP, 0, NULL);
            thorium_actor_send(actor, name, message);

            return;
        }

        reader1->sequence_reader = thorium_actor_spawn(actor, SCRIPT_INPUT_STREAM);

        reader1->file = argv[argc - 1];

        thorium_message_init(message, ACTION_INPUT_OPEN, strlen(reader1->file) + 1,
                        reader1->file);

        printf("actor %i: asking actor %i to count entries in %s\n",
                        name, reader1->sequence_reader, reader1->file);

        thorium_actor_send(actor, reader1->sequence_reader, message);

    } else if (tag == ACTION_INPUT_COUNT_PROGRESS) {

        sequences = *(int64_t *)buffer;

        if (sequences < reader1->last_report + 10000000) {

            return;
        }

        printf("Actor %i received a progress report from actor %i: %i\n",
                        name, source, sequences);
        reader1->last_report = sequences;

    } else if (tag == ACTION_INPUT_OPEN_REPLY && !reader1->counted) {

        thorium_message_unpack_int(message, 0, &error);

        if (error == BIOSAL_INPUT_ERROR_NO_ERROR) {
            printf("Successfully opened file.\n");
            thorium_actor_send_reply_empty(actor, ACTION_INPUT_COUNT);

        } else if (error == BIOSAL_INPUT_ERROR_FILE_NOT_FOUND) {

            printf("Error, file not found! \n");
            thorium_actor_send_to_self_empty(actor, ACTION_STOP);

        } else if (error == BIOSAL_INPUT_ERROR_FORMAT_NOT_SUPPORTED) {

            printf("Error, format not supported! \n");
            thorium_actor_send_to_self_empty(actor, ACTION_STOP);

        }
    } else if (tag == ACTION_INPUT_COUNT_REPLY) {

        count = *(int64_t*)thorium_message_buffer(message);
        printf("actor %i: file has %" PRIu64 " items\n", name, count);

        thorium_message_init(message, ACTION_INPUT_CLOSE, 0, NULL);
        thorium_actor_send(actor, source, message);

        reader1->counted = 1;

    } else if (tag == ACTION_INPUT_CLOSE_REPLY && !reader1->pulled) {

        /* not necessary, it is already dead. */
        thorium_actor_send_reply_empty(actor, ACTION_ASK_TO_STOP);

        printf("actor %d received ACTION_INPUT_CLOSE_REPLY from actor %d, asking it to stop"
                        " with ACTION_ASK_TO_STOP\n", name, source);
            /*
        thorium_message_init(message, ACTION_STOP, 0, NULL);
        thorium_actor_send(actor, name, message);

        return;
        */

        script = SCRIPT_INPUT_STREAM;

        thorium_message_init(message, ACTION_SPAWN, sizeof(script), &script);
        thorium_actor_send(actor, name, message);

    } else if (tag == ACTION_INPUT_CLOSE_REPLY && reader1->pulled) {

        thorium_actor_send_reply_empty(actor, ACTION_ASK_TO_STOP);

        thorium_actor_send_to_self_empty(actor, ACTION_STOP);

    } else if (tag == ACTION_ASK_TO_STOP_REPLY && reader1->pulled) {

        /* this tag will never arrive here */
        thorium_message_init(message, ACTION_STOP, 0, NULL);
        thorium_actor_send(actor, name, message);

    } else if (tag == ACTION_SPAWN_REPLY && source == name) {

        reader1->sequence_reader = *(int *)buffer;

        printf("actor %d tells actor %d to open %s to pull sequences from the file\n",
                        name, reader1->sequence_reader, reader1->file);

        thorium_message_init(message, ACTION_INPUT_OPEN,
                        strlen(reader1->file) + 1, reader1->file);
        thorium_actor_send(actor, reader1->sequence_reader, message);

    } else if (tag == ACTION_INPUT_OPEN_REPLY && reader1->counted) {

        thorium_message_init(message, ACTION_INPUT_GET_SEQUENCE, 0, NULL);
        thorium_actor_send(actor, source, message);

    } else if (tag == ACTION_INPUT_GET_SEQUENCE_REPLY) {

        sequence_index = *(int *)buffer;
        received_sequence = (char*)buffer + sizeof(sequence_index);

        /*
        printf("DEBUG %d %s\n", sequence_index, received_sequence);
*/
        if (sequence_index == 123456) {
            printf("actor %d says that sequence %d is %s.\n",
                            name, sequence_index, received_sequence);
        } else if (sequence_index % 100000 == 0) {
            printf("actor %d is pulling sequences from fellow local actor %d,"
                            " %d sequences pulled so far !\n",
                            name, reader1->sequence_reader, sequence_index);
        }

        if (sequence_index < 1000000) {
            thorium_message_init(message, ACTION_INPUT_GET_SEQUENCE, 0, NULL);
            thorium_actor_send(actor, source, message);
        } else {
            thorium_message_init(message, ACTION_INPUT_CLOSE, 0, NULL);
            thorium_actor_send(actor, source, message);
            reader1->pulled = 1;
        }

    } else if (tag == ACTION_INPUT_GET_SEQUENCE_END) {
        printf("actor %d: reached the end...\n", name);

        thorium_message_init(message, ACTION_INPUT_CLOSE, 0, NULL);
        thorium_actor_send(actor, source, message);

        reader1->pulled = 1;
    }
}
Beispiel #28
0
void frame_receive(struct thorium_actor *actor, struct thorium_message *message)
{
    int tag;
    int name;
    void *buffer;
    struct frame *concrete_actor;
    int other;
    struct core_vector initial_actors;
    struct core_vector *acquaintance_vector;
    int source;

    source = thorium_message_source(message);
    concrete_actor = (struct frame *)thorium_actor_concrete_actor(actor);
    tag = thorium_message_action(message);
    name = thorium_actor_name(actor);
    buffer = thorium_message_buffer(message);
    acquaintance_vector = &concrete_actor->acquaintance_vector;


    if (tag == ACTION_START) {

        core_vector_init(&initial_actors, sizeof(int));
        core_vector_unpack(&initial_actors, buffer);
        core_vector_push_back_vector(acquaintance_vector, &initial_actors);
        core_vector_destroy(&initial_actors);

        other = thorium_actor_spawn(actor, thorium_actor_script(actor));
        core_vector_push_back_int(acquaintance_vector, other);

        thorium_actor_send_empty(actor, other, ACTION_PING);

        printf("actor %d sends ACTION_PING to new actor %d\n",
                        name, other);

    } else if (tag == ACTION_PING) {

        /* new acquaintance
         */
        core_vector_push_back(acquaintance_vector, &source);

        printf("actor %d (value %d) receives ACTION_PING from actor %d\n",
                        name, concrete_actor->value, source);
        printf("Acquaintances of actor %d: ", name);
        core_vector_print_int(acquaintance_vector);
        printf("\n");

        thorium_actor_send_reply_empty(actor, ACTION_PING_REPLY);

    } else if (tag == ACTION_PING_REPLY) {

        concrete_actor->pings++;

        printf("actor %d receives ACTION_PING_REPLY from actor %d\n",
                        name, source);

        /* kill the system
         */
        if (concrete_actor->migrated_other && concrete_actor->pings == 2) {

            thorium_actor_send_reply_empty(actor, ACTION_ASK_TO_STOP);
            thorium_actor_send_to_self_empty(actor, ACTION_ASK_TO_STOP);

            return;
        }

        /* migrate other actor
         */

        printf("actor %d asks actor %d to migrate using actor %d as spawner\n",
                        name, source, name);

        printf("Acquaintances of actor %d: ", name);
        core_vector_print_int(acquaintance_vector);
        printf("\n");

        thorium_actor_send_reply_int(actor, ACTION_MIGRATE, name);

        /* send a message to other while it is migrating.
         * this is supposed to work !
         */
        printf("actor %d sends ACTION_PING to %d while it is migrating\n",
                        name, source);
        thorium_actor_send_reply_empty(actor, ACTION_PING);

        concrete_actor->migrated_other = 1;

    } else if (tag == ACTION_MIGRATE_REPLY) {

        thorium_message_unpack_int(message, 0, &other);
        printf("actor %d received migrated actor %d\n", name, other);
        printf("Acquaintances of actor %d: ", name);
        core_vector_print_int(acquaintance_vector);
        printf("\n");

        /* it is possible that the ACTION_PING went through
         * before the migration
         */
        if (concrete_actor->pings == 2) {
            thorium_actor_send_reply_empty(actor, ACTION_ASK_TO_STOP);
            thorium_actor_send_to_self_empty(actor, ACTION_ASK_TO_STOP);
        }

    } else if (tag == ACTION_PACK) {

        thorium_actor_send_reply_int(actor, ACTION_PACK_REPLY, concrete_actor->value);

    } else if (tag == ACTION_UNPACK) {

        thorium_message_unpack_int(message, 0, &concrete_actor->value);
        thorium_actor_send_reply_empty(actor, ACTION_UNPACK_REPLY);

    } else if (tag == ACTION_ASK_TO_STOP) {

        printf("actor %d received ACTION_ASK_TO_STOP, value: %d ",
                        name, concrete_actor->value);
        printf("acquaintance vector: ");
        core_vector_print_int(acquaintance_vector);
        printf("\n");

        thorium_actor_send_to_self_empty(actor, ACTION_STOP);
    }
}
Beispiel #29
0
void biosal_assembly_arc_classifier_push_arc_block(struct thorium_actor *self, struct thorium_message *message)
{
    struct biosal_assembly_arc_classifier *concrete_self;
    int source;
    struct biosal_assembly_arc_block input_block;
    struct biosal_assembly_arc_block *output_block;
    struct core_vector output_blocks;
    struct core_memory_pool *ephemeral_memory;
    int consumer_count;
    struct core_vector *input_arcs;
    struct core_vector *output_arcs;
    int size;
    int i;
    struct biosal_assembly_arc *arc;
    void *buffer;
    int count;
    struct biosal_dna_kmer *kmer;
    int consumer_index;
    int arc_count;
    int consumer;
    struct thorium_message new_message;
    int new_count;
    void *new_buffer;
    int *bucket;
    int maximum_pending_requests;
    int maximum_buffer_length;
    int reservation;

    count = thorium_message_count(message);
    buffer = thorium_message_buffer(message);

    if (count == 0) {
        printf("Error, count is 0 (classifier_push_arc_block)\n");
        return;
    }

    concrete_self = (struct biosal_assembly_arc_classifier *)thorium_actor_concrete_actor(self);
    source = thorium_message_source(message);
    consumer_count = core_vector_size(&concrete_self->consumers);
    ephemeral_memory = thorium_actor_get_ephemeral_memory(self);

    CORE_DEBUGGER_LEAK_DETECTION_BEGIN(ephemeral_memory, classify_arcs);

    core_vector_init(&output_blocks, sizeof(struct biosal_assembly_arc_block));
    core_vector_set_memory_pool(&output_blocks, ephemeral_memory);

    biosal_assembly_arc_block_init(&input_block, ephemeral_memory, concrete_self->kmer_length,
                    &concrete_self->codec);

#ifdef BIOSAL_ASSEMBLY_ARC_CLASSIFIER_DEBUG
    printf("UNPACKING\n");
#endif

    biosal_assembly_arc_block_unpack(&input_block, buffer, concrete_self->kmer_length,
                    &concrete_self->codec, ephemeral_memory);

#ifdef BIOSAL_ASSEMBLY_ARC_CLASSIFIER_DEBUG
    printf("OK\n");
#endif

    input_arcs = biosal_assembly_arc_block_get_arcs(&input_block);

    /*
     * Configure the ephemeral memory reservation.
     */
    arc_count = core_vector_size(input_arcs);
    reservation = (arc_count / consumer_count) * 2;

    core_vector_resize(&output_blocks, consumer_count);

    CORE_DEBUGGER_ASSERT(!core_memory_pool_has_double_free(ephemeral_memory));

    /*
     * Initialize output blocks.
     * There is one for each destination.
     */
    for (i = 0; i < consumer_count; i++) {

        output_block = core_vector_at(&output_blocks, i);

        biosal_assembly_arc_block_init(output_block, ephemeral_memory, concrete_self->kmer_length,
                        &concrete_self->codec);

        biosal_assembly_arc_block_reserve(output_block, reservation);
    }

    size = core_vector_size(input_arcs);

    /*
     * Classify every arc in the input block
     * and put them in output blocks.
     */

#ifdef BIOSAL_ASSEMBLY_ARC_CLASSIFIER_DEBUG
    printf("ClassifyArcs arc_count= %d\n", size);

#endif

    CORE_DEBUGGER_ASSERT(!core_memory_pool_has_double_free(ephemeral_memory));

    for (i = 0; i < size; i++) {

        arc = core_vector_at(input_arcs, i);

        kmer = biosal_assembly_arc_source(arc);

        consumer_index = biosal_dna_kmer_store_index(kmer, consumer_count,
                        concrete_self->kmer_length, &concrete_self->codec,
                        ephemeral_memory);

        output_block = core_vector_at(&output_blocks, consumer_index);

        /*
         * Make a copy of the arc and copy it.
         * It will be freed
         */

        biosal_assembly_arc_block_add_arc_copy(output_block, arc,
                        concrete_self->kmer_length, &concrete_self->codec,
                        ephemeral_memory);
    }

    /*
     * Input arcs are not needed anymore.
     */
    biosal_assembly_arc_block_destroy(&input_block, ephemeral_memory);

    CORE_DEBUGGER_ASSERT(!core_memory_pool_has_double_free(ephemeral_memory));

    /*
     * Finally, send these output blocks to consumers.
     */

    maximum_pending_requests = 0;
    maximum_buffer_length = 0;

    /*
     * Figure out the maximum buffer length tor
     * messages.
     */
    for (i = 0; i < consumer_count; i++) {

        output_block = core_vector_at(&output_blocks, i);
        new_count = biosal_assembly_arc_block_pack_size(output_block, concrete_self->kmer_length,
                    &concrete_self->codec);

        if (new_count > maximum_buffer_length) {
            maximum_buffer_length = new_count;
        }
    }

#if 0
    printf("POOL_BALANCE %d\n",
                    core_memory_pool_profile_balance_count(ephemeral_memory));
#endif

    for (i = 0; i < consumer_count; i++) {

        output_block = core_vector_at(&output_blocks, i);
        output_arcs = biosal_assembly_arc_block_get_arcs(output_block);
        arc_count = core_vector_size(output_arcs);

        /*
         * Don't send an empty message.
         */
        if (arc_count > 0) {

            /*
             * Allocation is not required because new_count <= maximum_buffer_length
             */
            new_count = biosal_assembly_arc_block_pack_size(output_block, concrete_self->kmer_length,
                    &concrete_self->codec);

            new_buffer = thorium_actor_allocate(self, maximum_buffer_length);

            CORE_DEBUGGER_ASSERT(new_count <= maximum_buffer_length);

            biosal_assembly_arc_block_pack(output_block, new_buffer, concrete_self->kmer_length,
                    &concrete_self->codec);

            thorium_message_init(&new_message, ACTION_ASSEMBLY_PUSH_ARC_BLOCK,
                    new_count, new_buffer);

            consumer = core_vector_at_as_int(&concrete_self->consumers, i);

            /*
             * Send the message.
             */
            thorium_actor_send(self, consumer, &new_message);
            thorium_message_destroy(&new_message);

            /* update event counters for control.
             */
            bucket = core_vector_at(&concrete_self->pending_requests, i);
            ++(*bucket);
            ++concrete_self->active_requests;

            if (*bucket > maximum_pending_requests) {
                maximum_pending_requests = *bucket;
            }

            if (*bucket > concrete_self->maximum_pending_request_count) {
                ++concrete_self->consumer_count_above_threshold;
            }
        }

        CORE_DEBUGGER_ASSERT(!core_memory_pool_has_double_free(ephemeral_memory));

#if 0
        printf("i = %d\n", i);
#endif

        /*
         * Destroy output block.
         */
        biosal_assembly_arc_block_destroy(output_block,
                    ephemeral_memory);

        CORE_DEBUGGER_LEAK_CHECK_DOUBLE_FREE(ephemeral_memory);
        CORE_DEBUGGER_ASSERT(!core_memory_pool_has_double_free(ephemeral_memory));
    }

    core_vector_destroy(&output_blocks);

    CORE_DEBUGGER_ASSERT(!core_memory_pool_has_double_free(ephemeral_memory));

    CORE_DEBUGGER_LEAK_CHECK_DOUBLE_FREE(ephemeral_memory);

    /*
     * Check if a response must be sent now.
     */

    ++concrete_self->received_blocks;
    concrete_self->source = source;

    /*
     * Only send a direct reply if there is enough memory.
     *
     * As long as maximum_pending_requests is lower than maximum_pending_request_count,
     * there is still space for at least one additional request.
     */
    if (maximum_pending_requests < concrete_self->maximum_pending_request_count
            && core_memory_has_enough_bytes()) {

        thorium_actor_send_empty(self, concrete_self->source,
                    ACTION_ASSEMBLY_PUSH_ARC_BLOCK_REPLY);
    } else {

        concrete_self->producer_is_waiting = 1;
    }

    CORE_DEBUGGER_LEAK_DETECTION_END(ephemeral_memory, classify_arcs);
}
Beispiel #30
0
void spate_init(struct thorium_actor *self)
{
    struct spate *concrete_self;

    concrete_self = (struct spate *)thorium_actor_concrete_actor(self);
    core_vector_init(&concrete_self->initial_actors, sizeof(int));
    core_vector_init(&concrete_self->sequence_stores, sizeof(int));
    core_vector_init(&concrete_self->graph_stores, sizeof(int));

    concrete_self->is_leader = 0;

    concrete_self->input_controller = THORIUM_ACTOR_NOBODY;
    concrete_self->manager_for_sequence_stores = THORIUM_ACTOR_NOBODY;
    concrete_self->assembly_graph = THORIUM_ACTOR_NOBODY;
    concrete_self->assembly_graph_builder = THORIUM_ACTOR_NOBODY;

    core_timer_init(&concrete_self->timer);

    thorium_actor_add_action(self,
                    ACTION_START, spate_start);
    thorium_actor_add_action(self,
                    ACTION_ASK_TO_STOP, spate_ask_to_stop);
    thorium_actor_add_action(self,
                    ACTION_SPAWN_REPLY, spate_spawn_reply);
    thorium_actor_add_action(self,
                    ACTION_MANAGER_SET_SCRIPT_REPLY, spate_set_script_reply);
    thorium_actor_add_action(self,
                    ACTION_SET_CONSUMERS_REPLY, spate_set_consumers_reply);
    thorium_actor_add_action(self,
                    ACTION_SET_BLOCK_SIZE_REPLY, spate_set_block_size_reply);
    thorium_actor_add_action(self,
                    ACTION_INPUT_DISTRIBUTE_REPLY, spate_distribute_reply);
    thorium_actor_add_action(self,
                    ACTION_SPATE_ADD_FILES, spate_add_files);
    thorium_actor_add_action(self,
                    ACTION_SPATE_ADD_FILES_REPLY, spate_add_files_reply);
    thorium_actor_add_action(self,
                    ACTION_ADD_FILE_REPLY, spate_add_file_reply);

    thorium_actor_add_action(self,
                    ACTION_START_REPLY, spate_start_reply);

    /*
     * Register required actor scripts now
     */

    thorium_actor_add_script(self, SCRIPT_INPUT_CONTROLLER,
                    &biosal_input_controller_script);
    thorium_actor_add_script(self, SCRIPT_DNA_KMER_COUNTER_KERNEL,
                    &biosal_dna_kmer_counter_kernel_script);
    thorium_actor_add_script(self, SCRIPT_MANAGER,
                    &core_manager_script);
    thorium_actor_add_script(self, SCRIPT_WRITER_PROCESS,
                    &core_writer_process_script);
    thorium_actor_add_script(self, SCRIPT_AGGREGATOR,
                    &biosal_aggregator_script);
    thorium_actor_add_script(self, SCRIPT_KMER_STORE,
                    &biosal_kmer_store_script);
    thorium_actor_add_script(self, SCRIPT_SEQUENCE_STORE,
                    &biosal_sequence_store_script);
    thorium_actor_add_script(self, SCRIPT_COVERAGE_DISTRIBUTION,
                    &biosal_coverage_distribution_script);
    thorium_actor_add_script(self, SCRIPT_ASSEMBLY_GRAPH_BUILDER,
                    &biosal_assembly_graph_builder_script);

    thorium_actor_add_script(self, SCRIPT_ASSEMBLY_GRAPH_STORE,
                    &biosal_assembly_graph_store_script);
    thorium_actor_add_script(self, SCRIPT_ASSEMBLY_SLIDING_WINDOW,
                    &biosal_assembly_sliding_window_script);
    thorium_actor_add_script(self, SCRIPT_ASSEMBLY_BLOCK_CLASSIFIER,
                    &biosal_assembly_block_classifier_script);
    thorium_actor_add_script(self, SCRIPT_COVERAGE_DISTRIBUTION,
                    &biosal_coverage_distribution_script);

    thorium_actor_add_script(self, SCRIPT_ASSEMBLY_ARC_KERNEL,
                    &biosal_assembly_arc_kernel_script);
    thorium_actor_add_script(self, SCRIPT_ASSEMBLY_ARC_CLASSIFIER,
                    &biosal_assembly_arc_classifier_script);
    thorium_actor_add_script(self, SCRIPT_UNITIG_WALKER,
                    &biosal_unitig_walker_script);
    thorium_actor_add_script(self, SCRIPT_UNITIG_VISITOR,
                    &biosal_unitig_visitor_script);
    thorium_actor_add_script(self, SCRIPT_UNITIG_MANAGER,
                    &biosal_unitig_manager_script);

    /*
     * This is the I/O controller block size.
     * This is a number of sequences.
     */
    concrete_self->block_size = 16 * 4096;

    concrete_self->file_index = 0;
}