Exemple #1
0
void thorium_worker_evict_actor(struct thorium_worker *worker, int actor_name)
{
    struct thorium_actor *actor;
    int name;
    struct core_fast_queue saved_actors;
    int count;
    int value;

    core_set_add(&worker->evicted_actors, &actor_name);
    core_map_delete(&worker->actors, &actor_name);
    core_fast_queue_init(&saved_actors, sizeof(struct thorium_actor *));

    /* evict the actor from the scheduling queue
     */
    while (thorium_scheduler_dequeue(&worker->scheduler, &actor)) {

        name = thorium_actor_name(actor);

        if (name != actor_name) {

            core_fast_queue_enqueue(&saved_actors,
                            &actor);
        }
    }

    while (core_fast_queue_dequeue(&saved_actors, &actor)) {
        thorium_scheduler_enqueue(&worker->scheduler, actor);
    }

    core_fast_queue_destroy(&saved_actors);

    /* Evict the actor from the ring
     */

    count = core_fast_ring_size_from_consumer(&worker->actors_to_schedule);

    while (count-- && core_fast_ring_pop_from_consumer(&worker->actors_to_schedule,
                            &actor)) {

        name = thorium_actor_name(actor);

        if (name != actor_name) {

            /*
             * This can not fail logically.
             */
            value = core_fast_ring_push_from_producer(&worker->actors_to_schedule,
                            &actor);

            CORE_DEBUGGER_ASSERT(value);
        }
    }

    core_map_iterator_destroy(&worker->actor_iterator);
    core_map_iterator_init(&worker->actor_iterator, &worker->actors);
}
Exemple #2
0
void systolic_receive(struct thorium_actor *actor, struct thorium_message *message)
{
    int tag;
    int name;
    void *buffer;
    struct systolic *systolic1;
    int i;

    systolic1 = (struct systolic *)thorium_actor_concrete_actor(actor);
    tag = thorium_message_action(message);
    name = thorium_actor_name(actor);
    buffer = thorium_message_buffer(message);

    if (tag == ACTION_START) {

        core_vector_unpack(&systolic1->initial_data, buffer);

        printf("Hello world ! my name is actor:%d and I have %d acquaintances:",
                        name, (int)core_vector_size(&systolic1->initial_data));

        for (i = 0; i < core_vector_size(&systolic1->initial_data); i++) {
            printf(" actor:%d", core_vector_at_as_int(&systolic1->initial_data, i));
        }
        printf("\n");

        thorium_actor_send_to_self_empty(actor, ACTION_STOP);
    }
}
Exemple #3
0
void thorium_actor_pack_proxy_message(struct thorium_actor *self, struct thorium_message *message,
                int real_source)
{
    int real_tag;
    int count;
    int new_count;
    void *buffer;
    void *new_buffer;
    int offset;
    struct core_memory_pool *ephemeral_memory;

    /*
     * pack data in this order:
     *
     * - data (count bytes)
     * - real_source
     * - real_tag
     */
    ephemeral_memory = thorium_actor_get_ephemeral_memory(self);
    real_tag = thorium_message_action(message);
    buffer = thorium_message_buffer(message);
    count = thorium_message_count(message);

#ifdef DEBUG_BINOMIAL_TREE
    printf("DEBUG_BINOMIAL_TREE pack_proxy_message count %d source %d action %x\n", count,
                    thorium_actor_name(self),
                    real_tag);
    thorium_message_print(message);

#endif

    new_count = count + sizeof(real_source) + sizeof(real_tag);

    /* use slab allocator */
    new_buffer = core_memory_pool_allocate(ephemeral_memory, new_count);

#ifdef THORIUM_ACTOR_DEBUG
    printf("DEBUG12 core_memory_pool_allocate %p (pack proxy message)\n",
                    new_buffer);
#endif

    if (count > 0)
        core_memory_copy(new_buffer, buffer, count);

    offset = count;
    core_memory_copy((char *)new_buffer + offset, &real_source, sizeof(real_source));
    offset += sizeof(real_source);
    core_memory_copy((char *)new_buffer + offset, &real_tag, sizeof(real_tag));
    offset += sizeof(real_tag);

    thorium_message_init(message, ACTION_PROXY_MESSAGE, new_count, new_buffer);
    thorium_message_set_source(message, real_source);

#if 0
    /* free the old buffer
     */
    core_memory_free(buffer);
    buffer = NULL;
#endif
}
Exemple #4
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
}
Exemple #5
0
void thorium_fifo_scheduler_print_with_priority(struct thorium_fifo_scheduler *queue, int priority, const char *name,
                int node, int worker)
{
    struct core_fast_queue *selection;
    struct thorium_actor *actor;
    int size;
    int i;

    selection = thorium_fifo_scheduler_select_queue(queue, priority);
    size = core_fast_queue_size(selection);

    printf("node/%d worker/%d scheduling_queue: Priority Queue %d (%s), actors: %d\n",
                    node, worker,
                    priority, name, size);

    i = 0;

    while (i < size) {
        core_fast_queue_dequeue(selection, &actor);
        core_fast_queue_enqueue(selection, &actor);

        printf("node/%d worker/%d [%i] actor %s/%d (%d messages)\n",
                        node, worker,
                        i,
                        thorium_actor_script_name(actor),
                        thorium_actor_name(actor),
                        thorium_actor_get_mailbox_size(actor));

        ++i;
    }
}
void thorium_cfs_scheduler_print(struct thorium_scheduler *self)
{
    struct thorium_cfs_scheduler *concrete_self;
    struct core_red_black_tree_iterator iterator;
    uint64_t virtual_runtime;
    struct thorium_actor *actor;
    int i;
    struct core_timer timer;

    core_timer_init(&timer);
    concrete_self = self->concrete_self;

    core_red_black_tree_iterator_init(&iterator, &concrete_self->tree);

    printf("[cfs_scheduler] %" PRIu64 " ns, timeline contains %d actors\n",
                    core_timer_get_nanoseconds(&timer),
                    core_red_black_tree_size(&concrete_self->tree));

    i = 0;
    while (core_red_black_tree_iterator_get_next_key_and_value(&iterator, &virtual_runtime,
                            &actor)) {
        printf("[%d] virtual_runtime= %" PRIu64 " actor= %s/%d\n",
                        i, virtual_runtime,
                        thorium_actor_script_name(actor), thorium_actor_name(actor));
        ++i;
    }

    core_red_black_tree_iterator_destroy(&iterator);
    core_timer_destroy(&timer);
}
Exemple #7
0
void spate_start_reply_builder(struct thorium_actor *self, struct thorium_message *message)
{
    void *buffer;
    int spawner;
    struct spate *concrete_self;

    concrete_self = (struct spate *)thorium_actor_concrete_actor(self);
    buffer = thorium_message_buffer(message);

    core_vector_unpack(&concrete_self->graph_stores, buffer);

    thorium_actor_log(self, "%s/%d has %d graph stores",
                    thorium_actor_script_name(self),
                    thorium_actor_name(self),
                    (int)core_vector_size(&concrete_self->graph_stores));

    spawner = thorium_actor_get_spawner(self, &concrete_self->initial_actors);

    concrete_self->unitig_manager = THORIUM_ACTOR_SPAWNING_IN_PROGRESS;

    thorium_actor_add_action_with_condition(self, ACTION_SPAWN_REPLY,
                    spate_spawn_reply_unitig_manager,
                    &concrete_self->unitig_manager, THORIUM_ACTOR_SPAWNING_IN_PROGRESS);

    thorium_actor_send_int(self, spawner, ACTION_SPAWN, SCRIPT_UNITIG_MANAGER);
}
Exemple #8
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);
}
Exemple #9
0
void table_destroy(struct thorium_actor *actor)
{
    struct table *table1;

    table1 = (struct table *)thorium_actor_concrete_actor(actor);

    core_vector_destroy(&table1->spawners);
    printf("actor %d dies\n", thorium_actor_name(actor));
}
Exemple #10
0
int thorium_worker_enqueue_actor_special(struct thorium_worker *worker, struct thorium_actor *actor)
{
    int name;

    name = thorium_actor_name(actor);

    core_set_delete(&worker->evicted_actors, &name);

    return thorium_worker_enqueue_actor(worker, actor);
}
Exemple #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);
}
Exemple #12
0
void core_writer_process_init(struct thorium_actor *self)
{
    struct core_writer_process *concrete_self;

    concrete_self = thorium_actor_concrete_actor(self);

    concrete_self->has_file = 0;

    thorium_actor_log(self, "%s/%d is ready to do input/output operations\n",
                    thorium_actor_script_name(self),
                    thorium_actor_name(self));
}
int thorium_cfs_scheduler_dequeue(struct thorium_scheduler *self, struct thorium_actor **actor)
{
    struct thorium_cfs_scheduler *concrete_self;
    void *key;
    void *value;
    uint64_t virtual_runtime;
    int size;

    key = NULL;
    value = NULL;
    virtual_runtime = 0;

    concrete_self = self->concrete_self;
    size = core_red_black_tree_size(&concrete_self->tree);

    if (size == 0) {
        return 0;
    }

#ifdef SHOW_TIMELINE
    if (size >= 10 && self->node == 0 && self->worker == 1) {
            /*
        printf("[cfs_scheduler] %d actor are in the timeline\n", size);
        */
        thorium_cfs_scheduler_print(self);
    }
#endif

    /*
     * This is O(N)
     */
    key = core_red_black_tree_get_lowest_key(&concrete_self->tree);

    /*
     * This is O(1) because the tree always keep a cache of the last node.
     */
    value = core_red_black_tree_get(&concrete_self->tree, key);

    /*
     * This is also O(1) because the tree keeps a cache of the last node.
     */
    core_red_black_tree_delete(&concrete_self->tree, key);

    core_memory_copy(&virtual_runtime, key, sizeof(virtual_runtime));
    core_memory_copy(actor, value, sizeof(struct thorium_actor *));

#if 0
    printf("CFS dequeue -> virtual_runtime= %" PRIu64 " actor= %d\n",
                    virtual_runtime, thorium_actor_name(*actor));
#endif

    return 1;
}
Exemple #14
0
void spate_set_consumers_reply(struct thorium_actor *self, struct thorium_message *message)
{
    struct spate *concrete_self;

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

    thorium_actor_log(self, "spate %d sends %d spawners to controller %d",
                    thorium_actor_name(self),
                    (int)core_vector_size(&concrete_self->initial_actors),
                    concrete_self->input_controller);

    thorium_actor_send_reply_vector(self, ACTION_START, &concrete_self->initial_actors);
}
Exemple #15
0
void biosal_input_stream_set_end_offset(struct thorium_actor *self, struct thorium_message *message)
{
    struct biosal_input_stream *concrete_self;

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

#ifdef DEBUG_ISSUE_594
    printf("DEBUG %d biosal_input_stream_set_end_offset\n",
                    thorium_actor_name(self));
#endif

    thorium_message_unpack_uint64_t(message, 0, &concrete_self->ending_offset);
    thorium_actor_send_reply_empty(self, ACTION_INPUT_STREAM_SET_END_OFFSET_REPLY);
}
Exemple #16
0
struct biosal_assembly_vertex *biosal_assembly_graph_store_find_vertex(struct thorium_actor *self,
                struct biosal_dna_kmer *kmer)
{
    struct core_memory_pool *ephemeral_memory;
    struct biosal_assembly_graph_store *concrete_self;
    char *sequence;
    struct biosal_dna_kmer storage_kmer;
    char *key;
    struct biosal_assembly_vertex *canonical_vertex;

    ephemeral_memory = thorium_actor_get_ephemeral_memory(self);
    concrete_self = thorium_actor_concrete_actor(self);

    sequence = core_memory_pool_allocate(ephemeral_memory, concrete_self->kmer_length + 1);

    biosal_dna_kmer_get_sequence(kmer, sequence, concrete_self->kmer_length,
                        &concrete_self->transport_codec);

    biosal_dna_kmer_init(&storage_kmer, sequence, &concrete_self->storage_codec,
                        ephemeral_memory);

    key = core_memory_pool_allocate(ephemeral_memory, concrete_self->key_length_in_bytes);

    biosal_dna_kmer_pack_store_key(&storage_kmer, key,
                        concrete_self->kmer_length, &concrete_self->storage_codec,
                        ephemeral_memory);

    canonical_vertex = core_map_get(&concrete_self->table, key);

#ifdef CORE_DEBUGGER_ASSERT
    if (canonical_vertex == NULL) {

        printf("not found Seq = %s name %d kmerlength %d key_length %d hash %" PRIu64 "\n", sequence,
                        thorium_actor_name(self),
                        concrete_self->kmer_length,
                        concrete_self->key_length_in_bytes,
                        biosal_dna_kmer_hash(&storage_kmer, concrete_self->kmer_length,
                                &concrete_self->storage_codec));
    }
#endif

    CORE_DEBUGGER_ASSERT(canonical_vertex != NULL);

    core_memory_pool_free(ephemeral_memory, sequence);
    core_memory_pool_free(ephemeral_memory, key);
    biosal_dna_kmer_destroy(&storage_kmer, ephemeral_memory);

    return canonical_vertex;
}
Exemple #17
0
void process_stop(struct thorium_actor *self, struct thorium_message *message)
{
    struct process *concrete_self;
    int total;

    concrete_self = (struct process *)thorium_actor_concrete_actor(self);
    total = concrete_self->passed + concrete_self->failed;
    printf("%s/%d PASSED %d/%d, FAILED %d/%d\n",
                    thorium_actor_script_name(self),
                    thorium_actor_name(self),
                    concrete_self->passed, total,
                    concrete_self->failed, total);

    thorium_actor_send_to_self_empty(self, ACTION_STOP);
}
Exemple #18
0
void thorium_balancer_update_actor_production(struct thorium_balancer *self, struct thorium_actor *actor)
{
    int messages;
    int name;

    if (actor == NULL) {
        return;
    }

    messages = thorium_actor_get_sum_of_received_messages(actor);
    name = thorium_actor_name(actor);

    if (!core_map_update_value(&self->last_actor_received_messages, &name, &messages)) {
        core_map_add_value(&self->last_actor_received_messages, &name, &messages);
    }
}
Exemple #19
0
void buddy_receive(struct thorium_actor *actor, struct thorium_message *message)
{
    int tag;
    int source;
    int name;

    name = thorium_actor_name(actor);
    source = thorium_message_source(message);
    tag = thorium_message_action(message);

    if (tag == ACTION_BUDDY_BOOT) {

        printf("ACTION_BUDDY_BOOT\n");
        thorium_actor_print(actor);

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

    } else if (tag == ACTION_BUDDY_HELLO) {

        printf("ACTION_BUDDY_HELLO\n");

        /* pin the actor to the worker for no reason !
         */

        /*
        thorium_actor_send_to_self_empty(actor, ACTION_PIN_TO_WORKER);
        */

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

    } else if (tag == ACTION_ASK_TO_STOP) {

        printf("BUDDY_DIE\n");

        printf("buddy_receive Actor %i received a message (%i BUDDY_DIE) from actor %i\n",
                        name, tag, source);

        /*
        thorium_actor_send_to_self_empty(actor, ACTION_UNPIN_FROM_WORKER);
        */

        thorium_message_init(message, ACTION_STOP, 0, NULL);
        thorium_actor_send(actor, name, message);
    }
}
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);
}
Exemple #21
0
void spate_distribute_reply(struct thorium_actor *self, struct thorium_message *message)
{
    struct spate *concrete_self;

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

    thorium_actor_log(self, "spate %d: all sequence stores are ready",
                    thorium_actor_name(self));

    thorium_actor_send_vector(self, concrete_self->assembly_graph_builder,
                    ACTION_SET_PRODUCERS, &concrete_self->sequence_stores);

    /* kill the controller
     */

    thorium_actor_send_reply_empty(self, ACTION_ASK_TO_STOP);
}
void biosal_coverage_distribution_init(struct thorium_actor *self)
{
    struct biosal_coverage_distribution *concrete_actor;

    concrete_actor = (struct biosal_coverage_distribution *)thorium_actor_concrete_actor(self);

    core_map_init(&concrete_actor->distribution, sizeof(int), sizeof(uint64_t));

#ifdef BIOSAL_COVERAGE_DISTRIBUTION_DEBUG
    thorium_actor_log(self, "DISTRIBUTION IS READY\n");
#endif
    concrete_actor->actual = 0;
    concrete_actor->expected = 0;

    thorium_actor_log(self, "%s/%d is ready\n",
                    thorium_actor_script_name(self),
                    thorium_actor_name(self));
}
Exemple #23
0
/* hello-hello_receive */
void hello_receive(struct thorium_actor *self, struct thorium_message *message)
{
    int tag;
    int name;
    void *buffer;
    struct hello *concrete_self;
    struct core_vector data_vector;
    int i;
    int action = thorium_message_action(message);

    concrete_self = thorium_actor_concrete_actor(self);
    name = thorium_actor_name(self);
    buffer = thorium_message_buffer(message);

    thorium_actor_log(self, "received action %d\n",
                    action);

    if (action == ACTION_START) {
        
        thorium_message_print(message);
        printf("\n");

        /*
         * Send a ping message to self.
         */
        thorium_actor_send_reply_empty(self, ACTION_MY_PING);

    }

    if (action == ACTION_MY_PING) {
        thorium_actor_send_reply_empty(self, ACTION_MY_PONG);

    }
    
    if (action == ACTION_MY_PONG) {

        thorium_actor_send_reply_empty(self, ACTION_ASK_TO_STOP);
    }

    if (action == ACTION_ASK_TO_STOP) {

        thorium_actor_send_reply_empty(self, ACTION_STOP);
    }
}
Exemple #24
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);
}
Exemple #25
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);
}
Exemple #26
0
int thorium_balancer_get_actor_production(struct thorium_balancer *self, struct thorium_actor *actor)
{
    int messages;
    int last_messages;
    int name;
    int result;

    if (actor == NULL) {
        return 0;
    }

    messages = thorium_actor_get_sum_of_received_messages(actor);

    last_messages = 0;
    name = thorium_actor_name(actor);
    core_map_get_value(&self->last_actor_received_messages, &name, &last_messages);

    result = messages - last_messages;

    return result;
}
Exemple #27
0
void biosal_input_stream_count_in_parallel_mock(struct thorium_actor *self, struct thorium_message *message)
{
    struct biosal_input_stream *concrete_self;
    void *buffer;
    int count;
    char *file;

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

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

    file = concrete_self->file_name;

    printf("%s/%d receives ACTION_INPUT_COUNT_IN_PARALLEL file %s\n",
                    thorium_actor_script_name(self),
                    thorium_actor_name(self),
                    file);

    thorium_actor_send_to_self_buffer(self, ACTION_INPUT_COUNT, count, buffer);
}
Exemple #28
0
void spate_ask_to_stop(struct thorium_actor *self, struct thorium_message *message)
{
    int source;
    struct spate *concrete_self;

    concrete_self = (struct spate *)thorium_actor_concrete_actor(self);
    source = thorium_message_source(message);

    if (!spate_must_print_help(self)) {
        thorium_actor_log(self, "spate %d stops", thorium_actor_name(self));
    }

#if 0
    thorium_actor_ask_to_stop(self, message);
#endif

    /*
     * Check if the source is an initial actor because each initial actor
     * is its own supervisor.
     */

    if (core_vector_index_of(&concrete_self->initial_actors, &source) >= 0) {
        thorium_actor_send_to_self_empty(self, ACTION_STOP);
    }

    if (concrete_self->is_leader) {

        if (concrete_self->assembly_graph_builder != THORIUM_ACTOR_NOBODY)
            thorium_actor_send_empty(self, concrete_self->assembly_graph_builder,
                        ACTION_ASK_TO_STOP);
        if (concrete_self->assembly_graph_builder != THORIUM_ACTOR_NOBODY)
            thorium_actor_send_empty(self, concrete_self->manager_for_sequence_stores,
                        ACTION_ASK_TO_STOP);

        if (!spate_must_print_help(self)) {
            core_timer_stop(&concrete_self->timer);
            core_timer_print_with_description(&concrete_self->timer, "Total");
        }
    }
}
Exemple #29
0
void framr_hello_reply(actor_t *actor, message_t *message)
{
    message_t new_message;
    int name;
    int source;
    int boss;

    framr_t *self;
    struct core_vector *spawners;

    self = thorium_actor_concrete_actor(actor);

    name = thorium_actor_name(actor);
    source = thorium_message_source(message);
    spawners = &self->spawners;

    pm("Actor %d is satisfied with a reply from the neighbor %d.\n", name, source);

    boss = core_vector_at_as_int(spawners, 0);
    thorium_message_init(&new_message, ACTION_NOTIFY, 0, NULL);
    thorium_actor_send(actor, boss, &new_message);
    thorium_message_destroy(&new_message);
}
Exemple #30
0
void biosal_assembly_graph_store_print_progress(struct thorium_actor *self)
{
    struct biosal_assembly_graph_store *concrete_self;
    uint64_t total;
    uint64_t stride;
    uint64_t current_value;
    int steps;
    float ratio;
    char finished[] = " FINISHED";
    char not_finished[] = "";
    char *state;

    concrete_self = thorium_actor_concrete_actor(self);

    total = core_map_size(&concrete_self->table);
    steps = 20;
    stride = total / steps;

    current_value = concrete_self->consumed_canonical_vertex_count;

    if ((current_value == 0)
                    || (current_value % stride == 0)
                    || (current_value == total)) {

        state = not_finished;

        if (current_value == total) {
            state = finished;
        }

        ratio = (0.0 + current_value) / total;

        printf("%s/%d %.2f of vertices were consumed%s\n",
                        thorium_actor_script_name(self),
                        thorium_actor_name(self), ratio, state);
    }
}