Commit 736c2e8d authored by Charles Bouillaguet's avatar Charles Bouillaguet
Browse files

macaulay_gen : avoids empty columns

parent 30bf4492
......@@ -4,7 +4,7 @@
50 | 64 | 3 | 13 | 4 K | 356 K |
64 | 64 | 4 | 13 | 120 K | 22 M |
54 | 64 | 4 | 14 | 90 K | 17 M |
54 | 64 | 5 | 15 | 1.5M | 422 M | 1.6Go, 20-30 min de BWc sur un noeud de grvingt
54 | 64 | 5 | 15 | 1.5M | 422 M | 1.6Go, 23 min de BWc sur un noeud de dahu (n=128, m=256), 24min42 (n=256, m=512)
---+-----+---+----+-------------+------------+
80 | 80 | 3 | 14 | 6 K | 780 K |
75 | 80 | 4 | 15 | 220 K | 52 M |
......@@ -12,9 +12,10 @@
---+-----+---+----+-------------+------------+
80 | 160 | 3 | 20 | 13 K | 3 M |
80 | 160 | 4 | 21 | 493 K | 213 M |
79 | 160 | 4 | 22 | 480 K | 223 M |
73 | 160 | 5 | 24 | 8.5M | 6 G | ---> 16h de bwc ?
64 | 160 | 5 | 25 | 5.3M | 3.5G | ---> 8h de bwc ?
79 | 160 | 4 | 22 | 480 K | 223 M | --> 2x 5min de bwc
66 | 160 | 4 | 23 | 330 K | 150 M | --> 2^14 * 160s == 730h de BW
73 | 160 | 5 | 24 | 8.5M | 6 G | --> 16h de bwc ?
64 | 160 | 5 | 25 | 5.3M | 3.5G | --> 8h de bwc ?
64 --> 1024 jobs de BWc + enumeration de 39 variables. Viable ?
......@@ -24,3 +25,28 @@ Type I et IV dans https://www.mqchallenge.org/
Cible : n = 80 et m = 160 (type I)
m = 72 et n = 108 (type IV)
(*) sur un dahu
m = n = 64 ---> 3min 30s
n = 64, m=128 --> 2min 57s
n = 64, m=256 --> 3min 07s
n = 128, m=256 --> 2min 40s
n = 256, m=256 --> 2min 49s
n = 256, m=512 --> 2min 59s
empty columns = multiples de :
- x59*x60*x61
- x59*x60*x62
- x59*x61*x62
- x60*x61*x62
- x59*x60*x63
- x59*x61*x63
- x60*x61*x63
- x59*x62*x63
- x60*x62*x63
- x61*x62*x63
par les variables "spéciales" (300 à chaque fois)
......@@ -199,6 +199,7 @@ monomial_t *monomials; /* array to rank/unrank monomials */
monomial_t vmask; /* monomial that contains all special variables */
int nbad; /* total number of bad monomials */
int *bad_renumbering; /* renumber the bad monomials consecutively */
int *inv_bad_renumbering; /* renumber the bad monomials consecutively */
static inline monomial_t mkvar(int i)
{
......@@ -339,7 +340,6 @@ void monomial_setup_list()
double start = wtime();
vmask = (v == 0) ? 0 : mkvar(v) - 1;
log(0, "Monomials setup\n");
log(1, " - Counting monomials\n");
Nd[0] = 0;
......@@ -358,9 +358,11 @@ void monomial_setup_list()
log(1, " - Singling out bad monomials\n");
bad_renumbering = alloc_array(Nd[D + 1], sizeof(*bad_renumbering), "bad monomial renumbering");
inv_bad_renumbering = alloc_array(Nd[D + 1], sizeof(*bad_renumbering), "bad monomial renumbering");
for (int j = 0; j < Nd[D + 1]; j++) {
bool bad = monomial_is_bad(monomials[j]);
bad_renumbering[j] = bad ? nbad : -1;
inv_bad_renumbering[nbad] = j;
nbad += bad;
}
log(2, " - %d bad monomials\n", nbad);
......@@ -415,6 +417,8 @@ FILE * buffer_stream;
void output_setup()
{
rows_written = 0;
words_written = 0;
buffer_capacity = 1024*256;
buffer_size = 0;
buffer = alloc_array(buffer_capacity, sizeof(*buffer),"output buffer");
......@@ -693,7 +697,7 @@ int main(int argc, char **argv)
else
errx(1, "ERROR : more columns than rows (%d extra columns)", ncols - nrows);
log(0, "Starting matrix production\n");
log(0, "Matrix production (pass 1/2)\n");
matrix_setup();
output_setup();
char hnrows[10];
......@@ -702,31 +706,8 @@ int main(int argc, char **argv)
human_format(ncols, hncols);
log(1, " - Final size: %s rows, %s columns\n", hnrows, hncols);
char matrix_filename[256];
char rw_filename[256];
char cw_filename[256];
char ilog_filename[256];
char jlog_filename[256];
if (out_basename) {
if (strlen(out_basename) > 240)
errx(1, "output base name too long");
snprintf(matrix_filename, 256, "%s.bin", out_basename);
snprintf(rw_filename, 256, "%s.rw.bin", out_basename);
snprintf(cw_filename, 256, "%s.cw.bin", out_basename);
snprintf(ilog_filename, 256, "%s.ilog.bin", out_basename);
snprintf(jlog_filename, 256, "%s.jlog.bin", out_basename);
log(1, " - saving to %s / %s / %s / %s / %s\n", matrix_filename,
rw_filename, cw_filename, ilog_filename, jlog_filename);
buffer_stream = fopen(matrix_filename, "w");
if (buffer_stream == NULL)
errx(1, "cannot open %s", matrix_filename);
} else {
log(1, " - not saving matrix because no --out option given\n");
}
/* actual stuff */
/* actual stuff -- two passes because of potential empty columns */
for (int d = 2; d <= D; d++) {
log(1, " - Expanding to degree %d\n", d);
......@@ -740,43 +721,80 @@ int main(int argc, char **argv)
hnrows, hncols, hnnz, (double) words_written / rows_written, skipped);
}
log(0, "Sanity check\n");
log(0, "Detecting empty columns\n");
/* check empty cols & rows */
int nempty_rows = 0;
u64 nnzr = 0;
u64 nnz = 0;
for (int i = 0; i < nrows; i++) {
if (rw[i] <= 0)
nempty_rows++;
nnzr += rw[i];
nnz += rw[i];
}
if (nempty_rows == 0)
log(1, " - no empty rows (OK)\n");
else
errx(1, " - %d empty rows (KO)!\n", nempty_rows);
int nempty_cols = 0;
u64 nnzc = 0;
for (int j = 0; j < ncols; j++) {
if (cw[j] <= 0)
nempty_cols++;
nnzc += cw[j];
int ncols_before = ncols;
ncols = 0;
/* check empty columns ; enumerate all monomials again */
for (int j = 0; j < Nd[D + 1]; j++) {
int jj = bad_renumbering[j];
bad_renumbering[j] = ncols;
if (cw[jj] != 0)
ncols += 1;
}
if (nempty_cols == 0)
log(1, " - no empty column (OK)\n");
else
errx(1, " - %d empty columnss (KO)!\n", nempty_cols);
assert(nnzr == nnzc);
assert(words_written == nnzr + nrows);
log(1, " - exact dimensions %d x %d (%ld nnz)\n", nrows, ncols, nnzr);
if (out_basename) {
log(0, "Finalization\n");
flush_buffer();
fclose(buffer_stream);
write_array(rw_filename, rw, nrows);
write_array(cw_filename, cw, ncols);
write_array(ilog_filename, ilog, nrows);
write_array(jlog_filename, jlog, nrows);
log(1, " - %d empty columns\n", ncols_before - ncols);
if (out_basename == NULL) {
log(0, "Not saving matrix because no --out option given\n");
exit(EXIT_SUCCESS);
}
log(1, " - exact dimensions %d x %d (%ld nnz)\n", nrows, ncols, nnz);
char matrix_filename[256];
char rw_filename[256];
char cw_filename[256];
char ilog_filename[256];
char jlog_filename[256];
if (strlen(out_basename) > 240)
errx(1, "output base name too long");
snprintf(matrix_filename, 256, "%s.bin", out_basename);
snprintf(rw_filename, 256, "%s.rw.bin", out_basename);
snprintf(cw_filename, 256, "%s.cw.bin", out_basename);
snprintf(ilog_filename, 256, "%s.ilog.bin", out_basename);
snprintf(jlog_filename, 256, "%s.jlog.bin", out_basename);
log(1, " - saving to %s / %s / %s / %s / %s\n", matrix_filename,
rw_filename, cw_filename, ilog_filename, jlog_filename);
buffer_stream = fopen(matrix_filename, "w");
if (buffer_stream == NULL)
errx(1, "cannot open %s", matrix_filename);
log(0, "Matrix production (pass 2/2)\n");
output_setup();
/* actual stuff -- two passes because of potential empty columns */
for (int d = 2; d <= D; d++) {
log(1, " - Expanding to degree %d\n", d);
#pragma omp parallel
macaulay_sparse(d - 2);
char hnnz[10];
human_format(rows_written, hnrows);
human_format(words_written, hnnz);
log(2, " - %s rows, %s cols, %s nnz (%.0f per row), %d poly skipped\n",
hnrows, hncols, hnnz, (double) words_written / rows_written, skipped);
}
log(0, "Finalization\n");
flush_buffer();
fclose(buffer_stream);
write_array(rw_filename, rw, nrows);
write_array(cw_filename, cw, ncols);
write_array(ilog_filename, ilog, nrows);
write_array(jlog_filename, jlog, nrows);
exit(EXIT_SUCCESS);
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment