source: branches/v4/platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/dhrystone/dhry21a.c @ 1051

Last change on this file since 1051 was 140, checked in by kane, 14 years ago

yAjout du multi_cache : plusieurs processeur peuvent ce partager le même cache L1.
2 remarques, (1) deux nouveaux paramètres : nb_cpu, nb_cache. Pour avoir un cache dont le comportement est identique à la version d'avant, mettre ces paramètres à 1.
(2) le port d'interruption est maintenant un tableau dépendant du nombre de processeur.
Voir le fichier "platforms/caba-ring-ccxcachev4_memcachev4-mips32el/top.cpp" pour plus de détails.

--Cette ligne, et les suivantes ci-dessous, seront ignorées--

M platforms/tsarv4_dspin_generic_32/tsarv4_dspin_generic_32_top.cpp
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/segmentation.h
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/top.cpp
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/configuration/default.cfg
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/configuration/gen_config.sh
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/dhrystone/dhry21a.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/define.h
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/matrix_multiplication/matrix_multiplication.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/common/common.c
A platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/self_code_modifying
A platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/self_code_modifying/self_code_modifying.c
A platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/self_code_modifying/self_code_modifying.h
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark.h
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_sort.c
A platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_self_code_modifying.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/benchmark/benchmark_matrix_multiplication.c
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/soft/Makefile
M platforms/caba-ring-ccxcachev4_memcachev4-mips32el/Makefile
M platforms/tsarv4_vgmn_generic_32/tsarv4_vgmn_generic_32_top.cpp
M modules/vci_cc_xcache_wrapper_v4/caba/source/include/vci_cc_xcache_wrapper_v4.h
M modules/vci_cc_xcache_wrapper_v4/caba/source/src/vci_cc_xcache_wrapper_v4.cpp
M modules/vci_mem_cache_v4/caba/source/include/vci_mem_cache_v4.h
M modules/vci_mem_cache_v4/caba/source/include/mem_cache_directory_v4.h
M modules/vci_mem_cache_v4/caba/source/src/vci_mem_cache_v4.cpp

File size: 12.4 KB
Line 
1/*
2 *************************************************************************
3 *
4 *                   "DHRYSTONE" Benchmark Program
5 *                   -----------------------------
6 *
7 *  Version:    C, Version 2.1
8 *
9 *  File:       dhry_1.c (part 2 of 3)
10 *
11 *  Date:       May 25, 1988
12 *
13 *  Author:     Reinhold P. Weicker
14 *
15 *************************************************************************
16 */
17
18#include "dhry.h"
19#include "dhry21.h"
20
21#include <stdio.h>
22#ifdef GENERATE_RESULT_FILE
23#include <string.h>
24#endif
25#include <stdlib.h>
26
27/* Global Variables: */
28
29Rec_Pointer     Ptr_Glob,
30                Next_Ptr_Glob;
31int             Int_Glob;
32Boolean         Bool_Glob;
33char            Ch_1_Glob,
34                Ch_2_Glob;
35int             Arr_1_Glob [50];
36int             Arr_2_Glob [50] [50];
37
38char Reg_Define[] = "Register option selected.";
39
40//extern char     *malloc ();
41//Enumeration     Func_1 ();
42  /*
43  forward declaration necessary since Enumeration may not simply be int
44  */
45
46#ifndef ROPT
47#define REG
48        /* REG becomes defined as empty */
49        /* i.e. no register variables   */
50#else
51#define REG register
52#endif
53
54
55/* variables for time measurement: */
56
57#define Too_Small_Time 2
58                /* Measurements should last at least 2 seconds */
59
60DOUBLE          Begin_Time,
61                End_Time,
62                User_Time;
63
64DOUBLE          Microseconds,
65                Dhrystones_Per_Second,
66                Vax_Mips;
67
68/* end of variables for time measurement */
69
70DOUBLE dhry21 (unsigned int NUMBER_OF_RUNS)
71/*****/
72
73  /* main program, corresponds to procedures        */
74  /* Main and Proc_0 in the Ada version             */
75{
76  DOUBLE   dtime();
77
78        One_Fifty       Int_1_Loc = 0;
79  REG   One_Fifty       Int_2_Loc = 0;
80        One_Fifty       Int_3_Loc;
81  REG   char            Ch_Index;
82        Enumeration     Enum_Loc;
83        Str_30          Str_1_Loc;
84        Str_30          Str_2_Loc;
85  REG   int             Run_Index;
86  REG   int             Number_Of_Runs;
87
88#ifdef GENERATE_RESULT_FILE
89        FILE            *Ap;
90
91  /* Initializations */
92
93  if ((Ap = fopen("dhry.res","a+")) == NULL)
94    {
95       printf("Can not open dhry.res\n\n");
96       EXIT(1);
97    }
98#endif
99
100  Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
101  Ptr_Glob      = (Rec_Pointer) malloc (sizeof (Rec_Type));
102
103  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
104  Ptr_Glob->Discr                       = Ident_1;
105  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
106  Ptr_Glob->variant.var_1.Int_Comp      = 40;
107  strcpy (Ptr_Glob->variant.var_1.Str_Comp,
108          "DHRYSTONE PROGRAM, SOME STRING");
109  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
110
111  Arr_2_Glob [8][7] = 10;
112        /* Was missing in published program. Without this statement,    */
113        /* Arr_2_Glob [8][7] would have an undefined value.             */
114        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
115        /* overflow may occur for this array element.                   */
116
117  printf ("\n");
118  printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
119  printf ("\n");
120 
121//  if (Reg)
122//  {
123//    printf ("Program compiled with 'register' attribute\n");
124//    printf ("\n");
125//  }
126//  else
127//  {
128//    printf ("Program compiled without 'register' attribute\n");
129//    printf ("\n");
130//  }
131
132//**********************************************************************
133//  printf ("Please give the number of runs through the benchmark: ");
134//  {
135//    int n;
136//    scanf ("%d", &n);
137//    Number_Of_Runs = n;
138//  }
139//  printf ("\n");
140//**********************************************************************
141
142  Number_Of_Runs = NUMBER_OF_RUNS;
143 
144  printf ("Execution starts, %d runs through Dhrystone\n",Number_Of_Runs);
145 
146  /***************/
147  /* Start timer */
148  /***************/
149 
150  Begin_Time = dtime();
151
152  for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
153  {
154    Proc_5();
155    Proc_4();
156      /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
157    Int_1_Loc = 2;
158    Int_2_Loc = 3;
159    strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
160    Enum_Loc = Ident_2;
161    Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
162      /* Bool_Glob == 1 */
163    while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
164    {
165      Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
166        /* Int_3_Loc == 7 */
167      Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
168        /* Int_3_Loc == 7 */
169      Int_1_Loc += 1;
170    } /* while */
171      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
172    Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
173      /* Int_Glob == 5 */
174    Proc_1 (Ptr_Glob);
175    for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
176                             /* loop body executed twice */
177    {
178      if (Enum_Loc == Func_1 (Ch_Index, 'C'))
179          /* then, not executed */
180        {
181        Proc_6 (Ident_1, &Enum_Loc);
182        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
183        Int_2_Loc = Run_Index;
184        Int_Glob = Run_Index;
185        }
186    }
187      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
188    Int_2_Loc = Int_2_Loc * Int_1_Loc;
189    Int_1_Loc = Int_2_Loc / Int_3_Loc;
190    Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
191      /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
192    Proc_2 (&Int_1_Loc);
193      /* Int_1_Loc == 5 */
194
195  } /* loop "for Run_Index" */
196
197  /**************/
198  /* Stop timer */
199  /**************/
200
201  End_Time = dtime();
202
203  printf ("Execution ends\n");
204
205#ifdef VERBOSE
206  printf ("\n");
207  printf ("Final values of the variables used in the benchmark:\n");
208  printf ("\n");
209  printf ("Int_Glob:            %d\n", Int_Glob);
210  printf ("        should be:   %d\n", 5);
211  printf ("Bool_Glob:           %d\n", Bool_Glob);
212  printf ("        should be:   %d\n", 1);
213  printf ("Ch_1_Glob:           %c\n", Ch_1_Glob);
214  printf ("        should be:   %c\n", 'A');
215  printf ("Ch_2_Glob:           %c\n", Ch_2_Glob);
216  printf ("        should be:   %c\n", 'B');
217  printf ("Arr_1_Glob[8]:       %d\n", Arr_1_Glob[8]);
218  printf ("        should be:   %d\n", 7);
219  printf ("Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
220  printf ("        should be:   Number_Of_Runs + 10\n");
221  printf ("Ptr_Glob->\n");
222  printf ("  Ptr_Comp:          %d\n", (int) Ptr_Glob->Ptr_Comp);
223  printf ("        should be:   (implementation-dependent)\n");
224  printf ("  Discr:             %d\n", Ptr_Glob->Discr);
225  printf ("        should be:   %d\n", 0);
226  printf ("  Enum_Comp:         %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
227  printf ("        should be:   %d\n", 2);
228  printf ("  Int_Comp:          %d\n", Ptr_Glob->variant.var_1.Int_Comp);
229  printf ("        should be:   %d\n", 17);
230  printf ("  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
231  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
232  printf ("Next_Ptr_Glob->\n");
233  printf ("  Ptr_Comp:          %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
234  printf ("        should be:   (implementation-dependent), same as above\n");
235  printf ("  Discr:             %d\n", Next_Ptr_Glob->Discr);
236  printf ("        should be:   %d\n", 0);
237  printf ("  Enum_Comp:         %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
238  printf ("        should be:   %d\n", 1);
239  printf ("  Int_Comp:          %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
240  printf ("        should be:   %d\n", 18);
241  printf ("  Str_Comp:          %s\n", Next_Ptr_Glob->variant.var_1.Str_Comp);
242  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
243  printf ("Int_1_Loc:           %d\n", Int_1_Loc);
244  printf ("        should be:   %d\n", 5);
245  printf ("Int_2_Loc:           %d\n", Int_2_Loc);
246  printf ("        should be:   %d\n", 13);
247  printf ("Int_3_Loc:           %d\n", Int_3_Loc);
248  printf ("        should be:   %d\n", 7);
249  printf ("Enum_Loc:            %d\n", Enum_Loc);
250  printf ("        should be:   %d\n", 1);
251  printf ("Str_1_Loc:           %s\n", Str_1_Loc);
252  printf ("        should be:   DHRYSTONE PROGRAM, 1'ST STRING\n");
253  printf ("Str_2_Loc:           %s\n", Str_2_Loc);
254  printf ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
255  printf ("\n");
256#endif
257
258  User_Time = End_Time - Begin_Time;
259
260//  if (User_Time < Too_Small_Time)
261//  {
262//#ifdef HAVE_DOUBLE
263//    printf ("Measured time too small to obtain meaningful results : %f\n",User_Time);
264//#else
265//    printf ("Measured time too small to obtain meaningful results : %d\n",User_Time);
266//#endif
267//    printf ("Please increase number of runs\n");
268//    printf ("\n");
269//  }
270//  else
271
272#ifdef HAVE_DOUBLE
273  Microseconds          = User_Time * Mic_secs_Per_Second / (DOUBLE) Number_Of_Runs;
274  Dhrystones_Per_Second = (DOUBLE) Number_Of_Runs / User_Time;
275  Vax_Mips              = Dhrystones_Per_Second / 1757.0;
276#else
277  Microseconds          = User_Time                       / (DOUBLE) Number_Of_Runs;
278#endif
279 
280#ifdef ROPT
281  printf ("Register option selected?  YES\n");
282#else
283  printf ("Register option selected?  NO\n");
284  strcpy(Reg_Define, "Register option not selected.");
285#endif
286 
287#ifdef HAVE_DOUBLE
288  printf ("Microseconds for one run through Dhrystone : %.1lf  \n",Microseconds);
289  printf ("Dhrystones per Second                      : %.1lf \n",Dhrystones_Per_Second);
290  printf ("VAX MIPS rating                            : %.3lf \n",Vax_Mips);
291#else
292  printf ("Begin_Time : %d\n",Begin_Time);
293  printf ("End_Time   : %d\n",End_Time  );
294  printf ("User_Time  : %d\n",User_Time );
295  printf ("Numbers of cycle for one run through Dhrystone : %d  \n",Microseconds);
296#endif
297  printf ("\n");
298 
299#ifdef GENERATE_RESULT_FILE
300  fprintf(Ap,"\n");
301  fprintf(Ap,"Dhrystone Benchmark, Version 2.1 (Language: C)\n");
302  fprintf(Ap,"%s\n",Reg_Define);
303 
304# ifdef HAVE_DOUBLE
305  fprintf(Ap,"Microseconds for one loop : %.1lf\n",Microseconds);
306  fprintf(Ap,"Dhrystones per second     : %.1lf\n",Dhrystones_Per_Second);
307  fprintf(Ap,"VAX MIPS rating           : %.3lf\n",Vax_Mips);
308# else
309  fprintf(Ap,"Numbers of cycle for one loop : %.1d\n",Microseconds);
310# endif
311  fclose(Ap);
312#endif
313 
314#ifdef HAVE_DOUBLE
315  return Vax_Mips;
316#else
317  return User_Time;
318#endif
319}
320
321void
322Proc_1 (Ptr_Val_Par)
323/******************/
324
325REG Rec_Pointer Ptr_Val_Par;
326    /* executed once */
327{
328  REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp; 
329                                        /* == Ptr_Glob_Next */
330  /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp,    */
331  /* corresponds to "rename" in Ada, "with" in Pascal           */
332 
333  structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
334  Ptr_Val_Par->variant.var_1.Int_Comp = 5;
335  Next_Record->variant.var_1.Int_Comp
336        = Ptr_Val_Par->variant.var_1.Int_Comp;
337  Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
338  Proc_3 (&Next_Record->Ptr_Comp);
339    /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
340                        == Ptr_Glob->Ptr_Comp */
341  if (Next_Record->Discr == Ident_1)
342    /* then, executed */
343  {
344    Next_Record->variant.var_1.Int_Comp = 6;
345    Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp, 
346           &Next_Record->variant.var_1.Enum_Comp);
347    Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
348    Proc_7 (Next_Record->variant.var_1.Int_Comp, 10, 
349           &Next_Record->variant.var_1.Int_Comp);
350  }
351  else /* not executed */
352    structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
353} /* Proc_1 */
354
355void
356Proc_2 (Int_Par_Ref)
357/******************/
358    /* executed once */
359    /* *Int_Par_Ref == 1, becomes 4 */
360
361One_Fifty   *Int_Par_Ref;
362{
363  One_Fifty  Int_Loc;
364  Enumeration   Enum_Loc;
365
366  Int_Loc = *Int_Par_Ref + 10;
367  do /* executed once */
368    if (Ch_1_Glob == 'A')
369      /* then, executed */
370    {
371      Int_Loc -= 1;
372      *Int_Par_Ref = Int_Loc - Int_Glob;
373      Enum_Loc = Ident_1;
374    } /* if */
375  while (Enum_Loc != Ident_1); /* true */
376} /* Proc_2 */
377
378void
379Proc_3 (Ptr_Ref_Par)
380/******************/
381    /* executed once */
382    /* Ptr_Ref_Par becomes Ptr_Glob */
383
384Rec_Pointer *Ptr_Ref_Par;
385
386{
387  if (Ptr_Glob != Null)
388    /* then, executed */
389    *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
390  Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
391} /* Proc_3 */
392
393void
394Proc_4 () /* without parameters */
395/*******/
396    /* executed once */
397{
398  Boolean Bool_Loc;
399
400  Bool_Loc = Ch_1_Glob == 'A';
401  Bool_Glob = Bool_Loc | Bool_Glob;
402  Ch_2_Glob = 'B';
403} /* Proc_4 */
404
405void
406Proc_5 () /* without parameters */
407/*******/
408    /* executed once */
409{
410  Ch_1_Glob = 'A';
411  Bool_Glob = false;
412} /* Proc_5 */
413
414
415        /* Procedure for the assignment of structures,          */
416        /* if the C compiler doesn't support this feature       */
417#ifdef  NOSTRUCTASSIGN
418memcpy (d, s, l)
419register char   *d;
420register char   *s;
421register int    l;
422{
423        while (l--) *d++ = *s++;
424}
425#endif
Note: See TracBrowser for help on using the repository browser.