aboutsummaryrefslogtreecommitdiffstats
path: root/test/ccured_olden/power/build.c
diff options
context:
space:
mode:
authorblazy <blazy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2006-10-20 12:37:13 +0000
committerblazy <blazy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2006-10-20 12:37:13 +0000
commitca0c62265eb8cdd5fb0d8a8b34ee77baf3de987e (patch)
tree50a139db8e2ac51c6ff41f3790ff72aa417ed3be /test/ccured_olden/power/build.c
parent43668d9109b1f36329646fd07324d435be6f0050 (diff)
downloadcompcert-ca0c62265eb8cdd5fb0d8a8b34ee77baf3de987e.tar.gz
compcert-ca0c62265eb8cdd5fb0d8a8b34ee77baf3de987e.zip
Ajout du banc de tests de CCured (Olden benchmark suite, cf.
CCured: type-safe retrofitting of legacy code, G.Necula et al.) rapportCompcert_all.txt liste les erreurs produites par ccomp. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@121 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/ccured_olden/power/build.c')
-rw-r--r--test/ccured_olden/power/build.c154
1 files changed, 154 insertions, 0 deletions
diff --git a/test/ccured_olden/power/build.c b/test/ccured_olden/power/build.c
new file mode 100644
index 00000000..881b8e60
--- /dev/null
+++ b/test/ccured_olden/power/build.c
@@ -0,0 +1,154 @@
+/* For copyright information, see olden_v1.0/COPYRIGHT */
+
+/* build.c
+ *
+ * By: Martin C. Carlisle
+ * 6/15/94
+ * builds the tree for the Power Pricing problem
+ *
+ * based on code by: Steve Lumetta, Sherry Li, and Ismail Khalil
+ * University of California at Berkeley
+ */
+
+#include "power.h"
+
+Root build_tree()
+{
+ register int i;
+ register Root t;
+#ifdef FUTURES
+ int j;
+ future_cell_int fc[NUM_FEEDERS];
+#else
+ register Lateral l;
+#endif
+
+ t = (Root) ALLOC(0,sizeof(*t));
+#ifdef FUTURES
+ for (i=0,j=0; i<NUM_FEEDERS; i++,j+=LATERALS_PER_FEEDER) {
+ FUTURE(j,LATERALS_PER_FEEDER,build_lateral,&fc[i]);
+ }
+ for (i=0; i<NUM_FEEDERS; i++) {
+ TOUCH(&fc[i]);
+ t->feeders[i]=(Lateral) fc[i].value;
+ }
+#else
+ for (i=0; i<NUM_FEEDERS; i++) {
+ /* Insert future here, split into two loops */
+ l = build_lateral(i*LATERALS_PER_FEEDER,LATERALS_PER_FEEDER);
+ t->feeders[i]=l;
+ }
+#endif
+ t->theta_R = 0.8;
+ t->theta_I = 0.16;
+ return t;
+}
+
+Lateral build_lateral(int i, int num)
+{
+ register int j,k;
+ register Lateral l;
+ register Branch b;
+#ifdef FUTURES
+ future_cell_int fc;
+#else
+ register Lateral next;
+#endif
+
+ if (num == 0) return NULL;
+
+#ifndef PLAIN
+ { int x,m,q,proc;
+ x = (i+num-1)*BRANCHES_PER_LATERAL+BRANCHES_PER_LATERAL-1;
+ m = 1000%__NumNodes;
+ q = 1000/__NumNodes;
+ if (x<m*(q+1)) proc = x/(q+1);
+ else proc = (x-m)/q;
+ l = (Lateral) ALLOC(__NumNodes-1-proc,sizeof(*l));
+ }
+#else
+ l = (Lateral) ALLOC(0,sizeof(*l));
+#endif
+
+#ifdef FUTURES
+ FUTURE(i,num-1,build_lateral,&fc);
+ b = build_branch(i*BRANCHES_PER_LATERAL,(num-1)*BRANCHES_PER_LATERAL,
+ BRANCHES_PER_LATERAL);
+#else
+ next = build_lateral(i,num-1);
+ b = build_branch(i*BRANCHES_PER_LATERAL,(num-1)*BRANCHES_PER_LATERAL,
+ BRANCHES_PER_LATERAL);
+#endif
+
+#ifdef FUTURES
+ TOUCH(&fc);
+ l->next_lateral = (Lateral) fc.value;
+#else
+ l->next_lateral = next;
+#endif
+ l->branch = b;
+ l->R = 1/300000.0;
+ l->X = 0.000001;
+ l->alpha = 0.0;
+ l->beta = 0.0;
+ return l;
+}
+
+Branch build_branch(int i, int j, int num)
+{
+ register Leaf l;
+ register Branch b;
+#ifdef FUTURES
+ future_cell_int fc;
+#endif
+
+ if (num == 0) return NULL;
+ /* allocate branch */
+#ifndef PLAIN
+ { int x,m,q,proc;
+ x = i+j+num-1;
+ m = 1000%__NumNodes;
+ q = 1000/__NumNodes;
+ if (x<m*(q+1)) proc = x/(q+1);
+ else proc = (x-m)/q;
+ b = (Branch) ALLOC(__NumNodes-1-proc,sizeof(*b));
+ }
+#else
+ b = (Branch) ALLOC(0,sizeof(*b));
+#endif
+
+ /* fill in children */
+#ifndef FUTURES
+ b->next_branch= build_branch(i,j,num-1);
+#else
+ FUTURE(i,j,num-1,build_branch,&fc);
+#endif
+
+ for (i=0; i<LEAVES_PER_BRANCH; i++) {
+ l = build_leaf();
+ b->leaves[i] = l;
+ }
+
+
+#ifdef FUTURES
+ TOUCH(&fc);
+ b->next_branch = (Branch) fc.value;
+#endif
+
+ /* fill in values */
+ b->R = 0.0001;
+ b->X = 0.00002;
+ b->alpha = 0.0;
+ b->beta = 0.0;
+ return b;
+}
+
+Leaf build_leaf()
+{
+ register Leaf l;
+
+ l = (Leaf) mymalloc(sizeof(*l));
+ l->D.P = 1.0;
+ l->D.Q = 1.0;
+ return l;
+}