File: testOrderViaBestOfNDandMS.c

package info (click to toggle)
spooles 2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 19,012 kB
  • sloc: ansic: 146,834; csh: 3,615; makefile: 2,040; perl: 74
file content (145 lines) | stat: -rw-r--r-- 4,472 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*  testOrderViaBestOfNDandMS.c  */

#include "../misc.h"
#include "../../timings.h"

/*--------------------------------------------------------------------*/
int
main ( int argc, char *argv[] )
/*
   --------------------------------------
   order a graph via the best of a nested 
   dissection and a multisection ordering

   created -- 98aug26, cca
   --------------------------------------
*/
{
char     *inGraphFileName, *outETreeFileName ;
double   cputotal, t1, t2 ;
ETree    *frontETree ;
int      maxdomainsize, maxsize, maxzeros, msglvl, nvtx, rc, seed ;
Graph    *graph ;
FILE     *msgFile ;

if ( argc != 9 ) {
   fprintf(stdout, 
"\n\n usage : %s msglvl msgFile GraphFile maxdomainsize "
"\n         maxzeros maxsize seed ETreeFile"
"\n    msglvl        -- message level"
"\n    msgFile       -- message file"
"\n    GraphFile     -- input graph file, must be *.graphf or *.graphb"
"\n    maxdomainsize -- maximum size for a subgraph not to be split"
"\n    maxzeros      -- maximum # of zeros in a front"
"\n    maxsize       -- maximum # of internal columns in a front"
"\n    seed          -- random number seed"
"\n    ETreeFile     -- output ETree file, must be *.etreef or *.etreeb"
"\n",
argv[0]) ;
   return(0) ;
}
msglvl = atoi(argv[1]) ;
if ( strcmp(argv[2], "stdout") == 0 ) {
   msgFile = stdout ;
} else if ( (msgFile = fopen(argv[2], "a")) == NULL ) {
   fprintf(stderr, "\n fatal error in %s"
           "\n unable to open file %s\n",
           argv[0], argv[2]) ;
   return(-1) ;
}
inGraphFileName  = argv[3] ;
maxdomainsize    = atoi(argv[4]) ;
maxzeros         = atoi(argv[5]) ;
maxsize          = atoi(argv[6]) ;
seed             = atoi(argv[7]) ;
outETreeFileName = argv[8] ;
fprintf(msgFile, 
        "\n %s "
        "\n msglvl        -- %d" 
        "\n msgFile       -- %s" 
        "\n GraphFile     -- %s" 
        "\n maxdomainsize -- %d" 
        "\n maxzeros      -- %d" 
        "\n maxsize       -- %d" 
        "\n seed          -- %d" 
        "\n ETreeFile     -- %s" 
        "\n",
        argv[0], msglvl, argv[2], inGraphFileName, maxdomainsize, 
        maxzeros, maxsize, seed, outETreeFileName) ;
fflush(msgFile) ;
/*
   ------------------------
   read in the Graph object
   ------------------------
*/
graph = Graph_new() ;
if ( strcmp(inGraphFileName, "none") == 0 ) {
   fprintf(msgFile, "\n no file to read from") ;
   exit(0) ;
}
MARKTIME(t1) ;
rc = Graph_readFromFile(graph, inGraphFileName) ;
MARKTIME(t2) ;
fprintf(msgFile, "\n CPU %8.3f : read in graph from file %s",
        t2 - t1, inGraphFileName) ;
nvtx = graph->nvtx ;
if ( rc != 1 ) {
   fprintf(msgFile, "\n return value %d from Graph_readFromFile(%p,%s)",
           rc, graph, inGraphFileName) ;
   exit(-1) ;
}
if ( msglvl > 2 ) {
   fprintf(msgFile, "\n\n after reading Graph object from file %s",
           inGraphFileName) ;
   Graph_writeForHumanEye(graph, msgFile) ;
   fflush(msgFile) ;
}
/*
   --------------------------------------------------------
   order the graph using nested dissection and multisection
   --------------------------------------------------------
*/
MARKTIME(t1) ;
frontETree = orderViaBestOfNDandMS(graph, maxdomainsize, maxzeros,
                               maxsize, seed, msglvl, msgFile) ;
MARKTIME(t2) ;
fprintf(msgFile, 
    "\n\n CPU %8.3f : order the graph via best of ND and MS", t2 - t1) ;
if ( msglvl > 2 ) {
   ETree_writeForHumanEye(frontETree, msgFile) ;
   fflush(msgFile) ;
}
fprintf(msgFile,
        "\n\n %d fronts, %d indices, %d entries, %.0f operations",
        frontETree->nfront,
        ETree_nFactorIndices(frontETree),
        ETree_nFactorEntries(frontETree, SPOOLES_SYMMETRIC),
        ETree_nFactorOps(frontETree, SPOOLES_REAL, SPOOLES_SYMMETRIC)) ;
/*
   -------------------------------------
   optionally write out the ETree object
   -------------------------------------
*/
if ( strcmp(outETreeFileName, "none") != 0 ) {
   fprintf(msgFile, "\n\n writing out ETree to file %s", 
           outETreeFileName) ;
   MARKTIME(t1) ;
   ETree_writeToFile(frontETree, outETreeFileName) ;
   MARKTIME(t2) ;
   fprintf(msgFile, "\n CPU %8.3f : write front tree to file %s",
           t2 - t1, outETreeFileName) ;
}
/*
   ------------------------
   free the working storage
   ------------------------
*/
Graph_free(graph) ;
ETree_free(frontETree) ;

fprintf(msgFile, "\n") ;
fclose(msgFile) ;

return(1) ; }

/*--------------------------------------------------------------------*/