int spate_add_file(struct thorium_actor *self) { char *file; int argc; char **argv; struct thorium_message message; struct spate *concrete_self; concrete_self = (struct spate *)thorium_actor_concrete_actor(self); argc = thorium_actor_argc(self); argv = thorium_actor_argv(self); if (concrete_self->file_index < argc) { file = argv[concrete_self->file_index]; thorium_message_init(&message, ACTION_ADD_FILE, strlen(file) + 1, file); thorium_actor_send(self, concrete_self->input_controller, &message); thorium_message_destroy(&message); ++concrete_self->file_index; return 1; } return 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 }
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 thorium_actor_send_double(struct thorium_actor *actor, int destination, int tag, double value) { struct thorium_message message; thorium_message_init(&message, tag, sizeof(value), &value); thorium_actor_send(actor, destination, &message); thorium_message_destroy(&message); }
void thorium_actor_send_range_empty(struct thorium_actor *actor, struct core_vector *actors, int tag) { struct thorium_message message; thorium_message_init(&message, tag, 0, NULL); thorium_actor_send_range(actor, actors, &message); thorium_message_destroy(&message); }
void thorium_actor_send_range_int(struct thorium_actor *actor, struct core_vector *actors, int tag, int value) { struct thorium_message message; thorium_message_init(&message, tag, sizeof(value), &value); thorium_actor_send_range(actor, actors, &message); thorium_message_destroy(&message); }
void thorium_actor_send_range_buffer(struct thorium_actor *actor, struct core_vector *destinations, int tag, int count, void *buffer) { struct thorium_message message; thorium_message_init(&message, tag, count, buffer); thorium_actor_send_range(actor, destinations, &message); thorium_message_destroy(&message); }
void thorium_actor_send_buffer(struct thorium_actor *actor, int destination, int tag, int count, void *buffer) { struct thorium_message message; thorium_message_init(&message, tag, count, buffer); thorium_actor_send(actor, destination, &message); thorium_message_destroy(&message); }
void thorium_message_init_copy(struct thorium_message *self, struct thorium_message *old_message) { thorium_message_init(self, thorium_message_action(old_message), thorium_message_count(old_message), thorium_message_buffer(old_message)); thorium_message_set_source(self, thorium_message_source(old_message)); thorium_message_set_destination(self, thorium_message_destination(old_message)); }
void thorium_actor_send_then_empty(struct thorium_actor *actor, int destination, int action, thorium_actor_receive_fn_t handler) { struct thorium_message message; int offset; int count = 0; void *buffer = NULL; thorium_message_init(&message, action, count, buffer); thorium_actor_send_then(actor, destination, &message, handler); thorium_message_destroy(&message); }
void thorium_actor_send_int(struct thorium_actor *actor, int destination, int tag, int value) { struct thorium_message message; void *buffer; int count; count = sizeof(value); buffer = thorium_actor_allocate(actor, count); core_memory_copy(buffer, &value, count); thorium_message_init(&message, tag, count, buffer); thorium_actor_send(actor, destination, &message); thorium_message_destroy(&message); }
void thorium_actor_send_empty(struct thorium_actor *actor, int destination, int tag) { struct thorium_message message; #if 0 void *buffer; /* * Allocate a buffer for metadata. */ buffer = thorium_actor_allocate(actor, 0); #endif thorium_message_init(&message, tag, 0, NULL); thorium_actor_send(actor, destination, &message); thorium_message_destroy(&message); }
void thorium_actor_send_then_int(struct thorium_actor *actor, int destination, int action, int value, thorium_actor_receive_fn_t handler) { struct thorium_message message; int count; int offset; count = sizeof(value); void *buffer = thorium_actor_allocate(actor, count); core_memory_copy(buffer, &value, sizeof(value)); thorium_message_init(&message, action, count, buffer); thorium_actor_send_then(actor, destination, &message, handler); thorium_message_destroy(&message); }
void thorium_actor_send_vector(struct thorium_actor *actor, int destination, int tag, struct core_vector *vector) { int count; struct thorium_message message; void *buffer; count = core_vector_pack_size(vector); buffer = thorium_actor_allocate(actor, count); core_vector_pack(vector, buffer); thorium_message_init(&message, tag, count, buffer); thorium_actor_send(actor, destination, &message); thorium_message_destroy(&message); }
void thorium_actor_send_range_vector(struct thorium_actor *actor, struct core_vector *actors, int tag, struct core_vector *vector) { struct thorium_message message; int count; void *buffer; struct core_memory_pool *ephemeral_memory; ephemeral_memory = thorium_actor_get_ephemeral_memory(actor); count = core_vector_pack_size(vector); buffer = core_memory_pool_allocate(ephemeral_memory, count); core_vector_pack(vector, buffer); thorium_message_init(&message, tag, count, buffer); thorium_actor_send_range(actor, actors, &message); thorium_message_destroy(&message); core_memory_pool_free(ephemeral_memory, buffer); }
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); }
void thorium_actor_send_2_int(struct thorium_actor *actor, int destination, int action, int value1, int value2) { struct thorium_message message; char *buffer; int count; int offset; count = sizeof(value1) + sizeof(value2); buffer = thorium_actor_allocate(actor, count); offset = 0; core_memory_copy(buffer + offset, &value1, sizeof(value1)); offset += sizeof(value1); core_memory_copy(buffer + offset, &value2, sizeof(value2)); offset += sizeof(value2); thorium_message_init(&message, action, count, buffer); thorium_actor_send(actor, destination, &message); thorium_message_destroy(&message); }
void biosal_input_controller_set_offset_reply(struct thorium_actor *self, struct thorium_message *message) { int stream_index; int acquaintance_index; int source; int block_index; struct biosal_mega_block *block; struct biosal_input_controller *concrete_actor; int file_index; char *file_name; struct thorium_message new_message; source = thorium_message_source(message); acquaintance_index = source; concrete_actor = (struct biosal_input_controller *)thorium_actor_concrete_actor(self); stream_index = core_vector_index_of(&concrete_actor->reading_streams, &acquaintance_index); block_index = core_map_get_int(&concrete_actor->assigned_blocks, &stream_index); #ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_READING_STREAMS printf("DEBUG got reply from stream/%d for offset, stream_index %d block_index %d\n", source, stream_index, block_index); #endif block = (struct biosal_mega_block *)core_vector_at(&concrete_actor->mega_block_vector, block_index); file_index = biosal_mega_block_get_file(block); file_name = *(char **)core_vector_at(&concrete_actor->files, file_index); printf("DEBUG send ACTION_INPUT_OPEN %s\n", file_name); thorium_message_init(&new_message, ACTION_INPUT_OPEN, strlen(file_name) + 1, file_name); thorium_actor_send_reply(self, &new_message); thorium_message_destroy(&new_message); }
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); }
void thorium_message_init_with_nodes(struct thorium_message *self, int count, void *buffer, int source, int destination) { int action; action = -1; thorium_message_init(self, action, count, buffer); /* * Initially assign the MPI source rank and MPI destination * rank for the actor source and actor destination, respectively. * Then, read the metadata and resolve the MPI rank from * that. The resolved MPI ranks should be the same in all cases */ thorium_message_set_source(self, source); thorium_message_set_destination(self, destination); thorium_message_set_source_node(self, source); thorium_message_set_destination_node(self, destination); thorium_message_set_type(self, THORIUM_MESSAGE_TYPE_NODE_INBOUND); }
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); }
void biosal_input_stream_receive(struct thorium_actor *actor, struct thorium_message *message) { int tag; int source; uint64_t count; struct biosal_input_stream *concrete_self; int i; int has_sequence; int sequences; int sequence_index; int buffer_size; char *buffer; char *read_buffer; struct biosal_mega_block mega_block; char *file_name_in_buffer; if (thorium_actor_take_action(actor, message)) { return; } concrete_self = thorium_actor_concrete_actor(actor); tag = thorium_message_action(message); source = thorium_message_source(message); buffer = (char *)thorium_message_buffer(message); /* Do nothing if there is an error. * has_error returns the error to the source. */ /* if (biosal_input_stream_has_error(actor, message)) { return; } */ if (tag == ACTION_INPUT_OPEN) { #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG ACTION_INPUT_OPEN\n"); #endif if (concrete_self->open) { concrete_self->error = BIOSAL_INPUT_ERROR_ALREADY_OPEN; thorium_actor_send_reply_int(actor, ACTION_INPUT_OPEN_REPLY, concrete_self->error); thorium_actor_send_to_self_empty(actor, ACTION_ASK_TO_STOP); return; } concrete_self->open = 1; /* TODO: find out the maximum read length in some way */ concrete_self->maximum_sequence_length = BIOSAL_INPUT_MAXIMUM_SEQUENCE_LENGTH; concrete_self->buffer_for_sequence = (char *)core_memory_allocate(concrete_self->maximum_sequence_length, MEMORY_INPUT_STREAM); /*biosal_input_stream_init(actor);*/ #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG biosal_input_stream_receive open %s\n", buffer); #endif /*core_memory_copy(&concrete_self->file_index, buffer, sizeof(concrete_self->file_index));*/ file_name_in_buffer = buffer; printf("stream/%d (node/%d) opens file %s offset %" PRIu64 "\n", thorium_actor_name(actor), thorium_actor_node_name(actor), file_name_in_buffer, concrete_self->starting_offset); #ifdef DEBUG_ISSUE_594 thorium_message_print(message); printf("Buffer %s\n", buffer); #endif concrete_self->file_name = core_memory_allocate(strlen(file_name_in_buffer) + 1, MEMORY_INPUT_STREAM); strcpy(concrete_self->file_name, file_name_in_buffer); biosal_input_proxy_init(&concrete_self->proxy, concrete_self->file_name, concrete_self->starting_offset, concrete_self->ending_offset); concrete_self->proxy_ready = 1; /* Die if there is an error... */ if (biosal_input_stream_has_error(actor, message)) { #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG has error\n"); #endif thorium_actor_send_reply_int(actor, ACTION_INPUT_OPEN_REPLY, concrete_self->error); thorium_actor_send_to_self_empty(actor, ACTION_ASK_TO_STOP); return; } concrete_self->controller = source; /* no error here... */ thorium_actor_send_reply_int(actor, ACTION_INPUT_OPEN_REPLY, concrete_self->error); } else if (tag == ACTION_INPUT_COUNT) { /* count a little bit and yield the worker */ if (concrete_self->count_customer == THORIUM_ACTOR_NOBODY) { concrete_self->count_customer = source; } if (biosal_input_stream_check_open_error(actor, message)) { thorium_actor_send_reply_int64_t(actor, ACTION_INPUT_COUNT_REPLY, concrete_self->error); thorium_actor_send_to_self_empty(actor, ACTION_ASK_TO_STOP); return; } #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG ACTION_INPUT_COUNT received...\n"); #endif i = 0; /* continue counting ... */ has_sequence = 1; while (i < concrete_self->granularity && has_sequence) { has_sequence = biosal_input_proxy_get_sequence(&concrete_self->proxy, concrete_self->buffer_for_sequence); #if 0 printf("Sequence= %s\n", concrete_self->buffer_for_sequence); #endif i++; } sequences = biosal_input_proxy_size(&concrete_self->proxy); #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG ACTION_INPUT_COUNT sequences %d...\n", sequences); #endif if (!has_sequence || sequences % concrete_self->mega_block_size == 0) { biosal_mega_block_init(&mega_block, -1, concrete_self->last_offset, sequences - concrete_self->last_entries, sequences); core_vector_push_back(&concrete_self->mega_blocks, &mega_block); concrete_self->last_entries = sequences; concrete_self->last_offset = biosal_input_proxy_offset(&concrete_self->proxy); thorium_actor_send_int64_t(actor, concrete_self->controller, ACTION_INPUT_COUNT_PROGRESS, sequences); } if (has_sequence) { /*printf("DEBUG yield\n");*/ thorium_actor_send_to_self_empty(actor, ACTION_YIELD); /* notify the controller of our progress... */ } else { thorium_actor_send_to_self_empty(actor, ACTION_INPUT_COUNT_READY); } } else if (tag == ACTION_YIELD_REPLY) { if (biosal_input_stream_check_open_error(actor, message)) { /* * it is not clear that there can be an error when receiving YIELD. error = concrete_self->error; thorium_actor_send_reply_int(actor, ACTION_INPUT_COUNT_REPLY, error); thorium_actor_send_to_self(actor, ACTION_ASK_TO_STOP); */ return; } thorium_actor_send_to_self_empty(actor, ACTION_INPUT_COUNT); } else if (tag == ACTION_INPUT_COUNT_READY) { if (biosal_input_stream_check_open_error(actor, message)) { return; } count = biosal_input_proxy_size(&concrete_self->proxy); thorium_actor_send_vector(actor, concrete_self->count_customer, ACTION_INPUT_COUNT_REPLY, &concrete_self->mega_blocks); printf("input_stream/%d on node/%d counted entries in %s, %" PRIu64 "\n", thorium_actor_name(actor), thorium_actor_node_name(actor), concrete_self->file_name, count); } else if (tag == ACTION_INPUT_CLOSE) { #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG destroy proxy\n"); #endif concrete_self->error = BIOSAL_INPUT_ERROR_NO_ERROR; if (biosal_input_stream_check_open_error(actor, message)) { concrete_self->error = BIOSAL_INPUT_ERROR_FILE_NOT_OPEN; thorium_message_init(message, ACTION_INPUT_CLOSE_REPLY, sizeof(concrete_self->error), &concrete_self->error); thorium_actor_send(actor, source, message); thorium_actor_send_to_self_empty(actor, ACTION_ASK_TO_STOP); return; } thorium_message_init(message, ACTION_INPUT_CLOSE_REPLY, sizeof(concrete_self->error), &concrete_self->error); thorium_actor_send(actor, source, message); thorium_actor_send_to_self_empty(actor, ACTION_ASK_TO_STOP); #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("actor %d sending ACTION_INPUT_CLOSE_REPLY to %d\n", thorium_actor_name(actor), source); #endif } else if (tag == ACTION_INPUT_GET_SEQUENCE) { if (biosal_input_stream_check_open_error(actor, message)) { /* the error management could be better. */ concrete_self->error = BIOSAL_INPUT_ERROR_FILE_NOT_OPEN; thorium_message_init(message, ACTION_INPUT_GET_SEQUENCE_REPLY, sizeof(concrete_self->error), &concrete_self->error); thorium_actor_send(actor, source, message); return; } sequence_index = biosal_input_proxy_size(&concrete_self->proxy); /* TODO it would be clearer to use a struct to pack a int and a char [] * then to use the code below. */ read_buffer = concrete_self->buffer_for_sequence + sizeof(sequence_index); has_sequence = biosal_input_proxy_get_sequence(&concrete_self->proxy, read_buffer); if (!has_sequence) { thorium_message_init(message, ACTION_INPUT_GET_SEQUENCE_END, 0, NULL); thorium_actor_send(actor, source, message); return; } buffer_size = sizeof(sequence_index) + strlen(read_buffer) + 1; core_memory_copy(concrete_self->buffer_for_sequence, &sequence_index, sizeof(sequence_index)); thorium_message_init(message, ACTION_INPUT_GET_SEQUENCE_REPLY, buffer_size, concrete_self->buffer_for_sequence); thorium_actor_send(actor, source, message); } else if (tag == ACTION_INPUT_PUSH_SEQUENCES) { biosal_input_stream_push_sequences(actor, message); } else if (tag == ACTION_ASK_TO_STOP) { thorium_actor_send_to_self_empty(actor, ACTION_STOP); thorium_actor_send_range_empty(actor, &concrete_self->parallel_streams, ACTION_ASK_TO_STOP); thorium_actor_send_reply_empty(actor, ACTION_ASK_TO_STOP_REPLY); } else if (tag == ACTION_INPUT_STREAM_RESET) { /* fail silently */ if (!concrete_self->open) { thorium_actor_send_reply_empty(actor, ACTION_INPUT_STREAM_RESET_REPLY); return; } #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG ACTION_INPUT_STREAM_RESET\n"); #endif biosal_input_proxy_destroy(&concrete_self->proxy); biosal_input_proxy_init(&concrete_self->proxy, concrete_self->file_name, concrete_self->starting_offset, concrete_self->ending_offset); thorium_actor_send_reply_empty(actor, ACTION_INPUT_STREAM_RESET_REPLY); } else if (tag == ACTION_PUSH_SEQUENCE_DATA_BLOCK_REPLY) { thorium_actor_send_to_supervisor_int(actor, ACTION_INPUT_PUSH_SEQUENCES_REPLY, source); } }
int main(int argc, char **argv) { BEGIN_TESTS(); struct core_fast_ring ring; int capacity = 64; int i; int value; int elements; elements = 0; #if 0 printf("Required %d\n", capacity); #endif core_fast_ring_init(&ring, capacity, sizeof(int)); capacity = core_fast_ring_capacity(&ring); #if 0 printf("Provided %d\n", capacity); #endif TEST_BOOLEAN_EQUALS(core_fast_ring_is_empty_from_consumer(&ring), 1); for (i = 0; i < capacity; i++) { TEST_BOOLEAN_EQUALS(core_fast_ring_push_from_producer(&ring, &i), 1); elements++; TEST_INT_EQUALS(core_fast_ring_size_from_producer(&ring), elements); TEST_INT_EQUALS(core_fast_ring_size_from_consumer(&ring), elements); } TEST_BOOLEAN_EQUALS(core_fast_ring_is_full_from_producer(&ring), 1); for (i = 0; i < capacity; i++) { TEST_BOOLEAN_EQUALS(core_fast_ring_pop_from_consumer(&ring, &value), 1); elements--; TEST_INT_EQUALS(value, i); TEST_INT_EQUALS(core_fast_ring_size_from_producer(&ring), elements); TEST_INT_EQUALS(core_fast_ring_size_from_consumer(&ring), elements); } core_fast_ring_destroy(&ring); { struct core_fast_ring ring; int capacity = 64; struct thorium_message message; int action; int count; void *buffer; int inserted; int pulled; action = 1234; count = 0; buffer = NULL; thorium_message_init(&message, action, count, buffer); core_fast_ring_init(&ring, capacity, sizeof(struct thorium_message)); core_fast_ring_use_multiple_producers(&ring); inserted = 0; while (core_fast_ring_push_from_producer(&ring, &message)) { ++inserted; } /* * 64 + 1 = 65, 128 is the next power of 2 for the mask. */ /* TEST_INT_EQUALS(inserted, capacity); */ pulled = 0; while (core_fast_ring_pop_from_consumer(&ring, &message)) { ++pulled; } TEST_INT_EQUALS(inserted, pulled); core_fast_ring_destroy(&ring); thorium_message_destroy(&message); } END_TESTS(); return 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); } } }
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); } } }
void biosal_input_controller_receive_command(struct thorium_actor *actor, struct thorium_message *message) { struct biosal_partition_command command; void *buffer; int stream_index; int store_index; int store_name; uint64_t store_first; uint64_t store_last; int command_name; int stream_name; int *bucket_for_command_name; int bytes; struct biosal_input_command input_command; void *new_buffer; struct thorium_message new_message; struct biosal_input_controller *concrete_actor; int *bucket; int *bucket_for_consumer; int consumer_index; concrete_actor = (struct biosal_input_controller *)thorium_actor_concrete_actor(actor); buffer = thorium_message_buffer(message); biosal_partition_command_unpack(&command, buffer); stream_index = biosal_partition_command_stream_index(&command); #ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_COMMANDS printf("DEBUG biosal_input_controller_receive_command controller receives command for stream %d\n", stream_index); biosal_partition_command_print(&command); #endif store_index = biosal_partition_command_store_index(&command); bucket_for_command_name = (int *)core_vector_at(&concrete_actor->partition_commands, stream_index); bucket_for_consumer = (int *)core_vector_at(&concrete_actor->stream_consumers, stream_index); stream_name = core_vector_at_as_int(&concrete_actor->reading_streams, stream_index); #ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_COMMANDS printf("DEBUG stream_index %d stream_name %d\n", stream_index, stream_name); #endif store_name = *(int *)core_vector_at(&concrete_actor->consumers, store_index); store_first = biosal_partition_command_store_first(&command); store_last = biosal_partition_command_store_last(&command); biosal_input_command_init(&input_command, store_name, store_first, store_last); bytes = biosal_input_command_pack_size(&input_command, &concrete_actor->codec); #ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_COMMANDS printf("DEBUG input command\n"); biosal_input_command_print(&input_command); printf("DEBUG biosal_input_controller_receive_command bytes %d\n", bytes); #endif new_buffer = thorium_actor_allocate(actor, bytes); biosal_input_command_pack(&input_command, new_buffer, &concrete_actor->codec); thorium_message_init(&new_message, ACTION_INPUT_PUSH_SEQUENCES, bytes, new_buffer); #ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_COMMANDS printf("DEBUG biosal_input_controller_receive_command sending ACTION_INPUT_PUSH_SEQUENCES to %d (index %d)\n", stream_name, stream_index); biosal_input_command_print(&input_command); printf("SENDING COMMAND TO stream/%d\n", stream_name); #endif thorium_actor_send(actor, stream_name, &new_message); command_name = biosal_partition_command_name(&command); #ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_COMMANDS printf("controller/%d processed input command %d %p\n", thorium_actor_name(actor), command_name, (void *)bucket_for_command_name); #endif *bucket_for_command_name = command_name; consumer_index = store_index; *bucket_for_consumer = consumer_index; bucket = (int *)core_vector_at(&concrete_actor->consumer_active_requests, consumer_index); (*bucket)++; #ifdef BIOSAL_INPUT_CONTROLLER_DEBUG_CONSUMERS printf("DEBUG consumer # %d has %d active requests\n", consumer_index, *bucket); #endif }
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; } }
void biosal_input_stream_push_sequences(struct thorium_actor *actor, struct thorium_message *message) { struct biosal_input_command command; void *buffer; int store_name; uint64_t store_first; uint64_t store_last; int sequences_to_read; void *new_buffer; int new_count; struct thorium_message new_message; void *buffer_for_sequence; struct biosal_dna_sequence dna_sequence; /*struct core_vector *command_entries;*/ int has_sequence; int i; struct biosal_input_stream *concrete_self; #ifdef BIOSAL_INPUT_STREAM_DEBUG int count; int actual_count; #endif /* answer immediately */ thorium_actor_send_reply_empty(actor, ACTION_INPUT_PUSH_SEQUENCES_READY); has_sequence = 1; #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG stream/%d biosal_input_stream_push_sequences entering...\n", thorium_actor_name(actor)); #endif buffer = thorium_message_buffer(message); concrete_self = (struct biosal_input_stream *)thorium_actor_concrete_actor(actor); biosal_input_command_init_empty(&command); biosal_input_command_unpack(&command, buffer, thorium_actor_get_ephemeral_memory(actor), &concrete_self->codec); #ifdef BIOSAL_INPUT_STREAM_DEBUG count = thorium_message_count(message); printf("DEBUG biosal_input_stream_push_sequences after unpack, count %d:\n", count); biosal_input_command_print(&command); #endif store_name = biosal_input_command_store_name(&command); store_first = biosal_input_command_store_first(&command); store_last = biosal_input_command_store_last(&command); sequences_to_read = store_last - store_first + 1; #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG biosal_input_stream_push_sequences received ACTION_INPUT_PUSH_SEQUENCES\n"); printf("DEBUG Command before sending it\n"); biosal_input_command_print(&command); #endif /* * add sequences to the input command */ buffer_for_sequence = concrete_self->buffer_for_sequence; /*command_entries = biosal_input_command_entries(&command);*/ i = 0; /* TODO: actually load something */ while (sequences_to_read-- && has_sequence) { has_sequence = biosal_input_proxy_get_sequence(&concrete_self->proxy, buffer_for_sequence); biosal_dna_sequence_init(&dna_sequence, buffer_for_sequence, &concrete_self->codec, thorium_actor_get_ephemeral_memory(actor)); biosal_input_command_add_entry(&command, &dna_sequence, &concrete_self->codec, thorium_actor_get_ephemeral_memory(actor)); biosal_dna_sequence_destroy(&dna_sequence, thorium_actor_get_ephemeral_memory(actor)); i++; } #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG prepared %d sequences for command\n", i); biosal_input_command_print(&command); #endif new_count = biosal_input_command_pack_size(&command, &concrete_self->codec); new_buffer = thorium_actor_allocate(actor, new_count); biosal_input_command_pack(&command, new_buffer, &concrete_self->codec); #ifdef BIOSAL_INPUT_STREAM_DEBUG actual_count = biosal_input_command_pack(&command, new_buffer); printf("DEBUG123 new_count %d actual_count %d\n", new_count, actual_count); #endif thorium_message_init(&new_message, ACTION_PUSH_SEQUENCE_DATA_BLOCK, new_count, new_buffer); #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG biosal_input_stream_push_sequences sending ACTION_PUSH_SEQUENCE_DATA_BLOCK to %d\n", store_name); #endif thorium_actor_send(actor, store_name, &new_message); /* * send sequences to store. * The required information is the input command */ /* thorium_actor_send_reply_empty(actor, ACTION_INPUT_PUSH_SEQUENCES_REPLY); */ /* free memory */ #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG freeing %d entries\n", (int)core_vector_size(command_entries)); #endif biosal_input_command_destroy(&command, thorium_actor_get_ephemeral_memory(actor)); #if 0 for (i = 0; i < core_vector_size(command_entries); i++) { a_sequence = (struct biosal_dna_sequence *)core_vector_at(command_entries, i); biosal_dna_sequence_destroy(a_sequence, thorium_actor_get_ephemeral_memory(actor)); } core_vector_destroy(command_entries); #endif #ifdef BIOSAL_INPUT_STREAM_DEBUG printf("DEBUG biosal_input_stream_push_sequences EXIT\n"); #endif }
void biosal_assembly_graph_store_get_vertex(struct thorium_actor *self, struct thorium_message *message) { struct biosal_assembly_vertex vertex; struct biosal_dna_kmer kmer; void *buffer; struct biosal_assembly_graph_store *concrete_self; struct core_memory_pool *ephemeral_memory; struct thorium_message new_message; int new_count; void *new_buffer; struct biosal_assembly_vertex *canonical_vertex; int is_canonical; int path; int position; int count; path = -1; ephemeral_memory = thorium_actor_get_ephemeral_memory(self); concrete_self = thorium_actor_concrete_actor(self); buffer = thorium_message_buffer(message); count = thorium_message_count(message); biosal_dna_kmer_init_empty(&kmer); position = 0; position += biosal_dna_kmer_unpack(&kmer, buffer, concrete_self->kmer_length, ephemeral_memory, &concrete_self->transport_codec); /* * Check if a path index was provided too. */ if (position < count) { position += thorium_message_unpack_int(message, position, &path); } CORE_DEBUGGER_ASSERT_IS_EQUAL_INT(position, count); CORE_DEBUGGER_ASSERT(position == count); canonical_vertex = biosal_assembly_graph_store_find_vertex(self, &kmer); biosal_assembly_vertex_init_copy(&vertex, canonical_vertex); is_canonical = biosal_dna_kmer_is_canonical(&kmer, concrete_self->kmer_length, &concrete_self->transport_codec); if (!is_canonical) { biosal_assembly_vertex_invert_arcs(&vertex); } biosal_dna_kmer_destroy(&kmer, ephemeral_memory); new_count = biosal_assembly_vertex_pack_size(&vertex); new_buffer = thorium_actor_allocate(self, new_count); biosal_assembly_vertex_pack(&vertex, new_buffer); thorium_message_init(&new_message, ACTION_ASSEMBLY_GET_VERTEX_REPLY, new_count, new_buffer); thorium_actor_send_reply(self, &new_message); thorium_message_destroy(&new_message); }
void biosal_assembly_graph_store_get_starting_vertex(struct thorium_actor *self, struct thorium_message *message) { struct biosal_assembly_graph_store *concrete_self; struct biosal_dna_kmer transport_kmer; struct biosal_dna_kmer storage_kmer; struct core_memory_pool *ephemeral_memory; struct thorium_message new_message; int new_count; void *new_buffer; char *sequence; void *storage_key; struct biosal_assembly_vertex *vertex; concrete_self = thorium_actor_concrete_actor(self); ephemeral_memory = thorium_actor_get_ephemeral_memory(self); while (core_map_iterator_has_next(&concrete_self->iterator)) { storage_key = NULL; vertex = NULL; core_map_iterator_next(&concrete_self->iterator, (void **)&storage_key, (void **)&vertex); /* * Skip the vertex if it does have the status * BIOSAL_VERTEX_FLAG_USED. */ if (biosal_assembly_vertex_get_flag(vertex, BIOSAL_VERTEX_FLAG_USED)) { continue; } CORE_DEBUGGER_ASSERT(storage_key != NULL); #ifdef BIOSAL_ASSEMBLY_GRAPH_STORE_DEBUG_GET_STARTING_VERTEX printf("From storage\n"); biosal_assembly_vertex_print(vertex); core_debugger_examine(storage_key, concrete_self->key_length_in_bytes); #endif biosal_dna_kmer_init_empty(&storage_kmer); biosal_dna_kmer_unpack(&storage_kmer, storage_key, concrete_self->kmer_length, ephemeral_memory, &concrete_self->storage_codec); #ifdef BIOSAL_ASSEMBLY_GRAPH_STORE_DEBUG_GET_STARTING_VERTEX printf("DEBUG starting kmer Storage kmer hash %" PRIu64 "\n", biosal_dna_kmer_hash(&storage_kmer, concrete_self->kmer_length, &concrete_self->storage_codec)); biosal_dna_kmer_print(&storage_kmer, concrete_self->kmer_length, &concrete_self->storage_codec, ephemeral_memory); #endif sequence = core_memory_pool_allocate(ephemeral_memory, concrete_self->kmer_length + 1); biosal_dna_kmer_get_sequence(&storage_kmer, sequence, concrete_self->kmer_length, &concrete_self->storage_codec); #ifdef BIOSAL_ASSEMBLY_GRAPH_STORE_DEBUG_GET_STARTING_VERTEX printf("SEQUENCE %s\n", sequence); #endif biosal_dna_kmer_init(&transport_kmer, sequence, &concrete_self->transport_codec, ephemeral_memory); new_count = biosal_dna_kmer_pack_size(&transport_kmer, concrete_self->kmer_length, &concrete_self->transport_codec); new_buffer = thorium_actor_allocate(self, new_count); biosal_dna_kmer_pack(&transport_kmer, new_buffer, concrete_self->kmer_length, &concrete_self->transport_codec); #ifdef BIOSAL_ASSEMBLY_GRAPH_STORE_DEBUG_GET_STARTING_VERTEX printf("Packed version:\n"); core_debugger_examine(new_buffer, new_count); printf("TRANSPORT Kmer new_count %d\n", new_count); biosal_dna_kmer_print(&transport_kmer, concrete_self->kmer_length, &concrete_self->transport_codec, ephemeral_memory); #endif thorium_message_init(&new_message, ACTION_ASSEMBLY_GET_STARTING_KMER_REPLY, new_count, new_buffer); thorium_actor_send_reply(self, &new_message); thorium_message_destroy(&new_message); biosal_dna_kmer_destroy(&transport_kmer, ephemeral_memory); core_memory_pool_free(ephemeral_memory, sequence); biosal_dna_kmer_destroy(&storage_kmer, ephemeral_memory); return; } /* * An empty reply means that the store has nothing more to yield. */ thorium_actor_send_reply_empty(self, ACTION_ASSEMBLY_GET_STARTING_KMER_REPLY); }