PIPS
locality.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  context_p
 cette structure contient une pile. More...
 

Typedefs

typedef struct context_p context_t
 

Functions

bool loop_statistics (const string)
 cproto-generated files More...
 
statement permutation (statement, Pmatrix)
 
statement permutation2 (statement, Pmatrix)
 
statement Hierarchical_tiling (void)
 
int position_one_element (Pmatrix, int)
 
statement Tiling_buffer_allocation (void)
 
statement Tiling2_buffer (void)
 
bool tiling_sequence (string)
 
statement unimodular (statement)
 
statement free_guards (statement)
 
bool guard_elimination (string)
 

Variables

loop loop1
 tiling_sequence.c More...
 
entity first_array
 une copie de l'un des nids de la sequence More...
 
Psysteme sc_newbase
 guard_elimination.c More...
 
Ptsg sg
 
bool if1
 
bool if2
 

Typedef Documentation

◆ context_t

typedef struct context_p context_t

Function Documentation

◆ free_guards()

statement free_guards ( statement  s)

sg_dump(sg);

fprint_lsom(stderr, vertice,variable_dump_name );

debut cas1

fins cas1

ebut cas2

fin cas2

debut cas3

s1

in cas3

debut cas4

in cas4

Definition at line 544 of file guard_elimination.c.

546 {
547  int isoler =-1,isoler2=-1;
548  instruction ins;
549  statement body1,body2,loop2=NULL;
550  sequence seqi,seqj,seq;
551  list lisi,lisj,lisjcopy,lis,lisjcopy2,lisp;
552  statement first, last=NULL;
553  expression exp;
555  Pvecteur pv1,pv2=NULL,pvif1=NULL,pvif2=NULL,pv_i_lower,pv_i_upper;
556  Pcontrainte cif1=NULL,cif2=NULL;
557  Value sommetg[4];
558  loop tab_loop[6], loop1;
559  instruction tab_instruction[6];
560  statement tab_statement[6];
561  int i=0,j;
562  Psommet vertice,e;
563  int nbr_vertice;
564  Variable indice1,indice2;
565  range range_i,range1,range2,range3;
566  /* sg_dump(sg); */
567  /* fprint_lsom(stderr, vertice,variable_dump_name ); */
568  ins =statement_instruction(s);
569  loop1=instruction_loop(ins);
570  body1=loop_body(instruction_loop(ins));
571  indice1=(Variable )loop_index(instruction_loop(ins));
572  range_i=loop_range(instruction_loop(ins));
576  vect_add_elem(&pv_i_lower,indice1,-1);
578  vect_add_elem(&pv_i_upper,indice1,-1);
579  ins =statement_instruction(body1);
580  seqi=instruction_sequence(ins);
581  lisi =sequence_statements(seqi);
582  MAP(STATEMENT,s1,{loop2 =s1; },lisi) ;
583  ins=statement_instruction(loop2);
584  indice2=(Variable )loop_index(instruction_loop(ins));
585  body2=loop_body(instruction_loop(ins));
586  ins =statement_instruction(body2);
587  seqj=instruction_sequence(ins);
588  lisj =sequence_statements(seqj);
589  lisjcopy= gen_full_copy_list(lisj);
590  first= (statement )CHUNK( CAR(lisj));
591  nbr_vertice=sg_nbre_sommets(sg);
592  printf(" le nombre de sommet est %d \n", nbr_vertice);
593  vertice= sg_sommets(sg);
594  for (e = vertice; e != NULL; e = e->succ) {
595  pv1=e->vecteur;
596  sommetg[i]=value_div (vect_coeff(indice1,pv1),e->denominateur);
597  i++;
598  };
599  for(i=0;i<=nbr_vertice-1;i++)
600  {
601  for(j=i+1;j<= nbr_vertice;j++)
602  if( sommetg[j]< sommetg[i] )
603  {
604  Value permut;
605  permut= sommetg[i];
606  sommetg[i]= sommetg[j];
607  sommetg[j]=permut;
608  };
609  };
610  for(i=0;i<= nbr_vertice-1;i++)
611  {
612  if( sommetg[i]== sommetg[i+1] )
613  {
614  for (j=i;j<=nbr_vertice-1;j++)
615  sommetg[j]=sommetg[j+1];
616  nbr_vertice--;
617  };
618  };
619  i=0;
620  MAP(STATEMENT,s1, { last =s1; },lisjcopy) ;
621  if (if1){
622  Pcontrainte peq;
623  syntax syntax;
624  call call;
625  list lis;
626  CHUNK(CAR(lisjcopy))= (gen_chunk *)
633  lis =call_arguments(call);
634  exp=(expression )CHUNK(CAR(lis));
636  pv1=normalized_linear(norm);
637  MAP(EXPRESSION,exp,{
639  pv2=normalized_linear(norm);
640  },lis) ;
641  pvif1=vect_substract(pv1,pv2);
643  for (peq = sc_newbase->inegalites;peq!=NULL;peq=peq->succ){
644  if( vect_oppos(pvif1,peq->vecteur))
645  pvif1=vect_substract(VECTEUR_NUL,vect_dup(pvif1));
646  };
647  cif1=contrainte_make(pvif1);
651  }
652  if(if2){
653  Pcontrainte peq;
654  syntax syntax;
655  call call;
656  list lis;
657  CHUNK(CAR(gen_last(lisjcopy)))= (gen_chunk *)
664  lis =call_arguments(call);
665  exp=(expression) CHUNK(CAR(lis));
667  pv1=normalized_linear(norm);
668  MAP(EXPRESSION,exp,{
670  pv2=normalized_linear(norm);
671  },lis) ;
672  pvif2=vect_substract(pv1,pv2);
673  for (peq = sc_newbase->inegalites;peq!=NULL;peq=peq->succ){
674  if( vect_oppos(pvif2,peq->vecteur))
675  pvif2= vect_substract(VECTEUR_NUL,vect_dup(pvif2)) ;
676  }
677  cif2=contrainte_make(pvif2);
681  (exp, int_to_expression(0) );
682  }
683  lis=NIL;
684  lisjcopy2= gen_full_copy_list(lisjcopy);
685  if(if1) CHUNK( CAR( (lisjcopy2)))= (gen_chunk *) make_block_statement(NIL);
686  if(if2)CHUNK(CAR(gen_last((lisjcopy))))= (gen_chunk *) make_block_statement(NIL);
687  for(i=0;i<=2*nbr_vertice-2;i++){
688  Pcontrainte peq,cinf=NULL,csup=NULL;
689  statement body1,body2;
690  instruction ins;
691  sequence seqi,seqj;
692  list lisi,lisj;
693  range range;
694  statement loop2=NULL;
695  bool condition1=false,condition2=false;
696  tab_loop[i]=copy_loop(loop1);
697  tab_instruction[i] = make_instruction_loop(tab_loop[i]);
698  tab_statement[i]=instruction_to_statement ( tab_instruction[i]);
699  lis=CONS(STATEMENT, tab_statement[i],lis);
700  if (i%2==0){
701  int indice;
702  Value minjp=-100,maxjp=100;
703  indice=i/2;
704  range_lower(loop_range(tab_loop[i]))=
705  int_to_expression( sommetg[indice]);
706  range_upper(loop_range(tab_loop[i]))=
707  int_to_expression( sommetg[indice]);
708  for (peq = sc_newbase->inegalites;peq!=NULL;peq=peq->succ){
709  Pvecteur v;
710  Value constante,val1,val2;
711  v = contrainte_vecteur(peq);
712  constante=vect_coeff(TCST,v);
713  val1=vect_coeff(indice1,v);
714  val2=vect_coeff(indice2,v);
715  if (val2 < 0){
716  if (eval2(constante,val1,val2, sommetg[indice])>minjp ){
717  minjp=eval2(constante,val1,val2, sommetg[indice]);
718  cinf=peq;
719  }
720  else {
721  if ( eval2(constante,val1,val2, sommetg[indice])==minjp ){
722  Pvecteur vp;
723  Value constantep,val1p,val2p;
724  vp=contrainte_vecteur(cinf);
725  constantep=vect_coeff(TCST,vp);
726  val1p=vect_coeff(indice1,vp);
727  val2p=vect_coeff(indice2,vp);
729  ( value_direct_multiply(val1,sommetg[indice])+ constante ,-val2p)
731  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2))
732  cinf=peq;
733  else
735  (value_direct_multiply(val1,sommetg[indice])+ constante,-val2p)
737  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2))
738  if(egalite_equal(peq,cif1)||egalite_equal(peq,cif2) )
739  cinf=peq;
740  };
741  };
742  };
743  if (val2 > 0){
744  if (eval2(constante,val1,val2, sommetg[indice])<maxjp ){
745  maxjp=eval2(constante,val1,val2, sommetg[indice]);
746  csup=peq;
747  }
748  else {
749  if (eval2(constante,val1,val2, sommetg[indice])==maxjp ){
750  Pvecteur vp;
751  Value constantep,val1p,val2p;
752  vp=contrainte_vecteur(csup);
753  constantep=vect_coeff(TCST,vp);
754  val1p=vect_coeff(indice1,vp);
755  val2p=vect_coeff(indice2,vp);;
757  (value_direct_multiply(val1,sommetg[indice])+ constante ,-val2p)
759  (value_direct_multiply (val1p,sommetg[indice])+ constantep,-val2))
760  csup=peq;
761  else
763  (value_direct_multiply(val1,sommetg[indice])+ constante ,-val2p)
765  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2))
766  if( ( egalite_equal(peq,cif1) )||(egalite_equal(peq,cif2)) )
767  csup=peq;
768  };
769  };
770  };
771  };
772  for (e = vertice; e != NULL; e = e->succ) {
773  Value j2;
774  Pvecteur pv1;
775  pv1=e->vecteur;
776  if (sommetg[indice]==vect_coeff(indice1,pv1)){
777  j2=vect_coeff(indice2,pv1);
778  if (
779  (value_direct_multiply(vect_coeff(indice1,pvif1),sommetg[indice])+
780  value_direct_multiply(vect_coeff(indice2,pvif1),j2)+
781  vect_coeff(TCST,pvif1)==0)&&
782  (value_direct_multiply(vect_coeff(indice1,pvif2),sommetg[indice])+
783  value_direct_multiply(vect_coeff(indice2,pvif2),j2)+
784  vect_coeff(TCST,pvif2)==0)){
785  if( vect_coeff(indice2,pvif2) < 0 )
786  condition1=true;
787  else{
788  if( vect_coeff(indice2,pvif1) > 0 ){
789  condition2=true;
790 
791  };
792  }
793  }
794  }
795  };
796 
797  }
798  else{
799  int indice;
800  Value minjp1=-100,minjp2=-100,maxjp1=100,maxjp2=100;
801  indice=i/2;
802  range_lower(loop_range(tab_loop[i]))=
803  int_to_expression( sommetg[indice]+1);
804  range_upper(loop_range(tab_loop[i]))=
805  int_to_expression( sommetg[indice+1]-1);
806  for (peq = sc_newbase->inegalites;peq!=NULL;peq=peq->succ){
807  Pvecteur v;
808  Value constante,val1,val2;
809  v = contrainte_vecteur(peq);
810  constante=vect_coeff(TCST,v);
811  val1=vect_coeff(indice1,v);
812  val2=vect_coeff(indice2,v);
813  if (val2 < 0){
814  if ( (eval2(constante,val1,val2, sommetg[indice])>=minjp1 )
815  &&( eval2(constante,val1,val2, sommetg[indice+1]) >=minjp2)){
816  if ( (eval2(constante,val1,val2, sommetg[indice])==minjp1 )
817  &&( eval2(constante,val1,val2, sommetg[indice+1]) ==minjp2))
818  {
819  Pvecteur vp;
820  Value constantep,val1p,val2p;
821  vp=contrainte_vecteur(cinf);
822  constantep=vect_coeff(TCST,vp);
823  val1p=vect_coeff(indice1,vp);
824  val2p=vect_coeff(indice2,vp);
826  (value_direct_multiply(val1,sommetg[indice])+constante,-val2p)
828  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2))||
830  ( value_direct_multiply(val1,sommetg[indice+1])+ constante ,-val2p)
833  (val1p,sommetg[indice+1])+ constantep ,-val2)))
834  {
835  minjp1=eval2(constante,val1,val2, sommetg[indice]);
836  minjp2=eval2(constante,val1,val2, sommetg[indice+1]);
837  cinf=peq;
838  }
839  }
840  else{
841  minjp1=eval2(constante,val1,val2, sommetg[indice]);
842  minjp2=eval2(constante,val1,val2, sommetg[indice+1]);
843  cinf=peq;
844  }
845  };
846  };
847  if (val2 > 0){
848  if ( (eval2(constante,val1,val2, sommetg[indice])<=maxjp1 )&&
849  ( eval2(constante,val1,val2, sommetg[indice+1]) <=maxjp2)){
850  if ( (eval2(constante,val1,val2, sommetg[indice])==maxjp1 )
851  &&( eval2(constante,val1,val2, sommetg[indice+1]) ==maxjp2))
852  {
853  Pvecteur vp;
854  Value constantep,val1p,val2p;
855  vp=contrainte_vecteur(csup);
856  constantep=vect_coeff(TCST,vp);
857  val1p=vect_coeff(indice1,vp);
858  val2p=vect_coeff(indice2,vp);
860  (value_direct_multiply(val1,sommetg[indice])+ constante ,-val2p)
862  (value_direct_multiply(val1p,sommetg[indice])+constantep,-val2)) ||
864  (value_direct_multiply(val1,sommetg[indice+1])+ constante ,-val2p)
866  (value_direct_multiply (val1p,sommetg[indice+1])+constantep,-val2)))
867  {
868  maxjp1=eval2(constante,val1,val2, sommetg[indice]);
869  maxjp2=eval2(constante,val1,val2, sommetg[indice+1]);
870  csup=peq;
871  };
872  }
873  else{
874  maxjp1=eval2(constante,val1,val2, sommetg[indice]);
875  maxjp2=eval2(constante,val1,val2, sommetg[indice+1]);
876  csup=peq;
877  };
878  };
879  };
880  };
881  };
882  body1=loop_body( tab_loop[i]);
883  ins =statement_instruction(body1);
884  seqi=instruction_sequence(ins);
885  lisi =sequence_statements(seqi);
886  MAP(STATEMENT,s,loop2=s,lisi);
887  ins=statement_instruction(loop2);
891  body2= loop_body(instruction_loop(ins));
893  lisj=sequence_statements(seqj);
894  if (condition1){
895  list lisjcopy;
896  Pvecteur v;
897  Value constante;
898  lisjcopy= gen_full_copy_list(lisj);
899  CHUNK(CAR(gen_last(lisjcopy)))= (gen_chunk *)
901  CHUNK(CAR(lisjcopy))= (gen_chunk *)
903  lisi= gen_concatenate(lisjcopy,lisi);
904  sequence_statements(seqi)=lisi;
905  v = vect_dup (contrainte_vecteur(cinf));
906  constante=vect_coeff(TCST,v);
907  vect_chg_coeff(&v,TCST,value_plus(1,constante));
908  cinf=contrainte_make(v);
910 
911  }
912  if (condition2){
913  Pvecteur v;
914  Value constante;
915  list lisjcopy;
916  lisjcopy= gen_full_copy_list(lisj);
917  CHUNK(CAR(gen_last(lisjcopy)))= (gen_chunk *)
919  CHUNK(CAR(lisjcopy))= (gen_chunk *)
921  lisi= gen_concatenate(lisi,lisjcopy);
922  sequence_statements(seqi)=lisi;
923  v=vect_dup( contrainte_vecteur(csup));
924  constante=vect_coeff(TCST,v);
925  vect_chg_coeff(&v,TCST,value_plus(1,constante));
926  csup=contrainte_make(v);
928  }
929  if (i==0){
930  if ( vect_equal(pvif1,pv_i_lower) ||
931  vect_oppos(pvif1,pv_i_lower)){
932  CHUNK( CAR((lisj)))= (gen_chunk * )
934  sequence_statements(seqj)=lisj;
935  isoler2=0;
936  }
937  else{
938  if ( vect_equal(pvif2,pv_i_lower) ||
939  vect_oppos(pvif2,pv_i_lower)) {
940  CHUNK( CAR(gen_last((lisj))))= (gen_chunk * )
942  sequence_statements(seqj)=lisj;
943  isoler2=0;
944  };
945  };
946  };
947  if (i==2*nbr_vertice-2){
948  if ( vect_equal(pvif1,pv_i_upper) ||
949  vect_oppos(pvif1,pv_i_upper))
950  {
951  CHUNK( CAR((lisj)))= (gen_chunk * )
953  sequence_statements(seqj)=lisj;
954  isoler=2*nbr_vertice-2;
955  }
956  else{
957  if ( vect_equal(pvif2,pv_i_upper) ||
958  vect_oppos(pvif2,pv_i_upper)) {
959  CHUNK( CAR(gen_last((lisj))))= (gen_chunk * )
961  sequence_statements(seqj)=lisj;
962  isoler=2*nbr_vertice-2;
963  };
964  };
965  };
966 
967  if ((condition1==false) && (condition2==false)){
968 
969  /* debut cas1 */
970 
971  if ( egalite_equal(cinf,cif1)){
972  if (value_abs (vect_coeff(indice2,pvif1))==1){
973  lisi=CONS(STATEMENT,
975  sequence_statements(seqi)=lisi;
976  }
977  else{
978  list lexp;
979  call ca;
980  expression exp1,exp2;
981  Pvecteur pv;
982  statement s;
983  pv=vect_dup (pvif1);
984  vect_erase_var( &pv,indice2);
985  exp1=Pvecteur_to_expression(pv);
986  s= copy_statement (first);
988  (-vect_coeff(indice2,pvif1)), NIL);
989  lexp = CONS(EXPRESSION, exp1, lexp);
993  exp2=int_to_expression(0);
994  exp1=eq_expression(exp1,exp2);
996  lisi=CONS(STATEMENT,s,lisi);
997  sequence_statements(seqi)=lisi;
998  };
999  };
1000 
1001  /* fins cas1 */
1002 
1003 
1004  /*debut cas2 */
1005 
1006  if ( egalite_equal(csup,cif2)) {
1007  list listemp;
1008  if (value_abs (vect_coeff(indice2,pvif2))==1){
1009  listemp=CONS(STATEMENT,
1011  lisi= gen_concatenate(lisi,listemp);
1012  sequence_statements(seqi)=lisi;
1013  }
1014  else{
1015  list lexp;
1016  call ca;
1017  expression exp1,exp2;
1018  Pvecteur pv;
1019  statement s;
1020  pv=vect_dup (pvif2);
1021  vect_erase_var( &pv,indice2);
1022  exp1=Pvecteur_to_expression(pv);
1023  s= copy_statement (last);
1025  (-vect_coeff(indice2,pvif2)), NIL);
1026  lexp = CONS(EXPRESSION, exp1, lexp);
1030  exp2=int_to_expression(0);
1031  exp1=eq_expression(exp1,exp2);
1033  listemp=CONS(STATEMENT,s ,NIL);
1034  lisi= gen_concatenate(lisi,listemp);
1035  sequence_statements(seqi)=lisi;
1036  };
1037  };
1038 
1039 
1040  /* fin cas2 */
1041  /* debut cas3 */
1042 
1043  if ( egalite_equal(cinf,cif2)) {
1044  statement sif1;
1045  sequence seqif1;
1046  instruction insif1;
1047  Pvecteur v;
1048  Value constante;
1049  seqif1=make_sequence(lisjcopy2);
1050  insif1=make_instruction_sequence(seqif1);
1051  sif1=instruction_to_statement(insif1);
1052  if (value_abs (vect_coeff(indice2,pvif2))==1){
1053  lisi=gen_concatenate(lisjcopy2,lisi);
1054  sequence_statements(seqi)=lisi;
1055  }
1056  else{
1057  list lexp;
1058  call ca;
1059  expression exp1,exp2;
1060  Pvecteur pv;
1061  Value val;
1062  statement s/*,s1*/;
1063  pv=vect_dup (pvif2);
1064  val=vect_coeff(indice2,pvif2);
1065  vect_erase_var( &pv,indice2);
1066  exp1=Pvecteur_to_expression(pv);;
1067  s= copy_statement (last);
1068 
1070  (-val), NIL);
1071  lexp = CONS(EXPRESSION, exp1, lexp);
1075  exp2=int_to_expression(0);
1076  exp1=eq_expression(exp1,exp2);
1079  lisi=CONS(STATEMENT,s,lisi);
1080  sequence_statements(seqi)=lisi;
1081  };
1082  v = vect_dup (contrainte_vecteur(cinf));
1083  constante=vect_coeff(TCST,v);
1084  vect_chg_coeff(&v,TCST,value_plus(1,constante));
1085  cinf=contrainte_make(v);
1087  }
1088  /*fin cas3 */
1089  /* debut cas4 */
1090 
1091  if ( egalite_equal(csup,cif1)){
1092  statement sif2;
1093  sequence seqif2;
1094  instruction insif2;
1095  Pvecteur v;
1096  list listemp;
1097  Value constante;
1098  seqif2=make_sequence(lisjcopy);
1099  insif2=make_instruction_sequence(seqif2);
1100  sif2=instruction_to_statement(insif2);
1101  if (value_abs (vect_coeff(indice2,pvif1))==1){
1102  lisi=gen_concatenate(lisi,lisjcopy);
1103  sequence_statements(seqi)=lisi;
1104  }
1105  else{
1106  list lexp;
1107  call ca;
1108  expression exp1,exp2;
1109  Pvecteur pv;
1110  statement s;
1111  pv=vect_dup (pvif1);
1112  vect_erase_var( &pv,indice2);
1113  exp1=Pvecteur_to_expression(pv);
1114  s= copy_statement (first);
1116  (-vect_coeff(indice2,pvif1)), NIL);
1117  lexp = CONS(EXPRESSION, exp1, lexp);
1121  exp2=int_to_expression(0);
1122  exp1=eq_expression(exp1,exp2);
1125  listemp=CONS(STATEMENT,s ,NIL);
1126  lisi= gen_concatenate(lisi,listemp);
1127  sequence_statements(seqi)=lisi;
1128  };
1129  v=vect_dup( contrainte_vecteur(csup));
1130  constante=vect_coeff(TCST,v);
1131  vect_chg_coeff(&v,TCST,value_plus(1,constante));
1132  csup=contrainte_make(v);
1134 
1135  }
1136 
1137  /*fin cas4 */
1138  };
1139  if (i%2==0){
1140  if (condition1||condition2) isoler =i;
1141  }
1142 
1143  };
1144  lis= gen_nreverse(lis);
1145  i=-1;
1146  lisp=lis;
1147  FOREACH(STATEMENT,s,lis)
1148  {
1149  i++;if((i!=isoler)&&(i%2==0)&&(i!=isoler2)) {
1150  if(i==0) {
1151  CHUNK( CAR(lisp))= (gen_chunk *) make_block_statement(NIL);
1152  range_lower(loop_range(tab_loop[i+1]))=
1153  int_to_expression( sommetg[(i+1)/2]);
1154  }
1155  else{
1156  if(i==2*nbr_vertice-2){
1157  CHUNK( CAR(lisp))= (gen_chunk *) make_block_statement(NIL);
1158  range_upper(loop_range(tab_loop[i-1]))=
1159  int_to_expression(sommetg[(i-1)/2+1]);
1160  }
1161  else{
1162  body1=loop_body(tab_loop[i]);
1163  ins =statement_instruction(body1);
1164  seq=instruction_sequence(ins);
1165  lisi =sequence_statements(seq);
1167  loop2 =s1; },lisi) ;
1168  ins =statement_instruction(loop2);
1169  range1=loop_range(instruction_loop(ins));
1170  body1=loop_body(tab_loop[i-1]);
1171  ins =statement_instruction(body1);
1172  seq=instruction_sequence(ins);
1173  lisi =sequence_statements(seq);
1175  loop2 =s1; },lisi) ;
1176  ins =statement_instruction(loop2);
1177  range2=loop_range(instruction_loop(ins));
1178  body1=loop_body(tab_loop[i+1]);
1179  ins =statement_instruction(body1);
1180  seq=instruction_sequence(ins);
1181  lisi =sequence_statements(seq);
1183  loop2 =s1; },lisi) ;
1184  ins =statement_instruction(loop2);
1185  range3=loop_range(instruction_loop(ins));
1186  if (range_equal_p(range1,range2)) {
1187  CHUNK( CAR(lisp))= (gen_chunk *) make_block_statement(NIL);
1188  range_upper(loop_range(tab_loop[i-1]))=
1189  int_to_expression( sommetg[(i-1)/2+1]);
1190  }
1191  else {
1192  CHUNK( CAR(lisp))= (gen_chunk *) make_block_statement(NIL);
1193  if (range_equal_p(range1,range3))
1194  range_lower(loop_range(tab_loop[i+1]))=
1195  int_to_expression( sommetg[(i+1)/2]);
1196  }
1197  };
1198  };
1199 
1200  };
1201  lisp=CDR(lisp);
1202  }
1203  seq=make_sequence (lis);
1204  ins= make_instruction_sequence(seq);
1205  return( instruction_to_statement(ins));
1206 }
instruction make_instruction_loop(loop _field_)
Definition: ri.c:1175
call make_call(entity a1, list a2)
Definition: ri.c:269
loop copy_loop(loop p)
LOOP.
Definition: ri.c:1265
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
instruction make_instruction_sequence(sequence _field_)
Definition: ri.c:1169
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
sequence make_sequence(list a)
Definition: ri.c:2125
struct _newgen_struct_expression_ * expression
Definition: alias_private.h:21
#define value_direct_multiply(v1, v2)
int Value
#define value_plus(v1, v2)
binary operators on values
#define value_abs(val)
#define value_div(v1, v2)
static list lexp
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
bool egalite_equal(Pcontrainte, Pcontrainte)
bool egalite_equal(Pcontrainte eg1, Pcontrainte eg2): teste l'equivalence de deux egalites; leurs coe...
Definition: predicats.c:98
#define CHUNK(x)
Definition: genC.h:90
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_concatenate(const list l1x, const list l2x)
concatenate two lists.
Definition: list.c:436
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
Psysteme sc_newbase
include <sys/ddi.h>
bool if2
Ptsg sg
static Value eval2(Value val0, Value val1, Value val2, Value val)
bool if1
bool vect_equal(Pvecteur v1, Pvecteur v2)
bool vect_equal(Pvecteur v1, Pvecteur v2): test a egalite de deux vecteurs
Definition: reductions.c:278
bool vect_oppos(Pvecteur v1, Pvecteur v2)
bool vect_oppos(Pvecteur v1, Pvecteur v2): test de l'opposition de deux vecteurs
Definition: reductions.c:360
loop loop1
tiling_sequence.c
struct _newgen_struct_range_ * range
Definition: message.h:21
void normalize_all_expressions_of(void *obj)
Definition: normalize.c:668
static void norm(struct rproblem *RR)
cette procedure normalise la fonction cout, calcule les valeurs des seconds membres resultant d'une n...
Definition: r1.c:271
#define eq_expression(e1, e2)
#define MODULO_OPERATOR_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression Pvecteur_to_expression(Pvecteur vect)
AP, sep 25th 95 : some usefull functions moved from static_controlize/utils.c.
Definition: expression.c:1825
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
expression make_contrainte_expression(Pcontrainte pc, Variable index)
A wrapper around make_constraint_expression() for compatibility.
Definition: expression.c:1815
bool range_equal_p(range r1, range r2)
Definition: expression.c:1522
#define loop_body(x)
Definition: ri.h:1644
#define normalized_undefined
Definition: ri.h:1745
#define instruction_loop_p(x)
Definition: ri.h:1518
#define range_upper(x)
Definition: ri.h:2290
#define instruction_loop(x)
Definition: ri.h:1520
@ is_syntax_call
Definition: ri.h:2693
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
struct _newgen_struct_call_ * call
Definition: ri.h:63
#define expression_normalized(x)
Definition: ri.h:1249
struct _newgen_struct_syntax_ * syntax
Definition: ri.h:407
#define test_true(x)
Definition: ri.h:2835
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514
#define syntax_call(x)
Definition: ri.h:2736
#define test_condition(x)
Definition: ri.h:2833
#define range_lower(x)
Definition: ri.h:2288
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define call_arguments(x)
Definition: ri.h:711
#define instruction_test(x)
Definition: ri.h:1517
#define normalized_linear(x)
Definition: ri.h:1781
#define expression_syntax(x)
Definition: ri.h:1247
#define loop_index(x)
Definition: ri.h:1640
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
int printf()
s1
Definition: set.c:247
#define sg_sommets(sg)
vieilles definitions des fonctions d'impression void sg_fprint(); #define print_sg(sg) sg_fprint(stdo...
Definition: sg-local.h:85
#define sg_nbre_sommets(sg)
nombre de sommets: int sg_nbre_sommets(Ptsg)
Definition: sg-local.h:96
Pvecteur vecteur
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
structure de donnees Sommet
Definition: sommet-local.h:64
struct typ_som * succ
Definition: sommet-local.h:68
Pvecteur vecteur
Definition: sommet-local.h:66
Value denominateur
Definition: sommet-local.h:67
A gen_chunk is used to store every object.
Definition: genC.h:58
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
Definition: binaires.c:75
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
Definition: unaires.c:106
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...
Definition: unaires.c:143

References call_arguments, CAR, CDR, CHUNK, CONS, contrainte_make(), contrainte_vecteur, copy_loop(), copy_statement(), typ_som::denominateur, egalite_equal(), entity_intrinsic(), eq_expression, eval2(), exp, EXPRESSION, expression_normalized, expression_syntax, FOREACH, gen_concatenate(), gen_full_copy_list(), gen_last(), gen_nreverse(), if1, if2, Ssysteme::inegalites, instruction_loop, instruction_loop_p, instruction_sequence, instruction_test, instruction_to_statement(), int_to_expression(), is_syntax_call, lexp, loop1, loop_body, loop_index, loop_range, make_block_statement(), make_call(), make_contrainte_expression(), make_expression(), make_instruction_loop(), make_instruction_sequence(), make_sequence(), make_syntax(), MAP, MODULO_OPERATOR_NAME, NIL, norm(), normalize_all_expressions_of(), normalized_linear, normalized_undefined, printf(), Pvecteur_to_expression(), range_equal_p(), range_lower, range_upper, s1, sc_newbase, sequence_statements, sg, sg_nbre_sommets, sg_sommets, STATEMENT, statement_instruction, Scontrainte::succ, typ_som::succ, syntax_call, TCST, test_condition, test_true, value_abs, value_direct_multiply, value_div, value_plus, vect_add_elem(), vect_chg_coeff(), vect_coeff(), vect_dup(), vect_equal(), vect_erase_var(), vect_oppos(), vect_substract(), Scontrainte::vecteur, typ_som::vecteur, and VECTEUR_NUL.

Referenced by guard_elimination().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ guard_elimination()

bool guard_elimination ( string  module)

set_ordering_to_statement(stat);

MAP(STATEMENT,s,{printf("%d \n",statement_ordering(s));},lis)

gen_recurse(stat, statement_domain, gen_true,);

Parameters
moduleodule

Definition at line 1208 of file guard_elimination.c.

1209 {
1210 
1211  statement stat,s1;
1212  string str ;
1213  int ordering ;
1214  instruction ins;
1215  sequence seq;
1216  list lis;
1217  context_t context;
1218  debug_on("GUARD_ELIMINATION_DEBUG_LEVEL");
1219  pips_debug(1, "considering module %s\n", module);
1221  stat = (statement) db_get_memory_resource(DBR_CODE, module, true);
1223  context.statement_stack = stack_make(statement_domain, 0, 0);
1224 
1225  // user_request
1226  // recherche le statement dans stat
1227  // appliquer...
1228 
1229  /* set_ordering_to_statement(stat); */
1230  ins=statement_instruction(stat);
1231  seq=instruction_sequence(ins);
1232  lis =sequence_statements(seq);
1233  /* MAP(STATEMENT,s,{printf("%d \n",statement_ordering(s));},lis) */
1234 
1235  str = user_request("Which nid do you want to treat?\n"
1236  "(give its ordering): ");
1237  ordering=atoi(str);
1238 
1239 
1240  s1=ordering_to_statement(ordering);
1241 
1245  NULL);
1246  str = user_request("for Which nid do you want apply unimodular "
1247  "transformation ?\n" "(give its ordering): ");
1248  ordering=atoi(str);
1249 
1250  s1=ordering_to_statement(ordering);
1251  MAP(STATEMENT,s,{if (statement_ordering(s)==ordering){
1252  s1=unimodular(s1); ; s1= free_guards(s1);
1253  CHUNK(CAR(lis))= (gen_chunk *) s1;}
1254  ;lis=CDR(lis) ;},lis)
1255 
1256 
1257 
1258 
1259  /* gen_recurse(stat, statement_domain, gen_true,); */
1260  module_reorder(stat);
1261 
1262  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module, stat);
1265  debug_off();
1266  return true;
1267 }
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
static bool stmt_flt(statement s, context_p context)
statement free_guards(statement s)
statement unimodular(s)
static void stmt_rwt(statement s, context_p context)
static bool loop_flt(loop l, context_p context)
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
string user_request(const char *,...)
stack stack_make(int, int, int)
allocation
Definition: stack.c:246
statement ordering_to_statement(int o)
Get the statement associated to a given ordering.
Definition: ordering.c:111
static char * module
Definition: pips.c:74
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define statement_ordering(x)
Definition: ri.h:2454
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
cette structure contient une pile.
Definition: delay.c:253

References CAR, CDR, CHUNK, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, free_guards(), gen_context_multi_recurse(), gen_null(), instruction_sequence, local_name_to_top_level_entity(), loop_domain, loop_flt(), MAP, module, module_reorder(), ordering_to_statement(), pips_debug, reset_current_module_entity(), reset_current_module_statement(), s1, sequence_statements, set_current_module_entity(), set_current_module_statement(), stack_make(), STATEMENT, statement_domain, statement_instruction, statement_ordering, stmt_flt(), stmt_rwt(), unimodular(), and user_request().

+ Here is the call graph for this function:

◆ Hierarchical_tiling()

statement Hierarchical_tiling ( void  )

Definition at line 1021 of file tiling_sequence.c.

1022 {
1023  FILE *infp;
1024  char *name_file;
1025  Pmatrix A,P;
1026  int rw,cl,i,j;
1027  list lis=NULL;
1028  instruction ins;
1029  sequence seq=NULL;
1030  statement s,s1;
1031  loop ls=NULL;
1032  cons *lls=NULL;
1033  Pbase base_oldindex = NULL;
1034  Pbase base_newindex = NULL;
1035  Pbase pb;
1036  expression upper=NULL,lower=NULL;
1037  int plus;
1038  Value elem_mat1,elem_mat2;
1040  name_file = user_request("nom du fichier pour la matrice A ");
1041  infp = safe_fopen(name_file,"r");
1042  matrix_fscan(infp,&A,&rw,&cl);
1043  name_file = user_request("nom du fichier pour la matrice P ");
1044  infp = safe_fopen(name_file,"r");
1045  matrix_fscan(infp,&P,&cl,&cl);
1046  matrix_print(A);
1047  matrix_print(P);
1050  ls=loop1;
1051  for(j=0;j<=depth-1;j++)
1052  {
1053  range range1;
1054  range1=loop_range(ls);
1055  range_lower(range1)=int_to_expression(tiled_nest[j].lower);
1056  range_upper(range1)= int_to_expression(tiled_nest[j].upper);
1058  };
1061  lls = CONS(STATEMENT,s1,lls);
1063  }
1064  (void)loop_iteration_domaine_to_sc(lls, &base_oldindex);
1065 
1066  derive_new_basis_deux(base_oldindex, &base_newindex , make_tile_index_entity_n);
1067  tiling_indice= ( Pvecteur *)malloc(depth *sizeof( Pvecteur*));
1068  plus=depth*3-1;
1069  for (pb =base_newindex; pb!=NULL; pb=pb->succ) {
1070  loop tl;
1071  switch(plus%3)
1072  {
1073  case 2:
1074  {
1075  elem_mat1=MATRIX_ELEM(A,plus/3+1,plus);
1076  elem_mat2=MATRIX_ELEM(A,plus/3+1,plus+1);
1077  upper= int_to_expression(value_minus(elem_mat1,VALUE_ONE));
1078  lower= int_to_expression(0);
1080  };
1081  break;
1082  case 1:
1083  {
1084  elem_mat1=MATRIX_ELEM(A,plus/3+1,plus) ;
1085  elem_mat2=MATRIX_ELEM(A,plus/3+1,plus+1 ) ;
1086  upper= int_to_expression(value_minus(value_div(elem_mat1,elem_mat2),VALUE_ONE));
1087  lower= int_to_expression(0);
1088  tiling_indice[plus/3]=vect_make( tiling_indice[plus/3],pb->var , elem_mat2,TCST,VALUE_ZERO);
1089  };
1090  break;
1091  case 0:
1092  {
1093  elem_mat1=MATRIX_ELEM(A,plus/3+1,plus+1);
1094  upper= int_to_expression(value_div(tiled_nest[plus/3].upper,elem_mat1));
1095  lower= int_to_expression(0);
1096  tiling_indice[plus/3]=vect_make( tiling_indice[plus/3],pb->var ,elem_mat1,TCST,VALUE_ZERO);
1097  };
1098  default: break;
1099  }
1100  tl = make_loop((entity) vecteur_var(pb),
1102  int_to_expression(1)),
1103  s1,
1106  NIL);
1108  plus--;
1109  };
1110 
1111  printf(" azuuuul lalallalalal \n"); getchar();
1112 
1113  /******/
1114  for (i=k1-1;i>=0;i--)
1115  {
1116  expression e1,e2,e,gauche=NULL,droite=NULL,delai_plus;
1117  test t;
1118  call c;
1119  int m;
1120  Pvecteur pv;
1122  Value_to_expression( value_plus(sequen[i].nd[0].lower,
1123  MATRIX_ELEM( sequen[i].delai,1,1))));
1125  Value_to_expression( value_plus(sequen[i].nd[0].upper,
1126  MATRIX_ELEM( sequen[i].delai,1,1))));
1127  if (value_eq( value_plus(sequen[i].nd[0].lower,MATRIX_ELEM( sequen[i].delai,1,1)),tiled_nest[0].lower))
1128  {
1129  if (value_eq( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),tiled_nest[0].upper)&&
1130  value_eq(value_mod( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),
1131  MATRIX_ELEM(A,1,1)),VALUE_ZERO))
1132  e=NULL;
1133  else
1134  e=e2;
1135  }
1136  else
1137  {
1138  if (value_eq( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),tiled_nest[0].upper)&&
1139  value_eq(value_mod( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),
1140  MATRIX_ELEM(A,1,1)),VALUE_ZERO))
1141  e=e1;
1142 
1143  else
1144  e=and_expression(e1,e2);
1145 
1146  };
1147 
1148  for(j=0;j<=depth-1;j++)
1149  {
1150 
1151  if (j>=1)
1152  {
1153 
1154 
1156 
1157 
1159  Value_to_expression(value_plus(sequen[i].nd[j].lower,
1160  MATRIX_ELEM( sequen[i].delai,j+1,1))));
1161 
1163  Value_to_expression( value_plus(sequen[i].nd[j].upper,
1164  MATRIX_ELEM( sequen[i].delai,j+1,1))));
1165 
1166  if (value_eq( value_plus(sequen[i].nd[j].lower,MATRIX_ELEM( sequen[i].delai,j+1,1)),tiled_nest[j].lower))
1167  {
1168  if (! (value_eq(value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),tiled_nest[j].upper)&&
1169  value_eq(value_mod( value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),
1170  MATRIX_ELEM(A,j+1,3*j+1)),VALUE_ZERO)))
1171  {
1172  if (e==NULL)
1173  e=e2;
1174  else
1175  e=and_expression(e,e2);
1176  };
1177  }
1178  else
1179  {
1180  if (value_eq(value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),tiled_nest[j].upper)&&
1181  value_eq(value_mod( value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),
1182  MATRIX_ELEM(A,j+1,3*j+1)),VALUE_ZERO))
1183  {
1184  if (e==NULL)
1185  e=e1;
1186  else
1187  e=and_expression(e,e1);
1188  }
1189  else
1190  {
1191  e1=and_expression(e1,e2);
1192  if(e==NULL)
1193  e=e1;
1194  else
1195  e=and_expression(e,e1);
1196  }
1197  };
1198 
1199 
1200  };
1202  m=0;
1203  MAP(EXPRESSION,exp,{
1204  if (m==0) gauche=exp;
1205  if (m==1) droite=exp;
1206  m++;
1207  },call_arguments(c)) ;
1208  pv = vect_make(tiling_indice[j],TCST,value_uminus(MATRIX_ELEM(sequen[i].delai,j+1,1)));
1209  delai_plus=Pvecteur_to_expression(pv);
1210  replace_entity_by_expression(gauche,(entity) sequen[i].nd[j].index,delai_plus);
1212  replace_entity_by_expression(exp,(entity) sequen[i].nd[j].index,delai_plus);
1213  };
1215  s=test_to_statement(t);
1216  if(i==k1-1) lis=CONS(STATEMENT,s,NIL);
1217  else lis=CONS(STATEMENT,s,lis);
1218  };
1219  seq= make_sequence(lis);
1220  ins= make_instruction_sequence(seq);
1221  s= instruction_to_statement(ins);
1223  for(j=0;j<=3*depth-1;j++)
1225  else loop_body(ls)=s;
1226  s1=permutation(s1,P);
1227  return s1;
1228 }
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
#define VALUE_ZERO
#define value_minus(v1, v2)
#define value_uminus(val)
unary operators on values
#define value_eq(v1, v2)
bool operators on values
#define VALUE_ONE
#define value_mod(v1, v2)
#define A(i, j)
comp_matrice.c
Definition: comp_matrice.c:63
Psysteme loop_iteration_domaine_to_sc(list, Pbase *)
loop_iteration_domaine_to_sc.c
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
void * malloc(YYSIZE_T)
void replace_entity_by_expression(void *s, entity ent, expression exp)
replace all reference to entity ent by expression exp in s.
Definition: replace.c:220
#define MATRIX_ELEM(matrix, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrix-local.h:80
void matrix_print(Pmatrix)
void matrix_print(matrice a): print an (nxm) rational matrix
Definition: matrix_io.c:70
void matrix_fscan(FILE *, Pmatrix *, int *, int *)
void matrix_fscan(FILE * f, matrice * a, int * n, int * m): read an (nxm) rational matrix in an ASCII...
Definition: matrix_io.c:93
#define UU
Definition: newgen_types.h:98
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
Definition: expression.c:58
#define loop_to_statement(l)
#define test_to_statement(t)
#define and_expression(e1, e2)
#define ge_expression(e1, e2)
#define le_expression(e1, e2)
entity entity_empty_label(void)
Definition: entity.c:1105
expression Value_to_expression(Value v)
added interface for linear stuff.
Definition: expression.c:1251
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_call(x)
Definition: ri.h:1529
@ is_execution_sequential
Definition: ri.h:1189
Definition: pip__tab.h:25
package matrice
Definition: matrix-local.h:63
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
static entity make_tile_index_entity_n(entity old_index, char *su)
statement permutation(statement s, Pmatrix P)
loop loop1
le nid fusionne
static Pvecteur * tiling_indice
static nid sequen[nid_nbr]
k1 represente le nombre de nid et k2 leur profondeur
static void compute_bound_tiled_nest()
static info_loop * tiled_nest
static int depth
la sequence de nids
static int k1
static void compute_delay_tiled_nest()
static void derive_new_basis_deux(Pbase base_oldindex, Pbase *base_newindex, entity(*new_entity)(entity, char *))
#define vecteur_var(v)
Pvecteur vect_make(Pvecteur v, Variable var, Value val,...)
Pvecteur vect_make(v, [var, val,]* 0, val) Pvecteur v; // may be NULL, use assigne anyway Variable va...
Definition: alloc.c:165

References A, and_expression, call_arguments, compute_bound_tiled_nest(), compute_delay_tiled_nest(), CONS, copy_expression(), depth, derive_new_basis_deux(), entity_empty_label(), exp, EXPRESSION, expression_syntax, FOREACH, ge_expression, INFO_LOOP::index, instruction_call, instruction_loop, instruction_loop_p, instruction_to_statement(), int_to_expression(), is_execution_sequential, is_instruction_loop, k1, le_expression, loop1, loop_body, loop_iteration_domaine_to_sc(), loop_range, loop_to_statement, INFO_LOOP::lower, make_block_statement(), make_execution(), make_instruction(), make_instruction_sequence(), make_loop(), make_range(), make_sequence(), make_test(), make_tile_index_entity_n(), malloc(), MAP, MATRIX_ELEM, matrix_fscan(), matrix_print(), NIL, permutation(), print_expression(), printf(), Pvecteur_to_expression(), range_lower, range_upper, replace_entity_by_expression(), s1, safe_fopen(), sequen, STATEMENT, statement_instruction, Svecteur::succ, syntax_call, TCST, test_to_statement, tiled_nest, tiling_indice, INFO_LOOP::upper, user_request(), UU, value_div, value_eq, value_minus, value_mod, VALUE_ONE, value_plus, Value_to_expression(), value_uminus, VALUE_ZERO, Svecteur::var, vect_make(), VECTEUR_NUL, and vecteur_var.

Referenced by tiling_sequence().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loop_statistics()

bool loop_statistics ( const  string)

cproto-generated files

stats.c

Parameters
stringame

Definition at line 450 of file stats.c.

451 {
452  statement stat;
453  string filename, localfilename;
455 
456  debug_on("STATISTICS_DEBUG_LEVEL");
457  pips_debug(1, "considering module %s\n", name);
459 
460  initialize() ;
461 
462  stat = (statement) db_get_memory_resource(DBR_CODE, name, true);
463 
464  context.contenu = hash_table_make(hash_pointer, 0);
466  context.statement_stack = stack_make(statement_domain, 0, 0);
467 
468 
470  (stat, & context,
479  NULL);
480 
481 
482  hash_table_free(context.contenu);
483 
484 
485  hash_table_free(context.depth);
486  stack_free(&context.statement_stack);
487 
488  localfilename = db_build_file_resource_name(DBR_STATS_FILE,
489  name, ".loop_stats");
490 
492  "/", localfilename, NULL));
493 
494  put_result(filename);
497  free(filename);
498  DB_PUT_FILE_RESOURCE(DBR_STATS_FILE, name, localfilename);
500 
501 pips_debug(1, "done.\n");
502  debug_off();
503 
504  return true;
505 }
void free(void *)
bool gen_false(__attribute__((unused)) gen_chunk *unused)
Return false and ignore the argument.
Definition: genClib.c:2796
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
Definition: pipsdbm-local.h:85
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
string db_build_file_resource_name(const char *rname, const char *oname, const char *suffix)
returns an allocated file name for a file resource.
Definition: lowlevel.c:169
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
@ hash_pointer
Definition: newgen_hash.h:32
void stack_free(stack *)
type, bucket_size, policy
Definition: stack.c:292
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
#define test_domain
newgen_entity_domain_defined
Definition: ri.h:418
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define unstructured_domain
newgen_type_domain_defined
Definition: ri.h:442
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
#define whileloop_domain
newgen_variable_domain_defined
Definition: ri.h:466
#define sequence_domain
newgen_reference_domain_defined
Definition: ri.h:346
char * strdup()
static bool stmt_flt(statement s, context_p context)
Definition: stats.c:97
static int * nbr_perf_nest_loop_of_depth
Definition: stats.c:38
static void uns_rwt(unstructured u, context_p context)
Definition: stats.c:220
static int * nbr_no_perf_nest_loop_of_depth
include "statistics.h"
Definition: stats.c:38
static bool uns_flt(unstructured u, context_p context)
Definition: stats.c:215
static void stmt_rwt(statement s, context_p context)
Definition: stats.c:105
static void call_rwt(call ca, context_p context)
Definition: stats.c:383
static bool test_flt(test t, context_p context)
Definition: stats.c:276
static void loop_rwt(loop l, context_p context)
Definition: stats.c:61
static void put_result(string filename)
Definition: stats.c:423
static void seq_rwt(sequence sq, context_p context)
Definition: stats.c:121
static bool loop_flt(loop l, context_p context)
Definition: stats.c:54
static bool call_flt(call ca, context_p context)
Definition: stats.c:377
static void wl_rwt(whileloop w, context_p context)
Definition: stats.c:399
static void initialize()
Definition: stats.c:407
static bool seq_flt(sequence sq, context_p context)
Definition: stats.c:116
static void test_rwt(test t, context_p context)
Definition: stats.c:281

References call_domain, call_flt(), call_rwt(), concatenate(), db_build_file_resource_name(), db_get_current_workspace_directory(), db_get_memory_resource(), DB_PUT_FILE_RESOURCE, debug_off, debug_on, expression_domain, free(), gen_context_multi_recurse(), gen_false(), gen_null(), gen_true(), hash_pointer, hash_table_free(), hash_table_make(), initialize(), local_name_to_top_level_entity(), loop_domain, loop_flt(), loop_rwt(), nbr_no_perf_nest_loop_of_depth, nbr_perf_nest_loop_of_depth, pips_debug, put_result(), reset_current_module_entity(), seq_flt(), seq_rwt(), sequence_domain, set_current_module_entity(), stack_free(), stack_make(), statement_domain, stmt_flt(), stmt_rwt(), strdup(), test_domain, test_flt(), test_rwt(), uns_flt(), uns_rwt(), unstructured_domain, whileloop_domain, and wl_rwt().

+ Here is the call graph for this function:

◆ permutation()

statement permutation ( statement  s,
Pmatrix  P 
)

Definition at line 957 of file tiling_sequence.c.

960 {
961  statement scopy;
962  int i,j;
963  loop ls1,ls2;
964  bool found=false;
965  scopy=copy_statement(s);
967  for(i=1;i<=3*depth;i++)
968  {
969  j=1;
970  found=false;
972  while ((j<=3*depth)&& !found)
973  {
974  if (value_eq(MATRIX_ELEM(P,i,j),VALUE_ONE))
975  {
976  found =true;
977  loop_index(ls1)=loop_index(ls2);
978  loop_range(ls1)=loop_range(ls2);
979  };
981  j++;
982  };
984  }
985 
986  return scopy;
987 }

References copy_statement(), depth, instruction_loop, loop_body, loop_index, loop_range, MATRIX_ELEM, statement_instruction, value_eq, and VALUE_ONE.

Referenced by Hierarchical_tiling(), and Tiling2_buffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ permutation2()

statement permutation2 ( statement  s,
Pmatrix  P 
)

Definition at line 989 of file tiling_sequence.c.

992 {
993  statement scopy;
994  int i,j;
995  loop ls1,ls2;
996  bool found=false;
997  scopy=copy_statement(s);
999  for(i=1;i<=2*depth;i++)
1000  {
1001  j=1;
1002  found=false;
1004  while ((j<=2*depth)&& !found)
1005  {
1006  if (value_eq(MATRIX_ELEM(P,i,j),VALUE_ONE))
1007  {
1008  found =true;
1009  loop_index(ls1)=loop_index(ls2);
1010  loop_range(ls1)=loop_range(ls2);
1011  };
1013  j++;
1014  };
1016  }
1017 
1018  return scopy;
1019 }

References copy_statement(), depth, instruction_loop, loop_body, loop_index, loop_range, MATRIX_ELEM, statement_instruction, value_eq, and VALUE_ONE.

Referenced by Tiling_buffer_allocation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ position_one_element()

int position_one_element ( Pmatrix  P,
int  i 
)

Definition at line 1232 of file tiling_sequence.c.

1233 {
1234  int j;
1235  for (j=1;j<=depth;j++)
1236  if(MATRIX_ELEM(P,i,j)==VALUE_ONE) return j;
1237  pips_internal_error("asking for a non existing element");
1238  return -1;
1239 }
#define pips_internal_error
Definition: misc-local.h:149

References depth, MATRIX_ELEM, pips_internal_error, and VALUE_ONE.

Referenced by Tiling_buffer_allocation().

+ Here is the caller graph for this function:

◆ Tiling2_buffer()

statement Tiling2_buffer ( void  )

Definition at line 2265 of file tiling_sequence.c.

2266 {
2267  FILE *infp;
2268  char *name_file;
2269  Pmatrix A,A1,A2,P, P1,P2,P3;
2270  int rw,cl,i,j;
2271  list lis=NULL;
2272  instruction ins;
2273  sequence seq=NULL;
2274  statement s,s1,s2;
2275  loop ls=NULL;
2276  cons *lls=NULL;
2277  Pbase base_oldindex = NULL;
2278  Pbase base_newindex = NULL;
2279  Pbase pb;
2280  expression upper=NULL,lower=NULL;
2281  int plus;
2282  Value elem_mat1,elem_mat2;
2284  // void full_loop_unroll();
2285  name_file = user_request("nom du fichier pour la matrice A ");
2286  infp = safe_fopen(name_file,"r");
2287  matrix_fscan(infp,&A,&rw,&cl);
2288  name_file = user_request("nom du fichier pour la matrice P ");
2289  infp = safe_fopen(name_file,"r");
2290  matrix_fscan(infp,&P,&cl,&cl);
2291  matrix_print(A);
2292  matrix_print(P);
2293  P1=matrix_new(depth,depth);
2294  for(i=1;i<=depth;i++)
2295  for(j=1;j<=3*depth;j=j+3)
2296  {
2297  if ( value_eq(MATRIX_ELEM(P,i,j),VALUE_ONE))
2298  MATRIX_ELEM(P1,i,j/3+1)=VALUE_ONE;
2299  else
2300  MATRIX_ELEM(P1,i,j/3+1)=VALUE_ZERO;
2301  };
2302 
2303  P2=matrix_new(depth,depth);
2304  for(i=depth+1;i<=2*depth;i++)
2305  for(j=2;j<=3*depth;j=j+3)
2306  {
2307  if (value_eq(MATRIX_ELEM(P,i,j),VALUE_ONE))
2308  MATRIX_ELEM(P2,(i-1)%depth+1,j/3+1)=VALUE_ONE;
2309  else
2310  MATRIX_ELEM(P2,(i-1)%depth+1,j/3+1)=VALUE_ZERO;
2311  };
2312 
2313  P3=matrix_new(depth,depth);
2314  for(i=2*depth+1;i<=3*depth;i++)
2315  for(j=3;j<=3*depth;j=j+3)
2316  {
2317  if (value_eq(MATRIX_ELEM(P,i,j),VALUE_ONE))
2318  MATRIX_ELEM(P3,(i-1)%depth+1,j/3)=VALUE_ONE;
2319  else
2320  MATRIX_ELEM(P3,(i-1)%depth+1,j/3)=VALUE_ZERO;
2321  };
2322 
2323 
2324  A1=matrix_new(depth,1);
2325  for(i=0;i<=depth-1;i++)
2326  MATRIX_ELEM(A1,i+1,1)=MATRIX_ELEM(A,i+1,3*i+1);
2327 
2328  A2=matrix_new(depth,1);
2329  for(i=0;i<=depth-1;i++)
2330  MATRIX_ELEM(A2,i+1,1)=MATRIX_ELEM(A,i+1,3*i+2);
2331 
2332 
2333 
2334  matrix_print(P1);
2335  matrix_print(P2);
2336  matrix_print(P3);
2337  matrix_print(A1);
2338  matrix_print(A2);
2339 
2340  getchar();
2341  getchar();
2342 
2345  ls=loop1;
2346  for(j=0;j<=depth-1;j++)
2347  {
2348  range range1;
2349  range1=loop_range(ls);
2350  range_lower(range1)=int_to_expression(tiled_nest[j].lower);
2351  range_upper(range1)= int_to_expression(tiled_nest[j].upper);
2353  };
2356  lls = CONS(STATEMENT,s1,lls);
2358  }
2359  (void)loop_iteration_domaine_to_sc(lls, &base_oldindex);
2360 
2361  derive_new_basis_deux(base_oldindex, &base_newindex , make_tile_index_entity_n);
2362  tiling_indice= ( Pvecteur *)malloc(depth *sizeof( Pvecteur*));
2363  plus=depth*3-1;
2364  for (pb =base_newindex; pb!=NULL; pb=pb->succ) {
2365  loop tl;
2366  switch(plus%3)
2367  {
2368  case 2:
2369  {
2370  elem_mat1=MATRIX_ELEM(A,plus/3+1,plus);
2371  elem_mat2=MATRIX_ELEM(A,plus/3+1,plus+1);
2372  upper= int_to_expression(value_minus(elem_mat1,VALUE_ONE));
2373  lower= int_to_expression(0);
2375  };
2376  break;
2377  case 1:
2378  {
2379  elem_mat1=MATRIX_ELEM(A,plus/3+1,plus) ;
2380  elem_mat2=MATRIX_ELEM(A,plus/3+1,plus+1 ) ;
2381  upper= int_to_expression(value_minus(value_div(elem_mat1,elem_mat2),VALUE_ONE));
2382  lower= int_to_expression(0);
2383  tiling_indice[plus/3]=vect_make( tiling_indice[plus/3],pb->var , elem_mat2,TCST,VALUE_ZERO);
2384  };
2385  break;
2386  case 0:
2387  {
2388  elem_mat1=MATRIX_ELEM(A,plus/3+1,plus+1);
2389  upper= int_to_expression(value_div(tiled_nest[plus/3].upper,elem_mat1));
2390  lower= int_to_expression(0);
2391  tiling_indice[plus/3]=vect_make( tiling_indice[plus/3],pb->var ,elem_mat1,TCST,VALUE_ZERO);
2392  };
2393  default: break;
2394  }
2395  tl = make_loop((entity) vecteur_var(pb),
2397  int_to_expression(1)),
2398  s1,
2401  NIL);
2403  plus--;
2404  };
2405 
2406 
2407 
2408  /******/
2409  for (i=k1-1;i>=0;i--)
2410  {
2411  expression e1,e2,e,gauche=NULL,droite=NULL,delai_plus;
2412  test t;
2413  call c;
2414  int m;
2415  Pvecteur pv;
2417  Value_to_expression( value_plus(sequen[i].nd[0].lower,
2418  MATRIX_ELEM( sequen[i].delai,1,1))));
2420  Value_to_expression( value_plus(sequen[i].nd[0].upper,
2421  MATRIX_ELEM( sequen[i].delai,1,1))));
2422  if (value_eq( value_plus(sequen[i].nd[0].lower,MATRIX_ELEM( sequen[i].delai,1,1)),tiled_nest[0].lower))
2423  {
2424  if (value_eq( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),tiled_nest[0].upper)&&
2425  value_eq(value_mod( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),
2426  MATRIX_ELEM(A,1,1)),VALUE_ZERO))
2427  e=NULL;
2428  else
2429  e=e2;
2430  }
2431  else
2432  {
2433  if (value_eq( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),tiled_nest[0].upper)&&
2434  value_eq(value_mod( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),
2435  MATRIX_ELEM(A,1,1)),VALUE_ZERO))
2436  e=e1;
2437 
2438  else
2439  e=and_expression(e1,e2);
2440 
2441  };
2442  for(j=0;j<=depth-1;j++)
2443  {
2444  if (j>=1)
2445  {
2447  Value_to_expression(value_plus(sequen[i].nd[j].lower,
2448  MATRIX_ELEM( sequen[i].delai,j+1,1))));
2450  Value_to_expression( value_plus(sequen[i].nd[j].upper,
2451  MATRIX_ELEM( sequen[i].delai,j+1,1))));
2452  if (value_eq( value_plus(sequen[i].nd[j].lower,MATRIX_ELEM( sequen[i].delai,j+1,1)),tiled_nest[j].lower))
2453  {
2454  if (! (value_eq(value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),tiled_nest[j].upper)&&
2455  value_eq(value_mod( value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),
2456  MATRIX_ELEM(A,j+1,3*j+1)),VALUE_ZERO)))
2457  {
2458  if (e==NULL)
2459  e=e2;
2460  else
2461  e=and_expression(e,e2);
2462  };
2463  }
2464  else
2465  {
2466  if (value_eq(value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),tiled_nest[j].upper)&&
2467  value_eq(value_mod( value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),
2468  MATRIX_ELEM(A,j+1,3*j+1)),VALUE_ZERO))
2469  {
2470  if (e==NULL)
2471  e=e1;
2472  else
2473  e=and_expression(e,e1);
2474  }
2475  else
2476  {
2477  e1=and_expression(e1,e2);
2478  if(e==NULL)
2479  e=e1;
2480  else
2481  e=and_expression(e,e1);
2482  }
2483  };
2484  };
2486  m=0;
2487  MAP(EXPRESSION,exp,{
2488  if (m==0) gauche=exp;
2489  if (m==1) droite=exp;
2490  m++;
2491  },call_arguments(c)) ;
2492  pv = vect_make(tiling_indice[j],TCST,value_uminus(MATRIX_ELEM(sequen[i].delai,j+1,1)));
2493  delai_plus=Pvecteur_to_expression(pv);
2494  replace_entity_by_expression(gauche,(entity) sequen[i].nd[j].index,delai_plus);
2496  replace_entity_by_expression(exp,(entity) sequen[i].nd[j].index,delai_plus);
2497  };
2499  s=test_to_statement(t);
2500  if(i==k1-1) lis=CONS(STATEMENT,s,NIL);
2501  else lis=CONS(STATEMENT,s,lis);
2502  };
2503  seq= make_sequence(lis);
2504  ins= make_instruction_sequence(seq);
2505  s= instruction_to_statement(ins);
2507  for(j=0;j<=3*depth-1;j++)
2509  else loop_body(ls)=s;
2510  s1=permutation(s1,P);
2511 
2512  i=1;
2513  s2=s1;
2514  while (i <=2*depth)
2515  {
2516  printf(" %d \n", i);
2518  i++;
2519  }
2520  print_statement(s2);
2521  printf(" tptpto \n");
2522  unroll_recursive(s2,depth);
2523 
2524 
2525  return s1;
2526 }
Pmatrix matrix_new(int m, int n)
package matrix
Definition: alloc.c:41
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
static void unroll_recursive(statement s, int n)

References A, and_expression, call_arguments, compute_bound_tiled_nest(), compute_delay_tiled_nest(), CONS, copy_expression(), depth, derive_new_basis_deux(), entity_empty_label(), exp, EXPRESSION, expression_syntax, FOREACH, ge_expression, INFO_LOOP::index, instruction_call, instruction_loop, instruction_loop_p, instruction_to_statement(), int_to_expression(), is_execution_sequential, is_instruction_loop, k1, le_expression, loop1, loop_body, loop_iteration_domaine_to_sc(), loop_range, loop_to_statement, INFO_LOOP::lower, make_block_statement(), make_execution(), make_instruction(), make_instruction_sequence(), make_loop(), make_range(), make_sequence(), make_test(), make_tile_index_entity_n(), malloc(), MAP, MATRIX_ELEM, matrix_fscan(), matrix_new(), matrix_print(), NIL, permutation(), print_statement(), printf(), Pvecteur_to_expression(), range_lower, range_upper, replace_entity_by_expression(), s1, safe_fopen(), sequen, STATEMENT, statement_instruction, Svecteur::succ, syntax_call, TCST, test_to_statement, tiled_nest, tiling_indice, unroll_recursive(), INFO_LOOP::upper, user_request(), UU, value_div, value_eq, value_minus, value_mod, VALUE_ONE, value_plus, Value_to_expression(), value_uminus, VALUE_ZERO, Svecteur::var, vect_make(), VECTEUR_NUL, and vecteur_var.

Referenced by tiling_sequence().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Tiling_buffer_allocation()

statement Tiling_buffer_allocation ( void  )

gauche=NULL,droite=NULL

Definition at line 1242 of file tiling_sequence.c.

1243 {
1244  FILE *infp;
1245  char *name_file;
1246  Pmatrix A,P,ATE,ATEP,ATEPP,P1,P2,N[nid_nbr],NP[nid_nbr],G_PRO[nid_nbr], G_PROP[nid_nbr],G_PROPP[nid_nbr];
1247  int rw,cl,i,j,k,pos;
1248  list lis=NULL,lis1=NULL,lis2=NULL;
1249  instruction ins;
1250  sequence seq=NULL;
1251  statement s, s1, sequenp[nid_nbr],
1252  ps1 = statement_undefined, ps2 = statement_undefined /*,*pst1*/;
1253  loop ls=NULL;
1254  cons *lls=NULL;
1255  Pbase base_oldindex = NULL;
1256  Pbase base_newindex = NULL;
1257  Pbase pb;
1258  expression upper=NULL,lower=NULL,exp=NULL;
1259  int plus;
1260  Value elem_mat1,elem_mat2;
1261  entity *ref[nid_nbr],name;
1262  reference *buf_ref[nid_nbr];
1263  statement *scopy[nid_nbr];
1265  Variable *iter, *itert;
1266  name_file = user_request("nom du fichier pour la matrice A ");
1267  infp = safe_fopen(name_file,"r");
1268  matrix_fscan(infp,&A,&rw,&cl);
1269  name_file = user_request("nom du fichier pour la matrice P ");
1270  infp = safe_fopen(name_file,"r");
1271  matrix_fscan(infp,&P,&cl,&cl);
1274  P1=matrix_new(depth,depth);
1275 
1276  for(i=1;i<=depth;i++)
1277  for(j=1;j<=2*depth;j=j+2)
1278  {
1279  if ( value_eq(MATRIX_ELEM(P,i,j),VALUE_ONE))
1280  MATRIX_ELEM(P1,i,j/2+1)=VALUE_ONE;
1281  else
1282  MATRIX_ELEM(P1,i,j/2+1)=VALUE_ZERO;
1283  };
1284 
1285 
1286  P2=matrix_new(depth,depth);
1287  for(i=depth+1;i<=2*depth;i++)
1288  for(j=2;j<=2*depth;j=j+2)
1289  {
1290  if (value_eq(MATRIX_ELEM(P,i,j),VALUE_ONE))
1291  MATRIX_ELEM(P2,(i-1)%depth+1,j/2)=VALUE_ONE;
1292  else
1293  MATRIX_ELEM(P2,(i-1)%depth+1,j/2)=VALUE_ZERO;
1294  };
1295 
1296  ATE=matrix_new(depth,1);
1297  for(i=0;i<=depth-1;i++)
1298  MATRIX_ELEM(ATE,i+1,1)=MATRIX_ELEM(A,i+1,2*i+1);
1299 
1300  ATEP=matrix_new(depth,1);
1301  matrix_multiply(P1,ATE,ATEP);
1302  ATEPP=matrix_new(depth,1);
1303  matrix_multiply(P2,ATE,ATEPP);
1304 
1305 
1306 
1307 
1310  lls = CONS(STATEMENT,s1,lls);
1312  }
1313 
1314  (void)loop_iteration_domaine_to_sc(lls, &base_oldindex);
1315  derive_new_basis_une(base_oldindex, &base_newindex , make_tile_index_entity_n);
1316 
1317  iter= ( Variable *)malloc(depth *sizeof( Variable));
1318  itert=( Variable *)malloc(depth *sizeof( Variable));
1319  i=2*depth-1;
1320  for (pb =base_newindex; pb!=NULL; pb=pb->succ) {
1321  if (i%2==1) iter[i/2]=(pb->var);
1322  else itert[i/2]=(pb->var);
1323  i--;
1324  };
1325 
1326 
1327  for(i=0;i<=k1-1;i++)
1328  {
1329  //statement s1;
1330  sequence seq;
1331  instruction ins;
1332 
1333  Pvecteur pv;
1334  Value con;
1336  test t;
1337  statement s;
1338  call c;
1339  int m;
1340 
1341  N[i]=matrix_new(depth,1);
1342  for (j=1;j<=depth;j++)
1343  MATRIX_ELEM(N[i],j,1)= value_plus(value_minus(sequen[i].nd[j-1].upper,sequen[i].nd[j-1].lower),VALUE_ONE);
1344  NP[i]=matrix_new(depth,1);
1345  matrix_multiply(P1,N[i],NP[i]);
1346 
1347  if (i<=k1-2)
1348  {
1349 
1350 
1351  lis2=NULL;
1352  G_PRO[i]=matrix_new(depth,1);
1353  for(j=1;j<=depth;j++)
1354  {
1355 
1356  Value temp;
1357 
1358  temp=value_minus(MATRIX_ELEM(sequen[i+1].delai,j,1),MATRIX_ELEM(sequen[i].delai,j,1));
1359  MATRIX_ELEM( G_PRO[i],j,1)=value_minus(temp, MATRIX_ELEM(sequen[i+1].st[0],j,1));
1360  for(k=1;k<=sequen[i].nbr_stencil-1;k++)
1361  {
1362  if (MATRIX_ELEM( G_PRO[i],j,1)< value_minus(temp, MATRIX_ELEM(sequen[i].st[k],j,1)))
1363  MATRIX_ELEM( G_PRO[i],j,1)=value_minus(temp, MATRIX_ELEM(sequen[i].st[k],j,1));
1364  };
1365  };
1366 
1367  G_PROP[i]=matrix_new(depth,1);
1368  matrix_multiply(P1,G_PRO[i],G_PROP[i]);
1369  G_PROPP[i]=matrix_new(depth,1);
1370  matrix_multiply(P2,G_PRO[i],G_PROPP[i]);
1371  ref[i]= ( entity *)malloc((depth+1) *sizeof( entity));
1372  buf_ref[i]=( reference *)malloc((depth+1) *sizeof( reference));
1373  scopy[i]=( statement *)malloc((depth+1) *sizeof( statement));
1374 
1375  for(j=1;j<=depth;j++)
1376  {
1377 
1378  lis= NULL;
1379  lis1=NULL;
1380 
1382  int_to_expression(1),
1383  NIL),
1384  lis);
1385  pos=position_one_element(P1,j);
1386  pv= vect_make(VECTEUR_NUL ,itert[pos-1], VALUE_ONE,TCST,VALUE_ZERO);
1388  lis1 =CONS(EXPRESSION, exp,lis1);
1389 
1390  for (k=1;k<=j-1;k++)
1391  {
1392 
1393  lis=CONS(DIMENSION,
1396  (MATRIX_ELEM(ATEP,k,1),VALUE_ONE)),
1397  NIL),
1398  lis);
1399  pos=position_one_element(P1,k);
1400  pv= vect_make(VECTEUR_NUL ,iter[pos-1], VALUE_ONE,TCST,VALUE_ZERO);
1402 
1403  lis1 =CONS(EXPRESSION, exp,lis1);
1404  }
1405 
1406  if (value_minus (MATRIX_ELEM(G_PROP[i],j,1),VALUE_ONE)==VALUE_MONE)
1407  {
1408 
1409  cavite=int_to_expression(0);
1410  }
1411 
1412  else
1413  {
1414 
1415  cavite =Value_to_expression(value_minus (MATRIX_ELEM(G_PROP[i],j,1),VALUE_ONE));
1416  };
1417  lis=CONS(DIMENSION,
1419  cavite,
1420  NIL),
1421  lis);
1422  pos=position_one_element(P1,k);
1423  con=value_minus(MATRIX_ELEM(G_PRO[i],pos,1), MATRIX_ELEM(ATE,pos,1));
1424  pv= vect_make(VECTEUR_NUL ,iter[pos-1], VALUE_ONE,TCST,con);
1425 
1427 
1428  lis1 =CONS(EXPRESSION, exp,lis1);
1429  for (k=j+1;k<=depth;k++)
1430  {
1431  Value v1;
1432  lis=CONS(DIMENSION,
1435  (MATRIX_ELEM(NP[i],k,1), VALUE_ONE)),
1436  NIL),
1437  lis);
1438  pos=position_one_element(P1,k);
1439  v1=sequen[i].nd[pos-1].lower+MATRIX_ELEM( sequen[i].delai,pos,1 );
1440 
1441 
1442  pv= vect_make(VECTEUR_NUL ,iter[pos-1], VALUE_ONE,itert[pos-1], MATRIX_ELEM(ATE,pos,1) ,TCST,
1443  value_uminus(v1) );
1444 
1445  vect_dump(pv);
1448 
1449  lis1 =CONS(EXPRESSION, exp,lis1);
1450  }
1451 
1452 
1454  buf_ref[i][j-1]=make_reference(name,lis1);
1455  ref[i][j-1]=name;
1456  scopy[i][j-1]=copy_statement(sequen[i].s);
1457 
1458  pos=position_one_element(P1,j);
1459  con=value_minus(MATRIX_ELEM(G_PRO[i],pos,1), MATRIX_ELEM(ATE,pos,1));
1460  pv= vect_make(VECTEUR_NUL ,iter[pos-1], VALUE_ONE,TCST,con);
1462  t= make_test(e,scopy[i][j-1],make_block_statement(NIL));
1463  s=test_to_statement(t);
1464  lis2=CONS(STATEMENT,s,lis2);
1465  c= instruction_call(statement_instruction(( scopy[i][j-1] )));
1466  m=0;
1468  if (m==0)
1469  gauche = exp;
1470  m++;
1471  }
1472  syntax_reference(expression_syntax(gauche))= buf_ref[i][j-1];
1473 
1474 
1475  }
1476 
1477  lis=CONS(DIMENSION,
1479  Value_to_expression(MATRIX_ELEM(G_PROPP[i],1,1)),
1480  NIL),
1481  NIL);
1482  pos=position_one_element(P2,1);
1483  pv= vect_make(VECTEUR_NUL ,iter[pos-1], VALUE_ONE,TCST,VALUE_ZERO);
1484 
1485 
1488 
1489 
1490  lis1 =CONS(EXPRESSION, exp,NIL);
1491  for (k=2;k<=depth;k++)
1492  {
1493  lis=CONS(DIMENSION,
1496  (MATRIX_ELEM(ATEPP,k,1),VALUE_ONE)),
1497  NIL),
1498  lis);
1499  pos=position_one_element(P2,k);
1500  pv= vect_make(VECTEUR_NUL ,iter[pos-1], VALUE_ONE,TCST,VALUE_ZERO);
1502 
1503  lis1 =CONS(EXPRESSION, exp,lis1);
1504  }
1506  buf_ref[i][depth]=make_reference(name,lis1);
1507  ref[i][depth]=name;
1508  scopy[i][depth]=copy_statement(sequen[i].s);
1509  c= instruction_call(statement_instruction(( scopy[i][depth] )));
1510  m=0;
1511  MAP(EXPRESSION,exp,{
1512  if (m==0) gauche=exp;
1513  m++;
1514  },call_arguments(c)) ;
1515  syntax_reference(expression_syntax(gauche))= buf_ref[i][depth];
1516  lis2=CONS(STATEMENT, scopy[i][depth],lis2);
1517  seq= make_sequence(lis2);
1518  ins= make_instruction_sequence(seq);
1519  sequenp[i]= instruction_to_statement(ins);
1520 
1521  };
1522  };
1523 
1524  for(i=1;i<=k1-2;i++)
1525  {
1526  expression e=NULL;
1527  Pvecteur pv;
1528  Pmatrix *temp;
1529  reference *regi[nid_nbr];
1530  int m1;
1531 
1532  for(j=1;j<=depth;j++)
1533  {
1534  Value v2;
1535  v2=value_uminus(MATRIX_ELEM(G_PRO[i-1],j,1));
1536  pv= vect_make(VECTEUR_NUL,iter[j-1], VALUE_ONE,TCST ,v2);
1538  else
1540  }
1541  temp=( Pmatrix *)malloc( sequen[i].nbr_stencil *sizeof(Pmatrix));
1542  regi[i]=( reference *)malloc( sequen[i].nbr_stencil *sizeof(reference));;
1543  for(k=0;k<=sequen[i].nbr_stencil-1;k++)
1544  {
1545  entity name;
1546  char buffer[20];
1547  //expression exp;
1548  //reference ref;
1549  temp[k]=matrix_new(depth,1);
1550  matrix_substract(temp[k],sequen[i].delai, sequen[i-1].delai);
1551  matrix_substract(temp[k], temp[k],sequen[i].st[k]);
1552  sprintf(buffer,"%s%d_%d", "R",i+1,k);
1554  make_basic(is_basic_int, (void *) 4) );
1555  regi[i][k]=make_reference(name,NIL);
1556  }
1557  for(j=0;j<=depth;j++)
1558  {
1559  expression droite = expression_undefined, expt;
1560  statement s1,s2,s3;
1561  sequence seq;
1562  instruction ins;
1563  call c;
1564  test t;
1565  int m,l;
1566  list lis,lisp;
1567  reference ref;
1568  s1=copy_statement(scopy[i][j]);
1570  m=0;
1571  MAP(EXPRESSION,exp,{
1572  if (m==1) droite=exp;
1573  m++;
1574  },call_arguments(c)) ;
1576  for(k=0;k<=sequen[i].nbr_stencil-1;k++)
1577  {
1578  expression exp;
1579  ref=copy_reference (buf_ref[i-1][depth]); /**** ?????? ****/
1581  for(l=0;l<=depth-1;l++)
1582  {
1583  Pvecteur pv;
1584  expression delai_plus;
1585  pv = vect_make(VECTEUR_NUL,iter[l], VALUE_ONE, TCST,-MATRIX_ELEM(temp[k],l+1,1));
1586  delai_plus=Pvecteur_to_expression(pv);
1587  replace_entity_by_expression(exp,(entity)iter[l],delai_plus);
1588  }
1589  expt=EXPRESSION( CAR(lis));
1590  lis=CDR(lis);
1592  }
1593  lis=NIL;
1594  for(k=0;k<=sequen[i].nbr_stencil-1;k++)
1595  {
1596  statement s,*stemp;
1597  stemp=( statement *)malloc( (depth+1) *sizeof(statement));
1598  for(l=0;l<=depth;l++)
1599  {
1600  int r;
1601  expression exp;
1602  reference ref;
1603 
1604  ref=copy_reference (buf_ref[i-1][l]);
1606  for (r=0;r<=depth-1;r++)
1607  {
1608  Pvecteur pv;
1609  expression delai_plus;
1610 
1611  if(r==l)
1612  {
1613  Value t;
1614  int pos;
1615  pos=position_one_element(P1,r+1);
1616  t=value_minus(MATRIX_ELEM(ATEP,r+1,1),MATRIX_ELEM(temp[k],pos,1));
1617  pv = vect_make(VECTEUR_NUL,iter[pos-1], VALUE_ONE, TCST,t);
1618  delai_plus=Pvecteur_to_expression(pv);
1619  replace_entity_by_expression(exp,(entity)iter[pos-1],delai_plus);
1620  }
1621 
1622  else
1623  {
1624  int pos;
1625  pos=position_one_element(P1,r+1);
1626  pv = vect_make(VECTEUR_NUL,iter[pos-1], VALUE_ONE, TCST,-MATRIX_ELEM(temp[k],pos,1));
1627  delai_plus=Pvecteur_to_expression(pv);
1628  replace_entity_by_expression(exp,(entity)iter[pos-1],delai_plus);
1629  }
1630  }
1631 
1632 
1633  r=0;
1634  MAP(EXPRESSION,exp,{
1635 
1636  if (r==depth)
1637  {
1638 
1639  int pos;
1640  expression delai_plus;
1641  pos=position_one_element(P1,l+1);
1642  pv= vect_make(VECTEUR_NUL ,itert[pos-1], VALUE_ONE,TCST,-VALUE_ONE);
1643  delai_plus=Pvecteur_to_expression(pv);
1644  replace_entity_by_expression(exp,(entity)itert[pos-1],delai_plus);
1645 
1646  };
1647  r++;
1648  },reference_indices(ref))
1649 
1651  };
1652  s= stemp[depth];
1653  for(l=depth-1;l>=0;l--)
1654  {
1655  int pos;
1656  Pvecteur pv2;
1657  //statement s1/*,s2*/;
1658  test t;
1659  expression exp;
1660  pos=position_one_element(P1,l+1);
1661  pv2= vect_make(VECTEUR_NUL,iter[pos-1], VALUE_ONE,TCST , -MATRIX_ELEM(temp[k],pos,1));
1663  t= make_test(exp,stemp[l],s);
1664  s=test_to_statement(t);
1665  }
1666  lis=CONS(STATEMENT,s,lis);
1667 
1668  }
1669  s3=copy_statement(s1);
1670 
1672  m=0;
1673  MAP(EXPRESSION,exp,{
1674  if (m==1) droite=exp;
1675  m++;
1676  },call_arguments(c)) ;
1678  for(k=0;k<=sequen[i].nbr_stencil-1;k++)
1679  {
1680 
1681  expression expt;
1682 
1683 
1684 
1685  expt=EXPRESSION( CAR(lisp));
1686 
1687  lisp=CDR(lisp);
1688 
1689  syntax_reference(expression_syntax(expt))=regi[i][k];
1690 
1691  }
1692 
1693 
1694 
1695  lis=CONS(STATEMENT,s3,lis);
1696  lis=gen_nreverse(lis);
1697 
1698  seq= make_sequence(lis);
1699  ins= make_instruction_sequence(seq);
1700  s2= instruction_to_statement(ins);
1701  t= make_test(e,s1,s2);
1702  scopy[i][j]=test_to_statement(t);
1703 
1704 
1705  };
1706 
1707  m1=0;
1708 
1710  MAP(STATEMENT,s,{
1711  if (m1!=0)
1712  {
1714 
1715  }
1716  m1++;
1718 
1719 
1720 
1721 
1722 
1723  };
1724  /* ********************************** */
1725 
1726  for(i= k1-1 ;i<=k1-1;i++)
1727  {
1728  expression e=NULL;
1729  Pvecteur pv;
1730  Pmatrix *temp;
1731  reference *regi[nid_nbr];
1732  //int m1;
1733  /* */
1734 
1735  expression droite = expression_undefined, expt;
1736  statement s1,s2,s3;
1737  sequence seq;
1738  instruction ins;
1739  call c;
1740  test t;
1741  int m,l;
1742  list lis,lisp;
1743  reference ref;
1744 
1745 
1746  for(j=1;j<=depth;j++)
1747  {
1748 
1749  Value v2;
1750 
1751 
1752 
1753  v2=value_uminus(MATRIX_ELEM(G_PRO[i-1],j,1));
1754 
1755  pv= vect_make(VECTEUR_NUL,iter[j-1], VALUE_ONE,TCST ,v2);
1756 
1758  else
1760 
1761  }
1762 
1763  temp=( Pmatrix *)malloc( sequen[i].nbr_stencil *sizeof(Pmatrix));
1764  regi[i]=( reference *)malloc( sequen[i].nbr_stencil *sizeof(reference));;
1765  for(k=0;k<=sequen[i].nbr_stencil-1;k++)
1766  {
1767  entity name;
1768  char buffer[20];
1769  //expression exp;
1770  //reference ref;
1771  temp[k]=matrix_new(depth,1);
1772 
1773  matrix_substract(temp[k],sequen[i].delai, sequen[i-1].delai);
1774  matrix_substract(temp[k], temp[k],sequen[i].st[k]);
1775 
1776 
1777 
1778  sprintf(buffer,"%s%d_%d", "R",i+1,k);
1780  make_basic(is_basic_int, (void *) 4) );
1781 
1782  regi[i][k]=make_reference(name,NIL);
1783 
1784 
1785 
1786  }
1787 
1788  s1=copy_statement( sequen[i].s);
1789  ps1=s1;
1791  m=0;
1792  MAP(EXPRESSION,exp,{
1793  if (m==1) droite=exp;
1794  m++;
1795  },call_arguments(c)) ;
1797  for(k=0;k<=sequen[i].nbr_stencil-1;k++)
1798  {
1799  expression exp;
1800  ref=copy_reference (buf_ref[i-1][depth]);
1802  for(l=0;l<=depth-1;l++)
1803  {
1804  Pvecteur pv;
1805  expression delai_plus;
1806  pv = vect_make(VECTEUR_NUL,iter[l], VALUE_ONE, TCST,-MATRIX_ELEM(temp[k],l+1,1));
1807  delai_plus=Pvecteur_to_expression(pv);
1808  replace_entity_by_expression(exp,(entity)iter[l],delai_plus);
1809  }
1810  expt=EXPRESSION( CAR(lis));
1811  lis=CDR(lis);
1813  }
1814  lis=NIL;
1815  for(k=0;k<=sequen[i].nbr_stencil-1;k++)
1816  {
1817  statement s,*stemp;
1818  stemp=( statement *)malloc( (depth+1) *sizeof(statement));
1819  for(l=0;l<=depth;l++)
1820  {
1821  int r;
1822  expression exp;
1823  reference ref;
1824 
1825  ref=copy_reference (buf_ref[i-1][l]);
1826 
1827 
1829  for (r=0;r<=depth-1;r++)
1830  {
1831  Pvecteur pv;
1832  expression delai_plus;
1833 
1834  if(r==l)
1835  {
1836  Value t;
1837  int pos;
1838  pos=position_one_element(P1,r+1);
1839  t=value_minus(MATRIX_ELEM(ATEP,r+1,1),MATRIX_ELEM(temp[k],pos,1));
1840  pv = vect_make(VECTEUR_NUL,iter[pos-1], VALUE_ONE, TCST,t);
1841  delai_plus=Pvecteur_to_expression(pv);
1842  replace_entity_by_expression(exp,(entity) iter[pos-1], delai_plus);
1843  }
1844 
1845  else
1846  {
1847  int pos;
1848  pos=position_one_element(P1,r+1);
1849  pv = vect_make(VECTEUR_NUL,iter[pos-1], VALUE_ONE, TCST,-MATRIX_ELEM(temp[k],pos,1));
1850  delai_plus=Pvecteur_to_expression(pv);
1851  replace_entity_by_expression(exp,(entity) iter[pos-1], delai_plus);
1852  }
1853 
1854  }
1855  r=0;
1856  MAP(EXPRESSION,exp,{
1857 
1858  if (r==depth)
1859  {
1860  int pos;
1861  expression delai_plus;
1862  pos=position_one_element(P1,l+1);
1863 
1864 
1865  pv= vect_make(VECTEUR_NUL ,itert[pos-1], VALUE_ONE,TCST,-VALUE_ONE);
1866 
1867  delai_plus=Pvecteur_to_expression(pv);
1868  replace_entity_by_expression(exp,(entity) itert[pos-1], delai_plus);
1869 
1870 
1871 
1872  };
1873  r++;
1874  },reference_indices(ref));
1875 
1877  };
1878  s= stemp[depth];
1879  for(l=depth-1;l>=0;l--)
1880  {
1881  int pos;
1882  Pvecteur pv2;
1883  //statement s1,s2;
1884  test t;
1885  expression exp;
1886  pos=position_one_element(P1,l+1);
1887  pv2= vect_make(VECTEUR_NUL,iter[pos-1], VALUE_ONE,TCST , -MATRIX_ELEM(temp[k],pos,1));
1889  t= make_test(exp,stemp[l],s);
1890  s=test_to_statement(t);
1891  }
1892  lis=CONS(STATEMENT,s,lis);
1893 
1894  }
1895  s3=copy_statement(s1);
1896  ps2=s3;
1898  m=0;
1899  MAP(EXPRESSION,exp,{
1900  if (m==1) droite=exp;
1901  m++;
1902  },call_arguments(c)) ;
1904  for(k=0;k<=sequen[i].nbr_stencil-1;k++)
1905  {
1906  expression expt;
1907  expt=EXPRESSION( CAR(lisp));
1908  lisp=CDR(lisp);
1909  syntax_reference(expression_syntax(expt))=regi[i][k];
1910  }
1911  lis=CONS(STATEMENT,s3,lis);
1912  lis=gen_nreverse(lis);
1913  seq= make_sequence(lis);
1914  ins= make_instruction_sequence(seq);
1915  s2= instruction_to_statement(ins);
1916  t= make_test(e,s1,s2);
1917  sequen[i].s=test_to_statement(t);
1918 
1919 
1920 
1921  };
1922 
1923 
1924 
1925 
1926 
1927 
1928 /* ************************** */
1929 
1930 
1931 
1932 
1933 
1934 
1935 
1936  ls=loop1;
1937  for(j=0;j<=depth-1;j++)
1938  {
1939  range range1;
1940  range1=loop_range(ls);
1941  range_lower(range1)=int_to_expression(tiled_nest[j].lower);
1942  range_upper(range1)= int_to_expression(tiled_nest[j].upper);
1944  };
1945  tiling_indice= ( Pvecteur *)malloc(depth *sizeof( Pvecteur*));
1946  plus=depth*2-1;
1947 
1948  for (pb =base_newindex; pb!=NULL; pb=pb->succ) {
1949  loop tl;
1950  switch(plus%2)
1951  {
1952  case 1:
1953  {
1954 
1955  elem_mat2=MATRIX_ELEM(A,plus/2+1,plus ) ;
1956 
1957  upper= int_to_expression(value_minus(elem_mat2,VALUE_ONE));
1958 
1959  lower= int_to_expression(0);
1960 
1962 
1963  vect_dump( tiling_indice[plus/2]);
1964 
1965 
1966  break;
1967  }
1968 
1969  case 0:
1970  {
1971  elem_mat1=MATRIX_ELEM(A,plus/2+1,plus+1);
1972  upper= int_to_expression(value_div(tiled_nest[plus/2].upper,elem_mat1));
1973  lower= int_to_expression(0);
1974 
1975  tiling_indice[plus/2]=vect_make( tiling_indice[plus/2],pb->var ,elem_mat1,TCST,VALUE_ZERO);
1976  vect_dup( tiling_indice[plus/2]);
1977 
1978  break;
1979  };
1980 
1981  default: break;
1982  }
1983 
1984  tl = make_loop((entity) vecteur_var(pb),
1986  int_to_expression(1)),
1987  s1,
1990  NIL);
1992 
1993 
1994  plus--;
1995  };
1996 
1997 
1998 
1999  /******/
2000  for (i=k1-1;i>=0;i--)
2001  {
2002  expression e1,e2,e/*,gauche=NULL,droite=NULL*/,delai_plus;
2003  test t;
2004  //call c;
2005  //int m;
2006  //Pvecteur pv;
2008  Value_to_expression( value_plus(sequen[i].nd[0].lower,
2009  MATRIX_ELEM( sequen[i].delai,1,1))));
2011  Value_to_expression( value_plus(sequen[i].nd[0].upper,
2012  MATRIX_ELEM( sequen[i].delai,1,1))));
2013  if (value_eq( value_plus(sequen[i].nd[0].lower,MATRIX_ELEM( sequen[i].delai,1,1)),tiled_nest[0].lower))
2014  {
2015  if (value_eq( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),tiled_nest[0].upper)&&
2016  value_eq(value_mod( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),
2017  MATRIX_ELEM(A,1,1)),VALUE_ZERO))
2018  e=NULL;
2019  else
2020  e=e2;
2021  }
2022  else
2023  {
2024  if (value_eq( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),tiled_nest[0].upper)&&
2025  value_eq(value_mod( value_plus(sequen[i].nd[0].upper,MATRIX_ELEM( sequen[i].delai,1,1)),
2026  MATRIX_ELEM(A,1,1)),VALUE_ZERO))
2027  e=e1;
2028 
2029  else
2030  e=and_expression(e1,e2);
2031 
2032  };
2033 
2034  for(j=0;j<=depth-1;j++)
2035  {
2036  if (j>=1)
2037  {
2039  Value_to_expression(value_plus(sequen[i].nd[j].lower,
2040  MATRIX_ELEM( sequen[i].delai,j+1,1))));
2042  Value_to_expression( value_plus(sequen[i].nd[j].upper,
2043  MATRIX_ELEM( sequen[i].delai,j+1,1))));
2044  if (value_eq( value_plus(sequen[i].nd[j].lower,MATRIX_ELEM( sequen[i].delai,j+1,1)),tiled_nest[j].lower))
2045  {
2046  if (! (value_eq(value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),tiled_nest[j].upper)&&
2047  value_eq(value_mod( value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),
2048  MATRIX_ELEM(A,j+1,2*j+1)),VALUE_ZERO)))
2049  {
2050  if (e==NULL)
2051  e=e2;
2052  else
2053  e=and_expression(e,e2);
2054  };
2055  }
2056  else
2057  {
2058  if (value_eq(value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),tiled_nest[j].upper)&&
2059  value_eq(value_mod( value_plus(sequen[i].nd[j].upper,MATRIX_ELEM( sequen[i].delai,j+1,1)),
2060  MATRIX_ELEM(A,j+1,2*j+1)),VALUE_ZERO))
2061  {
2062  if (e==NULL)
2063  e=e1;
2064  else
2065  e=and_expression(e,e1);
2066  }
2067  else
2068  {
2069  e1=and_expression(e1,e2);
2070  if(e==NULL)
2071  e=e1;
2072  else
2073  e=and_expression(e,e1);
2074  }
2075  };
2076  };
2077  };
2078  if(i<= k1-2)
2079  {
2080  if(i==0)
2081  {
2082  call c;
2083  int m ,j,l;
2085  Pvecteur pv;
2086 
2087  for(j=0;j<depth+1;j++)
2088  {
2089  c= instruction_call(statement_instruction(( scopy[i][j])));
2090  m=0;
2091  MAP(EXPRESSION,exp,{
2092  if (m==1) droite=exp;
2093  m++;
2094  },call_arguments(c)) ;
2095  for(l=0;l<=depth-1;l++)
2096  {
2097  pv = vect_make(tiling_indice[l],TCST,value_uminus(MATRIX_ELEM(sequen[i].delai,l+1,1)));
2098  delai_plus=Pvecteur_to_expression(pv);
2099 
2101  replace_entity_by_expression(exp,(entity) sequen[i].nd[l].index, delai_plus);
2102  }
2103  }
2104  }
2105 
2106  t= make_test(e,sequenp[i],make_block_statement(NIL));
2107  }
2108  else
2109  {
2110  call c;
2111  int m ,j;
2113  Pvecteur pv;
2115  m=0;
2116  MAP(EXPRESSION,exp,{
2117  if (m==0) gauche=exp;
2118  m++;
2119  },call_arguments(c)) ;
2120  for(j=0;j<=depth-1;j++)
2121  {
2122  pv = vect_make(tiling_indice[j],TCST,value_uminus(MATRIX_ELEM(sequen[i].delai,j+1,1)));
2123  delai_plus=Pvecteur_to_expression(pv);
2124  replace_entity_by_expression(gauche,(entity) sequen[i].nd[j].index, delai_plus);
2125  }
2127  m=0;
2128  MAP(EXPRESSION,exp,{
2129  if (m==0) gauche=exp;
2130  m++;
2131  },call_arguments(c)) ;
2132  for(j=0;j<=depth-1;j++)
2133  {
2134  pv = vect_make(tiling_indice[j],TCST,value_uminus(MATRIX_ELEM(sequen[i].delai,j+1,1)));
2135  delai_plus=Pvecteur_to_expression(pv);
2136  replace_entity_by_expression(gauche,(entity) sequen[i].nd[j].index, delai_plus);
2137  }
2138 
2139 
2140 
2142  };
2143  s=test_to_statement(t);
2144 
2145  if(i==k1-1) lis=CONS(STATEMENT,s,NIL);
2146  else lis=CONS(STATEMENT,s,lis);
2147 
2148  };
2149 
2150  seq= make_sequence(lis);
2151  ins= make_instruction_sequence(seq);
2152  s= instruction_to_statement(ins);
2154  for(j=0;j<=2*depth-1;j++)
2156  else loop_body(ls)=s;
2157 
2158 
2159  s1=permutation2(s1,P);
2160 
2161  return s1;
2162 }
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
reference copy_reference(reference p)
REFERENCE.
Definition: ri.c:2047
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
#define VALUE_MONE
struct _newgen_struct_reference_ * reference
Definition: compsec.h:14
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
statement make_assign_statement(expression, expression)
Definition: statement.c:583
#define NP
Definition: iabrev.h:22
void vect_dump(Pvecteur v)
void vect_dump(Pvecteur v): print sparse vector v on stderr.
Definition: io.c:304
void matrix_substract(Pmatrix a, Pmatrix b, Pmatrix c)
void matrix_substract(Pmatrix a, Pmatrix b, Pmatrix c): substract rational matrix c from rational mat...
Definition: matrix.c:435
void matrix_multiply(const Pmatrix a, const Pmatrix b, Pmatrix c)
void matrix_multiply(Pmatrix a, Pmatrix b, Pmatrix c): multiply rational matrix a by rational matrix ...
Definition: matrix.c:95
#define binary_intrinsic_expression(name, e1, e2)
#define lt_expression(e1, e2)
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
expression reference_to_expression(reference r)
Definition: expression.c:196
entity make_scalar_entity(const char *, const char *, basic)
entity make_scalar_entity(name, module_name, base)
Definition: variable.c:331
@ is_basic_int
Definition: ri.h:571
#define syntax_reference(x)
Definition: ri.h:2730
#define expression_undefined
Definition: ri.h:1223
#define reference_indices(x)
Definition: ri.h:2328
#define statement_undefined
Definition: ri.h:2419
static string buffer
Definition: string.c:113
info_loop * nd
les stencils
int nbr_stencil
les boucles
statement s
le delai qu'on doit ajouter a ce nid
#define nid_nbr
statement permutation2(statement s, Pmatrix P)
static entity internal_make_new_array_variable(int i, int j, entity module, basic b, list lis)
le tableau en entree
int position_one_element(Pmatrix P, int i)
static void derive_new_basis_une(Pbase base_oldindex, Pbase *base_newindex, entity(*new_entity)(entity, char *))

References A, and_expression, binary_intrinsic_expression, buffer, call_arguments, CAR, CDR, CHUNK, compute_bound_tiled_nest(), compute_delay_tiled_nest(), CONS, copy_expression(), copy_reference(), copy_statement(), depth, derive_new_basis_une(), DIMENSION, entity_empty_label(), exp, EXPRESSION, expression_syntax, expression_undefined, FOREACH, ge_expression, gen_nreverse(), get_current_module_entity(), INFO_LOOP::index, instruction_call, instruction_loop, instruction_loop_p, instruction_sequence, instruction_test, instruction_to_statement(), int_to_expression(), internal_make_new_array_variable(), is_basic_int, is_execution_sequential, is_instruction_loop, k1, le_expression, loop1, loop_body, loop_iteration_domaine_to_sc(), loop_range, loop_to_statement, INFO_LOOP::lower, lt_expression, make_assign_statement(), make_basic(), make_block_statement(), make_dimension(), make_execution(), make_instruction(), make_instruction_sequence(), make_loop(), make_range(), make_reference(), make_scalar_entity(), make_sequence(), make_test(), make_tile_index_entity_n(), malloc(), MAP, MATRIX_ELEM, matrix_fscan(), matrix_multiply(), matrix_new(), matrix_substract(), module_local_name(), NID::nbr_stencil, NID::nd, nid_nbr, NIL, NP, permutation2(), position_one_element(), print_expression(), Pvecteur_to_expression(), range_lower, range_upper, ref, reference_indices, reference_to_expression(), replace_entity_by_expression(), NID::s, s1, safe_fopen(), sequen, sequence_statements, STATEMENT, statement_instruction, statement_undefined, Svecteur::succ, syntax_call, syntax_reference, TCST, test_to_statement, test_true, tiled_nest, tiling_indice, INFO_LOOP::upper, user_request(), UU, value_div, value_eq, value_minus, value_mod, VALUE_MONE, VALUE_ONE, value_plus, Value_to_expression(), value_uminus, VALUE_ZERO, Svecteur::var, vect_dump(), vect_dup(), vect_make(), VECTEUR_NUL, and vecteur_var.

Referenced by tiling_sequence().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tiling_sequence()

bool tiling_sequence ( string  module)
Parameters
moduleodule

Definition at line 2534 of file tiling_sequence.c.

2535 {
2536  statement stat,s1=NULL;
2538  contenu_t contenu;
2539 
2540  debug_on("STATISTICS_DEBUG_LEVEL");
2541  pips_debug(1, "considering module %s\n", module);
2543 
2544  stat = (statement) db_get_memory_resource(DBR_CODE, module, true);
2545 
2546  context.contenu = hash_table_make(hash_pointer, 0);
2547  context.depth = hash_table_make(hash_pointer, 0);
2548  context.statement_stack = stack_make(statement_domain, 0, 0);
2549 
2551  (stat, & context,
2560  NULL);
2561  contenu = (contenu_t) hash_get(context.contenu, stat);
2562  depth = (intptr_t ) hash_get(context.depth, stat);
2563 
2564  if (contenu!=is_a_stencil)
2565  {
2566  printf(" Le programme ne repond pas aux hypotheses \n");
2567  array_overflow();
2568  }
2569  else
2570  {
2571  if(!array_overflow())
2572  {
2573  int choix ;
2574  printf("--------------Choix de la transformation-------\n");
2575  printf(" 1: Fusion \n");
2576  printf(" 2: Fusion avec allocation des tampons \n");
2577  printf(" 3: Tiling \n");
2578  printf(" 4: Tiling a seul niveau avec allocation des tampons \n");
2579  printf(" 5: Tiling a deux niveaux avec allocation des tampons \n");
2580  printf(" Choix: ");
2581  if(scanf("%d", &choix)!=1)
2582  pips_user_error("Undefined variable \"choix\".\n");
2583  switch(choix)
2584  {
2585  case 1: s1=fusion();
2586  break;
2587  case 2: s1= fusion_buffer();
2588  break;
2589  case 3: s1=Hierarchical_tiling();
2590  break;
2591  case 4: s1=Tiling_buffer_allocation();
2592  break;
2593  case 5: s1=Tiling2_buffer();
2594  break;
2595  default: break;
2596  }
2597  module_reorder(s1);
2598  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module, s1);
2599  }
2600  }
2602  // reset_current_module_statement();
2603 
2604  pips_debug(1, "done.\n");
2605  debug_off();
2606  return true;
2607 }
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
#define pips_user_error
Definition: misc-local.h:147
contenu_t
Definition: stats.c:45
#define intptr_t
Definition: stdint.in.h:294
static bool stmt_flt(statement s, context_p context)
static statement fusion()
cette fonction donne le code fusionne
statement Tiling_buffer_allocation()
static bool seq_flt()
static bool array_overflow()
statement Hierarchical_tiling()
contenu_t
pour marquer si la sequence repond a nos hypotheses
@ is_a_stencil
static void stmt_rwt(statement s, context_p context)
static void call_rwt(call ca, context_p context)
static void loop_rwt(loop l, context_p context)
static bool loop_flt(loop l)
static void seq_rwt(sequence sq, context_p context)
static bool uns_flt()
statement Tiling2_buffer()
static void wl_rwt(context_p context)
static statement fusion_buffer()
Cette fonction donne le code fusionne avec allocation des tampons.
static void test_rwt(context_p context)
static bool test_flt()
static bool call_flt()
static void uns_rwt(context_p context)

References array_overflow(), call_domain, call_flt(), call_rwt(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, depth, expression_domain, fusion(), fusion_buffer(), gen_context_multi_recurse(), gen_false(), gen_null(), gen_true(), hash_get(), hash_pointer, hash_table_make(), Hierarchical_tiling(), intptr_t, is_a_stencil, local_name_to_top_level_entity(), loop_domain, loop_flt(), loop_rwt(), module, module_reorder(), pips_debug, pips_user_error, printf(), reset_current_module_entity(), s1, seq_flt(), seq_rwt(), sequence_domain, set_current_module_entity(), stack_make(), statement_domain, stmt_flt(), stmt_rwt(), test_domain, test_flt(), test_rwt(), Tiling2_buffer(), Tiling_buffer_allocation(), uns_flt(), uns_rwt(), unstructured_domain, whileloop_domain, and wl_rwt().

+ Here is the call graph for this function:

◆ unimodular()

statement unimodular ( statement  )

Variable Documentation

◆ first_array

entity first_array
extern

une copie de l'un des nids de la sequence

Definition at line 83 of file tiling_sequence.c.

Referenced by array_overflow(), call_rwt(), and top_down_abc_flt().

◆ if1

bool if1
extern

Definition at line 49 of file guard_elimination.c.

Referenced by free_guards(), and loop_flt().

◆ if2

bool if2
extern

Definition at line 49 of file guard_elimination.c.

Referenced by free_guards(), and loop_flt().

◆ loop1

◆ sc_newbase

◆ sg