- int index;
- int completed = 0;
- void *addr_pointed;
- xbt_dynar_foreach(incomplete_communications_pattern, cursor, index) {
- current_pattern =
- (mc_comm_pattern_t) xbt_dynar_get_as(list, index, mc_comm_pattern_t);
- if (current_pattern->comm == comm) {
- current_pattern->src_proc = comm->comm.src_proc->pid;
- current_pattern->dst_proc = comm->comm.dst_proc->pid;
- current_pattern->src_host =
- simcall_host_get_name(comm->comm.src_proc->smx_host);
- current_pattern->dst_host =
- simcall_host_get_name(comm->comm.dst_proc->smx_host);
- if (current_pattern->data_size == -1) {
- current_pattern->data_size = *(comm->comm.dst_buff_size);
- current_pattern->data = xbt_malloc0(current_pattern->data_size);
- addr_pointed = *(void **) comm->comm.src_buff;
- if (addr_pointed > std_heap
- && addr_pointed < ((xbt_mheap_t) std_heap)->breakval)
- memcpy(current_pattern->data, addr_pointed,
- current_pattern->data_size);
- else
- memcpy(current_pattern->data, comm->comm.src_buff,
- current_pattern->data_size);
- }
- xbt_dynar_remove_at(incomplete_communications_pattern, cursor, NULL);
- completed++;
- if (completed == 2)
- return;
- cursor--;
+ unsigned int src = comm->comm.src_proc->pid;
+ unsigned int dst = comm->comm.dst_proc->pid;
+ mc_comm_pattern_t src_comm_pattern;
+ mc_comm_pattern_t dst_comm_pattern;
+ int src_completed = 0, dst_completed = 0;
+
+ /* Complete comm pattern */
+ xbt_dynar_foreach((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, src, xbt_dynar_t), cursor, current_comm_pattern) {
+ if (current_comm_pattern-> comm == comm) {
+ update_comm_pattern(current_comm_pattern, comm);
+ src_completed = 1;
+ xbt_dynar_remove_at((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, src, xbt_dynar_t), cursor, &src_comm_pattern);
+ XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %u", src, cursor);
+ break;
+ }
+ }
+ if(!src_completed)
+ xbt_die("Corresponding communication for the source process not found!");
+
+ cursor = 0;
+
+ xbt_dynar_foreach((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, dst, xbt_dynar_t), cursor, current_comm_pattern) {
+ if (current_comm_pattern-> comm == comm) {
+ update_comm_pattern(current_comm_pattern, comm);
+ dst_completed = 1;
+ xbt_dynar_remove_at((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, dst, xbt_dynar_t), cursor, &dst_comm_pattern);
+ XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %u", dst, cursor);
+ break;
+ }
+ }
+ if(!dst_completed)
+ xbt_die("Corresponding communication for the destination process not found!");
+
+ if (!initial_global_state->initial_communications_pattern_done) {
+ /* Store comm pattern */
+ if(src_comm_pattern->index < xbt_dynar_length(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, src, mc_list_comm_pattern_t))->list)){
+ xbt_dynar_set(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, src, mc_list_comm_pattern_t))->list, src_comm_pattern->index, &src_comm_pattern);
+ ((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, src, mc_list_comm_pattern_t))->list->used++;
+ } else {
+ xbt_dynar_insert_at(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, src, mc_list_comm_pattern_t))->list, src_comm_pattern->index, &src_comm_pattern);
+ }
+
+ if(dst_comm_pattern->index < xbt_dynar_length(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, dst, mc_list_comm_pattern_t))->list)) {
+ xbt_dynar_set(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, dst, mc_list_comm_pattern_t))->list, dst_comm_pattern->index, &dst_comm_pattern);
+ ((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, dst, mc_list_comm_pattern_t))->list->used++;
+ } else {
+ xbt_dynar_insert_at(((mc_list_comm_pattern_t)xbt_dynar_get_as(initial_communications_pattern, dst, mc_list_comm_pattern_t))->list, dst_comm_pattern->index, &dst_comm_pattern);