- 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;
+ int src_completed = 0, dst_completed = 0;
+
+ /* Looking for the corresponding communication in the comm pattern list of the src process */
+ xbt_dynar_foreach((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, src, xbt_dynar_t), cursor, index){
+ current_comm_pattern = (mc_comm_pattern_t) xbt_dynar_get_as((xbt_dynar_t)xbt_dynar_get_as(list, src, xbt_dynar_t), index, mc_comm_pattern_t);
+ if(current_comm_pattern->comm == comm){
+ update_comm_pattern(current_comm_pattern, comm);
+ xbt_dynar_remove_at((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, src, xbt_dynar_t), cursor, NULL);
+ src_completed = 1;
+ break;
+ }
+ }
+
+ if(!src_completed)
+ xbt_die("Corresponding communication for the source process not found!");
+
+ cursor = 0;
+
+ /* Looking for the corresponding communication in the comm pattern list of the dst process */
+ xbt_dynar_foreach((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, dst, xbt_dynar_t), cursor, index){
+ current_comm_pattern = (mc_comm_pattern_t) xbt_dynar_get_as((xbt_dynar_t)xbt_dynar_get_as(list, dst, xbt_dynar_t), index, mc_comm_pattern_t);
+ if(current_comm_pattern->comm == comm){
+ update_comm_pattern(current_comm_pattern, comm);
+ xbt_dynar_remove_at((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, dst, xbt_dynar_t), cursor, NULL);
+ dst_completed = 1;
+ break;