Strumenti Utente

Strumenti Sito


magistraleinformaticanetworking:spd:assistexamples

Examples of ASSIST code

I gathered here a few simple ASSIST programs (chosen among the ASSIST framework regression tests) as concrete examples of the ASSIST programming syntax.

Simple process graphs, "none" topology parmod

grafo.ast

grafo.ast
// -*- C++ -*-
 
 

#define N 10

generic main()
{
  stream long A1;
  stream long A2;

  stream long[N] B1;
  stream long[N] B2;

  stream long C1;
  stream long C2;

  stream bool D1;
  stream bool D2;
  
  genera1   (                    output_stream A1);
  genera2   (                    output_stream A2);
  p1        (input_stream A1     output_stream B1);
  p2        (input_stream A2     output_stream B2);
  cross     (input_stream B1,B2  output_stream C1,C2);
  p3        (input_stream C1     output_stream D1);
  p4        (input_stream C2     output_stream D2);
  fine      (input_stream D1,D2);
} 
 

genera1(output_stream long A1) {
  fgen1(output_stream A1);
}


proc fgen1(output_stream long A1)
 
inc<"iostream">
$c++{
  long a;
  
  // start message for regression test
  std::cerr << "STARTING genera1" << std::endl;

  for (int i=0;i<N;i++) {
    a = i;
    assist_out(A1, a);
  };
}c++$


genera2(output_stream long A2) {
  fgen2(output_stream A2);
}


proc fgen2(output_stream long A2)
 
inc<"iostream">
$c++{
  long a;

  // start message for regression test
  std::cerr << "STARTING genera2" << std::endl;

  for (int i=0;i<N;i++) {
    a = 1 + i;
    assist_out(A2,a);
  }
}c++$


parmod p1 (input_stream long A1 output_stream long B1[N]) {
  topology none Pv;
  
  do input_section {  
    guard1: on , , A1 {
      distribution A1 on_demand to Pv;
    }
  } while (true)
    
  virtual_processors {
    elab (in guard1 out B1) {
      VP {
	f_p1 (in A1 output_stream B1);
      }
    }
  }
   
  output_section {
    collects B1 from ANY Pv;
  } 
}


parmod p2 (input_stream long A2 output_stream long B2[N]) 
{
  topology none Pv;
  
  do input_section {
    guard1: on , , A2 {
      distribution A2 on_demand to Pv;
    }
  } while (true==true)
  
  virtual_processors {
    elab (in guard1 out B2) {
      VP {
	f_p2 (in A2 output_stream B2);
      }
    }
  }
 
  output_section {
    collects B2 from ANY Pv;
  } 
}


cross(input_stream long B1[N], long B2[N] output_stream long C1, long C2) {
  fcross (in B1,B2 output_stream C1,C2);
}


proc fcross(in long B1[N], long B2[N] output_stream long C1, long C2) 
 
inc<"iostream">
$c++{
  long c1 = 0;
  long c2 = 0;

  for (int i=0;i<N;i++) {
    c1 = c1 + B1[i];
    c2 = c2 + B2[i];
  }
  assist_out(C1,c1);
  assist_out(C2,c2);
}c++$


parmod p3 (input_stream long C1 output_stream bool D1) 
{
  topology none Pv;
  
  do input_section {
    guard1: on , , C1 {
      distribution C1 on_demand to Pv;
    }
  } while (true)
  
  virtual_processors {
    elab (in guard1 out D1) {
      VP {
	f_p3 (in C1 output_stream D1);
      }
    }
  }
 
  output_section {
    collects D1 from ANY Pv;
  } 
}


parmod p4 (input_stream long C2 output_stream bool D2) 
{
  topology none Pv;
  
  do input_section {
    guard1: on , , C2 {
      distribution C2 on_demand to Pv;
    }
  } while (true)
  
  virtual_processors {
    elab (in guard1 out D2) {
      VP {
	f_p4 (in C2 output_stream D2);
      }
    }
  }
 
  output_section {
    collects D2 from ANY Pv;
  } 
}


fine(input_stream bool D1,bool D2)
 
inc<"iostream">
$c++{
  static int count;
  static int ok = 0;

  if ((D1 != true) || (D2 !=false)) ok = -1;
  count++;

  if (count >= N) {
    // termination message for regression test
    if (ok==0) 
      std::cerr << "ENDING with SUCCESS grafo.ast" << std::endl;
    else 
      std::cerr << "ENDING with FAILURE grafo.ast" << std::endl;
  }
}c++$


proc f_p1(in long A1 output_stream long B1[N])
 
inc<"iostream">
$c++{
  long b[N];

  b[0] = A1;
  for (int i=1;i<N;i++)
    b[i] = b[i-1] + A1;

  assist_out(B1, b);
}c++$


proc f_p2(in long A2 output_stream long B2[N])
 
inc<"iostream">
$c++{
  long b[N];

  b[0] = A2;
  for (int i=1;i<N;i++)
    b[i] = b[i-1] + A2;

  assist_out(B2, b);
}c++$


proc f_p3(in long C1 output_stream bool D1)
 
inc<"iostream">
$c++{
  bool d1 = true;
  assist_out(D1,d1);
}c++$


proc f_p4(in long C2 output_stream bool D2)
 
inc<"iostream">
$c++{
  bool d2 = false;
  assist_out(D2,d2);
}c++$

pipeline.ast

pipeline.ast
// -*- C++ -*-
 
 

#define N 10
#define MAX_ITER 10  
#define FILE_OUT "/tmp/risultato.txt"


/* ------------------------------------------------------------ */
/* Test of a simple pipeline with a parmod none as middle stage */
/* here the proc elements have been written in C++              */ 
/* ------------------------------------------------------------ */

typedef struct {
  long x;
  long y;
} T_cart;
 

generic main()
{
  stream T_cart[N] A;
  stream T_cart[N] B;

  genera    (output_stream A);
  elabora   (input_stream A output_stream B);
  stampa    (input_stream B);
}


genera (output_stream T_cart A[N]) {
  Fgenera (output_stream A);
}


proc Fgenera (output_stream T_cart A[N])
 
inc<"iostream">
$c++{
  T_cart tmp_A[N];

  // start message for regression test
  std::cerr << "STARTING gen" << std::endl;
  
  for (int k=0; k<MAX_ITER; k++) {
    for (int i=0; i<N; i++) {
      tmp_A[i].x = i+(k/MAX_ITER);
      tmp_A[i].y = (i+(k/MAX_ITER)) * (i+(k/MAX_ITER));
    }
    assist_out (A, tmp_A);
  }
}c++$


parmod elabora (input_stream T_cart A[N] output_stream T_cart B[N]) 
{
  topology none Pv;
  
  do input_section {
    guard1: on , , A {
      distribution A on_demand to Pv;
    }
  } while (true)
  
  virtual_processors {
    elab (in guard1 out B) {
      VP {
	Felab (in A out B);
      }
    }
  }
 
  output_section {
    collects B from ANY Pv;
  } 
}


stampa (input_stream T_cart B[N])
 
inc<"iostream","fstream">
$c++{
  std::ofstream f;
  static int file_aperto = -1;
  static int count = 0;
  static int ok = 0;

  if (file_aperto == -1) {
    f.open (FILE_OUT);
    file_aperto = 0;
  }
  
  for(int i=0; i<N; i++)
    f << B[i].x << " " << B[i].y << std::endl;
  f << std::endl << std::endl;

  // verify result
  for (int i=0; i<N; i++) {
    if (B[i].y != -((int)(i+(count/MAX_ITER)))) ok = -1;
    if (B[i].x != ((int)((i+(count/MAX_ITER)) * (i+(count/MAX_ITER))))) ok = -1;
  }
    
  count++;
  
  if (count >= MAX_ITER) {
    f.close();
    
    // termination message for regression test
    if (ok==0) 
      std::cerr << "ENDING with SUCCESS pipeline.ast --> stampa su file " << FILE_OUT << std::endl;
    else 
      std::cerr << "ENDING with FAILURE pipeline.ast --> stampa su file " << FILE_OUT << std::endl;
  }
}c++$


proc Felab (in T_cart A[N] out T_cart B[N])
 
inc<"iostream">
$c++{
  static int count= 0;
  //std::cerr << " Felab " << count++ << std::endl;
  
  for (int i=0; i<N; i++) {
    B[i].x = A[i].y;
    B[i].y = -A[i].x;
  }
}c++$

pipeline_C.ast

pipeline_C.ast
// -*- C++ -*-
#define N 10
#define MAX_ITER 10

/* ------------------------------------------------------------ */
/* Test of a simple pipeline with a parmod none as middle stage */
/* here the proc elements have been written in C                */ 
/* ------------------------------------------------------------ */

typedef struct
{
  long x;
  long y;
} T_cart;
 

generic main()
{
  stream T_cart[N] A;
  stream T_cart[N] B;

  genera    (output_stream A);
  elabora   (input_stream A output_stream B);
  stampa    (input_stream B);
} 


genera (output_stream T_cart A[N]) {
  Fgenera (output_stream A);
}


proc Fgenera (output_stream T_cart A[N])
inc<"stdio.h">
$c{
  int i, k;
  T_cart tmp_A[N];

  // start message for regression test
  printf ("STARTING gen\n");
  
  for (k=0; k<MAX_ITER; k++) {
    for (i=0; i<N; i++) {
      tmp_A[i].x = i+(k/MAX_ITER);
      tmp_A[i].y = (i+(k/MAX_ITER)) * (i+(k/MAX_ITER));
    }
    assist_out (A, tmp_A);
  }
}c$ 



parmod elabora (input_stream T_cart A[N] output_stream T_cart B[N]) 
{
  topology none Pv;
  
  do input_section {
    guard1: on , , A {
      distribution A on_demand to Pv;
    }
  } while (true)
  
  virtual_processors {
    elab (in guard1 out B) {
      VP {
	Felab (in A output_stream B);
      }
    }
  }
 
  output_section {
    collects B from ANY Pv;
  } 
}


stampa (input_stream T_cart B[N])
inc<"stdio.h">
$c{
  int i;
  static int count = 0;
  static int ok = 0;

  /*
    for (i=0; i<N; i++) {
    printf("%d,%d - ",(*B)[i].x,(*B)[i].y);
    }
    printf("\n");
  */
  
  // verify result
  for (i=0; i<N; i++) {
    if ((*B)[i].y != -((int)(i+(count/MAX_ITER)))) {
      ok = -1;
      printf("B[%d].y = %d e il mio conto = %d\n", i, (*B)[i].y, 
	     ((int)(i+(count/MAX_ITER))));
    }
    if ((*B)[i].x != ((int)((i+(count/MAX_ITER)) * (i+(count/MAX_ITER))))) {
      ok = -1;
      printf("B[%d].x = %d e il mio conto = %d\n", i, (*B)[i].x, 
	     -((int)((i+(count/MAX_ITER)) * (i+(count/MAX_ITER)))));
    }
  }
    
  count++;
  
  if (count >= MAX_ITER) {
    // termination message for regression test
    if (ok==0) 
      printf("ENDING with SUCCESS pipeline_C.ast\n");
    else 
      printf("ENDING with FAILURE pipeline_C.ast\n");
  }
}c$

proc Felab (in T_cart A[N] output_stream T_cart S[N])
inc<"stdio.h">
$c{
  int i;
  T_cart B[N];

  for (i=0; i<N; i++) {
    B[i].x = (*A)[i].y;
    B[i].y = -((*A)[i].x);
  }
  assist_out(S,B);
}c$

More complex examples of parmod usage

parmod.ast

parmod.ast
// -*- C++ -*-
#define N 10
#define M 5

generic main()
{
  stream long A1;
  stream long B1;

  genera(output_stream A1);  
  p_array(input_stream A1 output_stream B1);
  fine1(input_stream B1);
}


genera(output_stream long A1) {
  fgen(output_stream A1);
}


proc fgen(output_stream long A1)
inc<"iostream">
$c++{
  long a;
  
  // start regression test
  std::cerr << "STARTING gen" << std::endl;

  for (int i=0;i<N;i++) {
    a = i;
    assist_out(A1, a);
  };
}c++$


parmod p_array (input_stream long A1 output_stream long B1) {
  topology array[i:M] Pv;
  attribute long z;

  do input_section {
    guard1: on , , A1 {
      distribution A1 broadcast to Pv;
      operation {
	z = z + 1;
      }<use {z}>
    }
  } while (true)
  
  virtual_processors {
    elab1 (in guard1 out B1) {
      VP i {
	f_p1 (in A1 output_stream B1);
      }
    }
  }
   
  output_section {
    collects B1 from ANY Pv;
  } 
}


fine1(input_stream long B1)
 
inc<"iostream">
$c++{
  static int count = 0;
  static int ok = 0;

  //std::cerr << "Fine -> ricevuto B1 = " << B1 <<std::endl;
  
  // verify result
  long b;

  if (B1 != ((int)(count/M))) ok = -1;
  count++;

  // end of regression test
  if (count >= N*M) {  
    if (ok==0) 
      std::cerr << "ENDING with SUCCESS fine parmod.ast" << std::endl;
    else std::cerr << "ENDING with FAILURE fine parmod.ast" << std::endl;
  }
}c++$


proc f_p1(in long A1 output_stream long B1)
 
inc<"iostream">
$c++{
  long b = A1;
  assist_out(B1,b);
}c++$

parmod_due_proc.ast

parmod_due_proc.ast
// -*- C++ -*-
 
#define   CIPATH "/usr/include"

#define    N 10
#define    M 5
#define NUM1 0
#define NUM2 1

generic main()
{
  stream long    A;
  stream long[2] B;

  genera   (                 output_stream A);  
  p_array  (input_stream A   output_stream B);
  fine1    (input_stream B);
}


genera(output_stream long A) {
  fgen(output_stream A);
}


proc fgen(output_stream long A)
 
inc<"iostream">
$c++{
  long a;
  
  // start of regression test
  std::cerr << "STARTING gen" << std::endl;

  for (int i=0;i<N;i++) {
    a = i;
    assist_out(A, a);
  };
}c++$


parmod p_array (input_stream long A output_stream long B[2]) {
  
  topology array[i:M] Pv;
  attribute long b[2] replicated;

  do input_section {
    guard1: on , , A {
      distribution A broadcast to Pv;
    }
  } while (true)
  
  virtual_processors {
    elab1 (in guard1) {
      VP i {
	f_p1 (in A, i  out b);
        f_p2 (in b  out b);
	assist_out (B, b);
      }
    }
  }
   
  output_section {
    collects B from ANY Pv;
  } 
}


fine1(input_stream long B[2])
 
inc<"iostream">
$c++{
  static int count = 0;
  static int ok = 0;

  long b;
  
  if (B[1] != NUM2) ok = -1;
  count++;
  
  // end of regression test
  if (count >= N*M) {  
    if (ok==0) 
      std::cerr << "ENDING with SUCCESS fine parmod_due_proc.ast" << std::endl;
    else std::cerr << "ENDING with FAILURE fine parmod_due_proc.ast" << std::endl;
  }
}c++$


proc f_p1(in long A, long i  out long B[2])
 
inc<"iostream">
$c++{
  B[0] = i;
  B[1] = NUM1;
}c++$


proc f_p2(in long B1[2]  out long B2[2])
 
inc<"iostream">
$c++{
  B2[0] = B1[0];
  B2[1] = NUM2;
}c++$

nondeterminismo.ast

nondeterminismo.ast
// -*- C++ -*-

/* ------------------------------------------------------------ */
/* This example test nondeterministic receive over two streams  */
/* in a parmod with none topology                               */
/* Program graph contains 2 sequential modules, a parmod and    */
/* a further sequential.                                        */
/* ------------------------------------------------------------ */

 
 

#define N 10
#define MAX_ITER1 10   
#define MAX_ITER2 10   
#define FILE_OUT "/tmp/risultato.txt"


typedef struct
{
  long x;
  long y;
} T_cart;
 

generic main()
{
  stream T_cart[N] A;
  stream long A1;
  stream T_cart[N] B;

  genera1   (output_stream A);
  genera2   (output_stream A1);
  elabora   (input_stream A, A1  output_stream B);
  stampa    (input_stream B);
} 
 

genera1(output_stream T_cart A[N]) {
  Fgenera1(output_stream A);
}


proc Fgenera1(output_stream T_cart A[N])
 
inc<"iostream">
$c++{
  T_cart tmp_A[N];
  
  // start regression test
  std::cerr << "STARTING fgen1" << std::endl;

  for (int k=0; k<MAX_ITER1; k++) {
    for (int i=0; i<N; i++) {
      tmp_A[i].x =  i+(k/MAX_ITER1);
      tmp_A[i].y = (i+(k/MAX_ITER1)) * (i+(k/MAX_ITER1));
    }
    assist_out (A, tmp_A);
  }
}c++$


genera2(output_stream long A1) {
  Fgenera2(output_stream A1);
}


proc Fgenera2(output_stream long A1)
 
inc<"iostream">
$c++{
  static long c = 0;
  
  // start regression test
  std::cerr << "STARTING fgen2" << std::endl;

  for(int k=0; k<MAX_ITER2; k++) {
    assist_out(A1, c);
    c++;
  }
}c++$


parmod elabora(input_stream T_cart A[N], long A1 output_stream T_cart B[N]) {
  topology none Pv;
  
  do input_section {
    guard1: on , , A {
      distribution A on_demand to Pv;
    }
    guard2: on , , A1 {
      distribution A1 on_demand to Pv;
    }
  } while(true)
  
  virtual_processors {
    elab(in guard1 out B) {
      VP {
	Felab1(in A output_stream B);
      }
    }
    elab1(in guard2) {
      VP {
	Felab2(in A1);
      }
    }
  }
 
  output_section {
    collects B from ANY Pv;
  } 
}


stampa(input_stream T_cart B[N])
 
inc<"fstream","iostream">
$c++{
  std::ofstream f;
  static int file_aperto = -1;
  static int count = 0;
  static int ok = 0;


  if (file_aperto == -1) {
    f.open (FILE_OUT);
    file_aperto = 0;
  }
  
  for(int i=0; i<N; i++)
    f << B[i].x << " " << B[i].y << std::endl;
  f << std::endl << std::endl;

  // verift result
  for (int i=0; i<N; i++) {
    if (B[i].y != -((int)(i+(count/MAX_ITER1)))) ok = -1;
    if (B[i].x != ((int)((i+(count/MAX_ITER1)) * (i+(count/MAX_ITER1))))) ok = -1;
  }
    
  count++;
  
  if (count >= MAX_ITER1) {
    f.close();
    
    // end of regression test
    if (ok==0) 
      std::cerr << "ENDING with SUCCESS nondeterminismo.ast su file " << FILE_OUT << std::endl;
    else 
      std::cerr << "ENDING with FAILURE nondeterminismo.ast su file " << FILE_OUT << std::endl;
  }
}c++$


proc Felab1(in T_cart A[N] output_stream T_cart S[N])
 
inc<"iostream">
$c++{
  int i;
  T_cart B[N];

  for(i=0; i<N; i++) {
    B[i].x = A[i].y;
    B[i].y = -A[i].x;
  }
  assist_out(S, B);
}c++$


proc Felab2(in long A1)
 
inc<"iostream">
$c++{
}c++$

array_scatter.ast

array_scatter.ast
// -*- C++ -*-
#define N 10

generic main()
{
  stream long[N] A1;
  stream long[N] A2;
  stream long[N] B1;
  stream long[N] B2;
  
  genera1  (output_stream A1);
  genera2  (output_stream A2);  
  cross    (input_stream A1, A2  output_stream B1, B2);
  fine1    (input_stream B1);
  fine2    (input_stream B2);
}


genera1(output_stream long A1[N]) {
  fgen1(output_stream A1);
}


proc fgen1(output_stream long A1[N])
inc<"iostream">
$c++{
  long a[N];
  
  // start regression test
  std::cerr << "STARTING fgen1" << std::endl;

  for (int i=0;i<N;i++) 
    a[i] = i;
  
  assist_out(A1, a);
}c++$


genera2(output_stream long A2[N]) {
  fgen2(output_stream A2);
}


proc fgen2(output_stream long A2[N])
inc<"iostream">
$c++{
  long a[N];

  // start regression test
  std::cerr << "STARTING fgen2" << std::endl;

  for (int i=0;i<N;i++)
    a[i] = 10 + i;
  
  assist_out(A2,a);
}c++$


parmod cross(input_stream long A1[N], long A2[N]  output_stream long B1[N], long B2[N]) {

  topology array [i:N] Pv;

  attribute long S[N] scatter S[*i0] onto Pv[i0];

  stream long s1;
  stream long s2;

  do input_section {
    guard1: on , , A1 {
      distribution A1[*j] scatter to S[j];
    }
    guard2: on , , A2 {
      distribution A2[*k] scatter to S[k];
    }  
  } while (true)
  
  virtual_processors {
    elab1(in guard1 out s1) {
      VP i {
	f_p1(in S[i] out s1);
      }
    }
    elab2(in guard2 out s2) {
      VP i {
	f_p2(in S[i] out s2);
      }
    }
  }
  
  output_section {
    collects s1 from ALL Pv[i] {  
      int el1;
      int B1_[N];
      AST_FOR_EACH(el1) {
	B1_[i]=el1;
      }
      assist_out (B1, B1_);
    }<>;

    collects s2 from ALL Pv[i] {
      int el2;
      int B2_[N];
      AST_FOR_EACH(el2) {
	B2_[i]=el2;
      }
      assist_out (B2, B2_);
    }<>;
  } 
}


fine1(input_stream long B1[N])
 
inc<"iostream">
$c++{
  int ok = 0;
  
  /*
    std::cerr << "Fine1: " << std::endl;
    for (int i=0; i<N; i++)
    std::cerr << B1[i] << " ";
    std::cerr << std::endl;
  */
  
  for (int i=0;i<N;i++) if (B1[i] != i) ok = -1;
  if (ok==0) 
    std::cerr << "ENDING with SUCCESS fine1 array_scatter.ast" << std::endl;
  else  
    std::cerr << "ENDING with FAILURE fine1 array_scatter.ast" << std::endl;
}c++$


fine2(input_stream long B2[N])
 
inc<"iostream">
$c++{
  int ok = 0;

  /*
    std::cerr << "Fine2: " << std::endl;
    for (int i=0; i<N; i++)
    std::cerr << B2[i] << " ";
    std::cerr << std::endl;
  */

  for (int i=0;i<N;i++) if (B2[i] != (10 + i)) ok = -1;
  if (ok==0) 
    std::cerr << "ENDING with SUCCESS fine2 array_scatter.ast" << std::endl;
  else  
    std::cerr << "ENDING with FAILURE fine2 array_scatter.ast" << std::endl;
}c++$


proc f_p1(in long A1 out long B1)
 
inc<"iostream">
$c++{
  long b;
  b = A1;
  B1 = b;
}c++$


proc f_p2(in long A2 out long B2)
 
inc<"iostream">
$c++{
  B2 = A2;
}c++$

array_on_demand_attrib_array_replic.ast

array_on_demand_attrib_array_replic.ast
// -*- C++ -*-
#define N 5
#define M 10
#define MAX_ITER 20
#define RIS "/tmp/risultato.txt"

/***************************************************************/
/*                                                             */
/* Test of the on_demand distribution over the array topology  */
/*                                                             */
/* The parmod "elabora" has array topology                     */
/*                                                             */
/* The replicated attribute is a one-dimension array           */
/*                                                             */
/**************************************************************/

generic main() {
  stream long[M] A;
  stream long[M] B;

  genera    (output_stream A);
  elabora   (input_stream A output_stream B);
  stampa    (input_stream B);
} 
 

genera (output_stream long A[M]) {
  Fgenera (output_stream A);
}


proc Fgenera (output_stream long A[M]) 
inc<"iostream">
$c++{
  long tmp_A[M];

  // start regression test
  std::cerr << "STARTING fgen" << std::endl;
  
  for (int k=0; k<MAX_ITER; k++) {
    for (int i=0; i<M; i++) 
      tmp_A[i] = i;
    assist_out (A, tmp_A);
  }
}c++$


parmod elabora (input_stream long A[M] output_stream long B[M]) {

  topology array [i:N] Pv;

  /* bug in module builder solved:
     it was taking B_ as an integer, while it is an array */
     
  attribute long B_[M] replicated;
  stream long ris[M];
  
  do input_section {
    guard1: on , , A {
      distribution A on_demand to Pv;
    }
  } while (true)
       
  virtual_processors {
    elab (in guard1 out ris) {
      VP i {
	  Felab (in A out B_);
	  assist_out (ris, B_); 
      }
    }
  }
 
  output_section {
    collects ris from ANY Pv {
      assist_out(B, ris);
    }<>;
  } 
}


stampa (input_stream long B[M])
 
inc<"fstream","iostream">
$c++{
  static std::ofstream f;
  static int  count = 0;
  static int     ok = 0;

  if (count == 0) {
    f.open (RIS);
  }

  /* print and verify results */
  for (int i=0; i<M; i++) {
    f << B[i] << std::endl;
    if (B[i] != i) ok = -1;
  }
  count++;
  
  // end of regression test
  if (count >= MAX_ITER) {
    if (ok==0) 
      std::cerr << "ENDING with SUCCESS fine array_on_demand_attrib_array_replic.ast" << std::endl;
    else std::cerr << "ENDING with FAILURE fine array_on_demand_attrib_array_replic.ast" << std::endl;
    f.close();
  }
}c++$


proc Felab (in long A[M] out long B_[M])
 
inc<"iostream">
$c++{
  for (int i=0; i<M; i++)
    B_[i] = A[i];
}c++$
magistraleinformaticanetworking/spd/assistexamples.txt · Ultima modifica: 19/05/2010 alle 12:52 (14 anni fa) da Massimo Coppola