void biosal_assembly_graph_store_set_vertex_flag(struct thorium_actor *self, struct thorium_message *message) { char *buffer; int count; int flag; struct biosal_dna_kmer transport_kmer; struct biosal_assembly_vertex *vertex; struct biosal_assembly_graph_store *concrete_self; struct core_memory_pool *ephemeral_memory; int position; concrete_self = thorium_actor_concrete_actor(self); ephemeral_memory = thorium_actor_get_ephemeral_memory(self); biosal_dna_kmer_init_empty(&transport_kmer); buffer = thorium_message_buffer(message); count = thorium_message_count(message); position = 0; position += biosal_dna_kmer_unpack(&transport_kmer, buffer, concrete_self->kmer_length, ephemeral_memory, &concrete_self->transport_codec); core_memory_copy(&flag, buffer + position, sizeof(flag)); position += sizeof(flag); CORE_DEBUGGER_ASSERT_IS_EQUAL_INT(position, count); CORE_DEBUGGER_ASSERT(flag >= BIOSAL_VERTEX_FLAG_START_VALUE); CORE_DEBUGGER_ASSERT(flag <= BIOSAL_VERTEX_FLAG_END_VALUE); if (flag == BIOSAL_VERTEX_FLAG_UNITIG) { ++concrete_self->unitig_vertex_count; } #if 0 printf("DEBUG ACTION_SET_VERTEX_FLAG %d\n", flag); #endif vertex = biosal_assembly_graph_store_find_vertex(self, &transport_kmer); CORE_DEBUGGER_ASSERT_NOT_NULL(vertex); biosal_dna_kmer_destroy(&transport_kmer, ephemeral_memory); biosal_assembly_vertex_set_flag(vertex, flag); thorium_actor_send_reply_empty(self, ACTION_SET_VERTEX_FLAG_REPLY); }
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); }
static void source_receive(struct thorium_actor *self, struct thorium_message *message) { int action; void *buffer; int leader; int source; int count; struct source *concrete_self; int name; concrete_self = (struct source *)thorium_actor_concrete_actor(self); action = thorium_message_action(message); buffer = thorium_message_buffer(message); source = thorium_message_source(message); name = thorium_actor_name(self); count = thorium_message_count(message); if (action == ACTION_ASK_TO_STOP) { thorium_actor_log(self, "sent %d ACTION_PING messages\n", concrete_self->message_count); thorium_actor_send_to_self_empty(self, ACTION_STOP); } else if (action == ACTION_NOTIFY) { #ifdef LATENCY_PROBE_USE_MULTIPLEXER thorium_actor_send_to_self_empty(self, ACTION_ENABLE_MULTIPLEXER); #endif CORE_DEBUGGER_ASSERT(core_vector_empty(&concrete_self->targets)); core_vector_unpack(&concrete_self->targets, buffer); if (source_is_important(self)) { printf("%d (node %d worker %d) has %d targets\n", thorium_actor_name(self), thorium_actor_node_name(self), thorium_actor_worker_name(self), (int)core_vector_size(&concrete_self->targets)); } concrete_self->leader = source; source_send_ping(self); } else if (action == ACTION_PING_REPLY) { CORE_DEBUGGER_ASSERT(count == 0); ++concrete_self->message_count; CORE_DEBUGGER_ASSERT_IS_EQUAL_INT(count, 0); CORE_DEBUGGER_ASSERT_IS_NULL(buffer); if (concrete_self->message_count % PERIOD == 0 || concrete_self->event_count < 500) { if (source_is_important(self)) { printf("progress %d %d/%d\n", name, concrete_self->message_count, concrete_self->event_count); } } if (concrete_self->message_count == concrete_self->event_count) { leader = concrete_self->leader; thorium_actor_send_empty(self, leader, ACTION_NOTIFY_REPLY); if (source_is_important(self)) printf("%d (ACTION_PING sent: %d)" " sends ACTION_NOTIFY_REPLY to %d\n", thorium_actor_name(self), concrete_self->message_count, leader); } else { source_send_ping(self); } } }