ejr / matchpres (public) (License: BSD) (since 2018-08-29) (hash sha1)
Ye olde thesis code implementing an auction-based weighted bipartite matching algorithm over MPI.
List of commits:
Subject Hash Author Date (UTC)
Prepare for massive runs. 5f9172fedbc636a986bd57c48cfa20bd1f1c17a7 Jason Riedy 2005-04-12 22:55:06
Update build stuff. 64cf1bc1ea3e70fdf320fe51a95f140f57076d80 Jason Riedy 2005-04-12 22:28:15
Add bigfloat changes 11ccd212bae7140c529c3431262b03d52c8a6309 Jason Riedy 2005-04-12 21:46:27
initial import 2aa81858e4a8c9d6c37158f5f32eccdaa5184643 Jason Riedy 2005-04-12 21:45:12
Commit 5f9172fedbc636a986bd57c48cfa20bd1f1c17a7 - Prepare for massive runs.
* Make.inc (CPPFLAGS): Not under umfpack dir, and don't collect stats.

* Makefile: Add matchmtx to general progs.

* auction.c (auction_scaling): Add a relgap parameter to toggle using
relative gap v. absolute gap.

* auction.h (auction_scaling): Add relgap param.

* matchmtx.c: New file. Stripped down parauction.c.

git-archimport-id: ejr@cs.berkeley.edu--superlu/matchpres--base--0--patch-3
Author: Jason Riedy
Author date (UTC): 2005-04-12 22:55
Committer name: Jason Riedy
Committer date (UTC): 2005-04-12 22:55
Parent(s): 64cf1bc1ea3e70fdf320fe51a95f140f57076d80
Signing key:
Tree: 82a71acb9939fb5c1f7ce1b45a5050a75ce99bf7
File Lines added Lines deleted
Make.inc 1 1
Makefile 4 1
auction.c 12 4
auction.h 1 1
matchmtx.c 20 140
File Make.inc changed (mode: 100644) (index 31b341a..5fec71e)
... ... MPICC = CC=$(CC) mpicc
11 11 RANLIB = ranlib RANLIB = ranlib
12 12
13 13 CC = icc -Qoption,cpp,--extended_float_types CC = icc -Qoption,cpp,--extended_float_types
14 CPPFLAGS = -I../../Include
14 CPPFLAGS = -DNOSTATS
15 15 CFLAGS = -g -O2 -Wall "-DBIGFLOAT_T=_Quad" "-DSMUT_BIGFLOAT_T=_Quad" CFLAGS = -g -O2 -Wall "-DBIGFLOAT_T=_Quad" "-DSMUT_BIGFLOAT_T=_Quad"
16 16 CFLAGS_NOOPT = -g -O0 -Wall "-DBIGFLOAT_T=_Quad" "-DSMUT_BIGFLOAT_T=_Quad" CFLAGS_NOOPT = -g -O0 -Wall "-DBIGFLOAT_T=_Quad" "-DSMUT_BIGFLOAT_T=_Quad"
17 17 F77 = ifort F77 = ifort
File Makefile changed (mode: 100644) (index 5ea3e5f..3221e36)
1 1 include Make.inc include Make.inc
2 2
3 PROGS_BASIC = readbin writebin transposebin
3 PROGS_BASIC = readbin writebin transposebin matchmtx
4 4 #redist1 redist2 redist3 redist4 \ #redist1 redist2 redist3 redist4 \
5 5 # colcomp mpitransposebin mpitransposebin_root # colcomp mpitransposebin mpitransposebin_root
6 6 PROGS = $(PROGS_BASIC) PROGS = $(PROGS_BASIC)
 
... ... libmc64.a: mc64ad.o mc21.o lsame.o dlamch.o
54 54 seqauction.o: seqauction.c smut.h timer.h seqauction.o: seqauction.c smut.h timer.h
55 55 seqauction: seqauction.o auction.o libsmut.a libmc64.a seqauction: seqauction.o auction.o libsmut.a libmc64.a
56 56 $(F77) $(FFLAGS) -o $@ $^ $(LDLIBS) $(F77) $(FFLAGS) -o $@ $^ $(LDLIBS)
57 matchmtx.o: matchmtx.c smut.h timer.h
58 matchmtx: matchmtx.o auction.o libsmut.a
59 $(CC) $(FFLAGS) -o $@ $^ $(LDLIBS)
57 60
58 61 stripe_auction.o: stripe_auction.c stripe_auction.h auction.h smut.h stripe_auction.o: stripe_auction.c stripe_auction.h auction.h smut.h
59 62 $(MPICC) $(CFLAGS) -c -o $@ $< $(MPICC) $(CFLAGS) -c -o $@ $<
File auction.c changed (mode: 100644) (index 76da2b1..5b5a5bd)
... ... int
1440 1440 auction_scaling (const struct spcsr_t A, const double *b_in, auction_scaling (const struct spcsr_t A, const double *b_in,
1441 1441 int *match_in, int *match_in,
1442 1442 double *price_in, double *price_in,
1443 const double mu_final)
1443 const double mu_final, const int relgap)
1444 1444 { {
1445 1445 int n_unmatched; int n_unmatched;
1446 1446 int *unmatched; int *unmatched;
 
... ... auction_scaling (const struct spcsr_t A, const double *b_in,
1579 1579 int j; int j;
1580 1580
1581 1581 pmax = -HUGE_VAL; pmax = -HUGE_VAL;
1582 auction_eval_gap (A, b, match, price, &gap);
1582 if (!relgap) {
1583 auction_eval_gap (A, b, match, price, &gap);
1583 1584 #if 1 #if 1
1584 if (gap < A.nc * mu_final) break; /* before clearing match */
1585 if (gap < A.nc * mu_final) break; /* before clearing match */
1585 1586 #else #else
1586 if (gap < mu_final) break; /* before clearing match */
1587 if (gap < mu_final) break; /* before clearing match */
1587 1588 #endif #endif
1589 }
1590 else {
1591 double pval, dval;
1592 auction_eval_primal_mdual (A, b, match, price, &pval, &dval);
1593 gap = dval - pval;
1594 if (gap / pval < mu_final) break;
1595 }
1588 1596 new_mu = theta * (gap) / A.nc; new_mu = theta * (gap) / A.nc;
1589 1597 if (new_mu < 8.0*mu_final) new_mu = mu_final; if (new_mu < 8.0*mu_final) new_mu = mu_final;
1590 1598 if (new_mu > theta * mu) new_mu = theta * mu; if (new_mu > theta * mu) new_mu = theta * mu;
File auction.h changed (mode: 100644) (index 2d852fb..a1c1b2d)
... ... int auction_simple_cache (const struct spcsr_t, const double *b,
20 20 const double mu_min); const double mu_min);
21 21 int auction_scaling (const struct spcsr_t, const double *b, int auction_scaling (const struct spcsr_t, const double *b,
22 22 int *match, double *price, int *match, double *price,
23 const double mu_min);
23 const double mu_min, const int relgap);
24 24
25 25 void auction_eval_primal_mdual (const struct spcsr_t, const double *b, void auction_eval_primal_mdual (const struct spcsr_t, const double *b,
26 26 const int *match, const double *price, const int *match, const double *price,
File matchmtx.c copied from file seqauction.c (similarity 51%) (mode: 100644) (index 6c4e1e7..2eedf95)
24 24 #define restrict #define restrict
25 25 #endif #endif
26 26
27 static int icntl[10];
28 void mc64ad_ (int* JOB,
29 int* N,
30 int* NE,
31 int* IP,
32 int* IRN,
33 double* A,
34 int* NUM,
35 int* CPERM,
36 int* LIW,
37 int* IW,
38 int* LDW,
39 double* DW,
40 int* ICNTL,
41 int* INFO);
42
43 void mc64wd_ (int* n, int* ne, int* ip, int* irn, double* a,
44 int* iperm, int* num, int* jperm, int* out,
45 int* pr, int* q, int* L, double* U, double* D);
46
47 27 int int
48 28 main (int argc, char **argv) main (int argc, char **argv)
49 29 { {
 
... ... main (int argc, char **argv)
53 33 struct spcsr_t A; struct spcsr_t A;
54 34
55 35 double mu_min; double mu_min;
36 int relgap = 0;
56 37
57 38 double *R, *C; double *R, *C;
58 39 double *expint; double *expint;
 
... ... main (int argc, char **argv)
81 62 return -1; return -1;
82 63 } }
83 64
84 if (argc > 2) {
85 fout = fopen (argv[2], "wb");
86 }
65 mu_min = 1.0 / A.nr;
66 if (argc > 3)
67 mu_min = strtod(argv[3], NULL);
68 if (argc > 4)
69 relgap = 1;
87 70
88 71 err = spcsr_load_binfile (f, &A); err = spcsr_load_binfile (f, &A);
89 72 if (err) { if (err) {
 
... ... main (int argc, char **argv)
111 94 spcsr_lascale (&A, R, C); spcsr_lascale (&A, R, C);
112 95 #endif #endif
113 96
114 #if 1
97 #if 0
115 98 auction_toexpint (&A, expint); auction_toexpint (&A, expint);
116 99 #else #else
117 100 auction_toexp (&A, expint); auction_toexp (&A, expint);
 
... ... main (int argc, char **argv)
129 112 printf ("expint max: %g , min %g\n", mx, mn); printf ("expint max: %g , min %g\n", mx, mn);
130 113 } }
131 114
132 cacheblast();
133
134 mu_min = 1.0 / A.nr;
135 /* be approximate */
136 /*mu_min = 1.0;*/
137 /*mu_min = 100.0 / A.nr;*/
138
139 #if 0
140 {
141 int n_unmatched;
142 double mu_min;
143 double p, d;
144
145 initialize_timer (&timer);
146 start_timer (&timer);
147 n_unmatched = auction_simple (A, expint, match, price, mu_min);
148 stop_timer (&timer);
149 auction_eval_primal_mdual (A, expint, match, price, &p, &d);
150 printf ("* Primal: %20g\n* Dual: %20g\n* Time: %20g\n", p, d,
151 timer_duration(timer));
152 a_printstats ();
153 }
154 #endif
155
156 cacheblast();
157
158 115 memset (match, -1, A.nc * sizeof(int)); memset (match, -1, A.nc * sizeof(int));
159 116 memset (price, 0, A.nc * sizeof(double)); memset (price, 0, A.nc * sizeof(double));
117
160 118 CALLGRIND_START_INSTRUMENTATION(); CALLGRIND_START_INSTRUMENTATION();
161 119 initialize_timer (&timer); initialize_timer (&timer);
162 120 start_timer (&timer); start_timer (&timer);
163 errflg = auction_scaling (A, expint, match, price, mu_min);
121 errflg = auction_scaling (A, expint, match, price, mu_min, relgap);
164 122 stop_timer (&timer); stop_timer (&timer);
165 123 if (errflg) if (errflg)
166 124 fprintf (stderr, "Errflg: %d\n", errflg); fprintf (stderr, "Errflg: %d\n", errflg);
167 125
168 126
127 CALLGRIND_STOP_INSTRUMENTATION();
128
169 129 auction_eval_primal_mdual (A, expint, match, price, &auction_primal, &d); auction_eval_primal_mdual (A, expint, match, price, &auction_primal, &d);
170 130 printf ("Primal: %20g\nDual: %20g\nTime: %20g\nmu_min: %20g\n", printf ("Primal: %20g\nDual: %20g\nTime: %20g\nmu_min: %20g\n",
171 131 auction_primal, d, timer_duration(timer), mu_min); auction_primal, d, timer_duration(timer), mu_min);
172 132
173 a_printstats();
174
175 133 { {
176 134 int i, j; int i, j;
177 135 for (j = 0; j < A.nc; ++j) { for (j = 0; j < A.nc; ++j) {
 
... ... main (int argc, char **argv)
191 149 } }
192 150 } }
193 151
194 if (fout) {
195 int tag = 1;
196 fwrite (&tag, sizeof(int), 1, fout);
197 fwrite (&A.nc, sizeof(int), 1, fout);
198 fwrite (match, sizeof(int), A.nc, fout);
199 }
200
201 #if 0
202 cacheblast();
203
204 {
205 int n_unmatched;
206 double mu_min;
207 double p, d;
208
209 initialize_timer (&timer);
210 start_timer (&timer);
211 n_unmatched = auction_scaling_cache (A, expint, match, price, mu_min);
212 stop_timer (&timer);
213 auction_eval_primal_mdual (A, expint, match, price, &p, &d);
214 printf ("_ Primal: %20g\n_ Dual: %20g\n_ Time: %20g\n", p, d,
215 timer_duration(timer));
216 a_printstats ();
217 }
218 #endif
219
220 CALLGRIND_STOP_INSTRUMENTATION();
221
222 cacheblast();
223
224 /* mc64 */
225 {
226 int job = 4; /* sum of diag, already log scale */
227 int num_on_diag = 0;
228 int liw;
229 int *iw;
230 int ldw;
231 double *dw;
232 int info = 0;
233
234 int i, k;
235
236 for (i = 0; i <= A.nr; ++i)
237 ++A.rowoff[i];
238 for (k = 0; k < A.nent; ++k)
239 ++A.colind[k];
240
241 initialize_timer (&timer);
242 start_timer (&timer);
243 liw = 5 * A.nr;
244 iw = malloc (liw * sizeof(int));
245 ldw = 2 * A.nr + A.nent;
246 dw = malloc (ldw * sizeof(double));
247 memset (icntl, 0, 10 * sizeof(int));
248 icntl[0] = 6; icntl[1] = 6; icntl[2] = -1;
249 #if !defined(NDEBUG)
250 icntl[3] = 0;
251 #else
252 icntl[3] = -1;
253 #endif
254 mc64ad_ (&job, &A.nr, &A.nent, A.rowoff, A.colind, expint,
255 &num_on_diag, invmatch, &liw, iw, &ldw, dw, icntl,
256 &info);
257 free (iw);
258 free (dw);
259 stop_timer (&timer);
260
261 for (i = 0; i < A.nr; ++i) --invmatch[i];
262 for (i = 0; i <= A.nr; ++i) --A.rowoff[i];
263 for (k = 0; k < A.nent; ++k)
264 --A.colind[k];
265
266 }
267
268 for (i = 0; i < A.nr; ++i) {
269 if (invmatch[i] < 0) printf("mc64: row %d is unmatched\n", i);
152 if (argc > 2) {
153 fout = fopen (argv[2], "wb");
270 154 } }
271 155
272 memset (match, -1, A.nc * sizeof(int));
273 for (i = 0; i < A.nr; ++i) {
274 const int j = invmatch[i];
275 match[j] = i;
276 }
277 for (j = 0; j < A.nc; ++j) {
278 if (match[j] < 0) printf("mc64: col %d is unmatched\n", j);
156 if (fout) {
157 int k;
158 smut_write_bin_vectors (1, A.nc, price, fout);
159 for (k = 0; k < A.nc; ++k) {
160 price[k] = match[k];
161 }
162 smut_write_bin_vectors (1, A.nc, price, fout);
279 163 } }
280 auction_eval_primal_mdual (A, expint, invmatch, price, &mc64_primal, &d);
281 printf ("mc64 Primal: %20g\nmc64 Time: %20g\n", mc64_primal,
282 timer_duration(timer));
283 printf (" primal diff: %20g\n", auction_primal - mc64_primal);
284 164
285 165 free (price); free (price);
286 166 free (invmatch); free (invmatch);
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/ejr/matchpres

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/ejr/matchpres

Clone this repository using git:
git clone git://git.rocketgit.com/user/ejr/matchpres

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main