aboutsummaryrefslogtreecommitdiffstats
path: root/test/ccured_olden/mst/makegraph.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/mst/makegraph.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/mst/makegraph.c')
-rw-r--r--test/ccured_olden/mst/makegraph.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/test/ccured_olden/mst/makegraph.c b/test/ccured_olden/mst/makegraph.c
new file mode 100644
index 00000000..c99fad96
--- /dev/null
+++ b/test/ccured_olden/mst/makegraph.c
@@ -0,0 +1,93 @@
+/* For copyright information, see olden_v1.0/COPYRIGHT */
+
+#include "mst.h"
+#include "ssplain.h"
+
+#define CONST_m1 10000
+#define CONST_b 31415821
+#define RANGE 2048
+static int HashRange;
+
+static int mult(int p, int q)
+{
+ int p1, p0, q1, q0;
+
+ p1=p/CONST_m1; p0=p%CONST_m1;
+ q1=q/CONST_m1; q0=q%CONST_m1;
+ return (((p0*q1+p1*q0) % CONST_m1)*CONST_m1+p0*q0);
+}
+
+static int mst_random(int seed)
+{
+ int tmp;
+ tmp = (mult(seed,CONST_b)+1);
+ return tmp;
+}
+
+static int compute_dist(int i,int j, int numvert)
+{
+ int less, gt;
+ if (i<j) {less = i; gt = j;} else {less = j; gt = i;}
+ return (mst_random(less*numvert+gt) % RANGE)+1;
+}
+
+static int hashfunc(unsigned int key)
+{
+ return ((key>>4) % HashRange);
+}
+
+static void AddEdges(Graph retval, int numvert)
+{
+ Vertex src, dest;
+ Hash hash;
+ int i, j, dist, num_inserted = 0;
+
+ for (j = 0; j < numvert; j++)
+ {
+ src = &(retval->vlist[j]);
+ hash = src->edgehash;
+
+ for (i=0; i<numvert; i++)
+ {
+ if (i!=j)
+ {
+ dist = compute_dist(i,j,numvert);
+ dest = &(retval->vlist[i]);
+ HashInsert((void *) dist,(unsigned int) dest,hash);
+ num_inserted++;
+ }
+ } /* for i */
+ } /* for j */
+
+ chatting("%d edges inserted\n", num_inserted);
+}
+
+Graph MakeGraph(int numvert)
+{
+ int i;
+ Vertex vf, vt;
+ Graph retval;
+
+ retval = (Graph) malloc (sizeof(*retval));
+
+ chatting("Make phase 1: Creating hash tables\n");
+ retval->vlist = (Vertex) malloc (numvert*(sizeof(*vf)));
+ vt = NULL;
+
+ for (i = numvert - 1; i >= 0; i--)
+ {
+ vf = &(retval->vlist[i]);
+ HashRange = numvert/4;
+ vf->mindist = 9999999;
+ vf->edgehash = MakeHash(HashRange,hashfunc);
+ vf->next = vt;
+ vt=vf;
+ }
+
+ chatting("Make phase 3: Creating graph\n");
+ AddEdges(retval, numvert);
+ chatting("Make returning\n");
+ return retval;
+}
+
+