diff dependency.c @ 48:593fe0543a22

added NtoN construct recording (in send/recv_type for now)
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Wed, 21 Dec 2011 16:53:22 +0100
parents 23bcca1c3687
children 70d24e2343bb
line diff
     1.1 --- a/dependency.c	Tue Dec 20 14:42:56 2011 +0100
     1.2 +++ b/dependency.c	Wed Dec 21 16:53:22 2011 +0100
     1.3 @@ -12,26 +12,55 @@
     1.4      return newDep;
     1.5  }
     1.6  
     1.7 +NtoN* new_NtoN(int id){
     1.8 +    NtoN* newn = (NtoN*) VMS__malloc(sizeof(NtoN));
     1.9 +    newn->id = id;
    1.10 +    newn->senders = makeListOfArrays(sizeof(Unit), 64);
    1.11 +    newn->receivers = makeListOfArrays(sizeof(Unit), 64);
    1.12 +    return newn;
    1.13 +}
    1.14 +
    1.15  int set_dependency_file(FILE* file){
    1.16      dependency_file = file;
    1.17  }
    1.18  
    1.19  void print_ctl_dependency_to_file(void* _dep){
    1.20      Dependency* dep = (Dependency*) _dep;
    1.21 +    if(!dep) return;
    1.22      fprintf(dependency_file,"ctlDep,%d,%d,%d,%d\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task);
    1.23  }
    1.24  
    1.25  void print_comm_dependency_to_file(void* _dep){
    1.26      Dependency* dep = (Dependency*) _dep;
    1.27 +    if(!dep) return;
    1.28      fprintf(dependency_file,"commDep,%d,%d,%d,%d\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task);
    1.29  }
    1.30  
    1.31  void print_dependency_to_file(void* _dep){
    1.32      Dependency* dep = (Dependency*) _dep;
    1.33 +    if(!dep) return;
    1.34      fprintf(dependency_file,"VP_%d_%d -> VP_%d_%d;\n",dep->from_vp,dep->from_task,dep->to_vp,dep->to_task);
    1.35  }
    1.36  
    1.37  void print_unit_to_file(void* _unit){
    1.38      Unit* unit = (Unit*) _unit;
    1.39 +    if(!unit) return;
    1.40      fprintf(dependency_file,"unit,%d,%d\n",unit->vp,unit->task);
    1.41 +}
    1.42 +
    1.43 +void print_nton_set_helper(void* _u){
    1.44 +    Unit* u = (Unit*) _u;
    1.45 +    if(!u) return;
    1.46 +    fprintf(dependency_file,",%d,%d",u->vp,u->task);
    1.47 +}
    1.48 +
    1.49 +void print_nton_to_file(void* _nton){
    1.50 +    NtoN* nton = (NtoN*) _nton;
    1.51 +    if(!nton) return;
    1.52 +    //assert(nton->senders->next_free_index==nton->receivers->next_free_index);
    1.53 +    int numInSet = nton->senders->next_free_index;
    1.54 +    fprintf(dependency_file,"NtoN,%d",numInSet);
    1.55 +    forAllInListOfArraysDo(nton->senders,&print_nton_set_helper);
    1.56 +    forAllInListOfArraysDo(nton->receivers,&print_nton_set_helper);
    1.57 +    fprintf(dependency_file,"\n");
    1.58  }
    1.59 \ No newline at end of file