Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: from frugalos_dyn to master #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ liberation_01_SOURCES = liberation_01.c
decoder_SOURCES = decoder.c
encoder_SOURCES = encoder.c

LDADD = ../src/libJerasure.la
LDADD = ../src/libFrugalosJerasure.la
decoder_LDADD = $(LDADD) ../src/libtiming.a
encoder_LDADD = $(LDADD) ../src/libtiming.a
reed_sol_time_gf_LDADD = $(LDADD) ../src/libtiming.a
10 changes: 6 additions & 4 deletions Examples/cauchy_01.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "galois.h" /* gf2_t */
#include "cauchy.h"
#include "jerasure.h"
#include "reed_sol.h"
Expand All @@ -74,6 +75,7 @@ int main(int argc, char **argv)
int n;
int i, no, w;
int *bitmatrix;
static gf2_t g;

if (argc != 3) usage(NULL);
if (sscanf(argv[1], "0x%x", &n) == 0) {
Expand All @@ -86,7 +88,7 @@ int main(int argc, char **argv)
if (n >= (1 << w)) usage("Bad n/w combination (n not between 0 and 2^w-1)\n");
}

bitmatrix = jerasure_matrix_to_bitmatrix(1, 1, w, &n);
bitmatrix = jerasure_matrix_to_bitmatrix(&g, 1, 1, w, &n);
printf("<HTML><title>cauchy_01 %u %d</title>\n", w, n);
printf("<HTML><h3>cauchy_01 %u %d</h3>\n", w, n);
printf("<pre>\n");
Expand All @@ -100,13 +102,13 @@ int main(int argc, char **argv)

no = 0;
for (i = 0; i < w*w; i++) no += bitmatrix[i];
if (no != cauchy_n_ones(n, w)) {
if (no != cauchy_n_ones(&g, n, w)) {
fprintf(stderr, "Jerasure error: # ones in the bitmatrix (%d) doesn't match cauchy_n_ones() (%d).\n",
no, cauchy_n_ones(n, w));
no, cauchy_n_ones(&g, n, w));
exit(1);
}

printf("# Ones: %d\n", cauchy_n_ones(n, w));
printf("# Ones: %d\n", cauchy_n_ones(&g, n, w));

return 0;
}
16 changes: 9 additions & 7 deletions Examples/cauchy_02.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <string.h>
#include <gf_rand.h>
#include "jerasure.h"
#include "galois.h"
#include "cauchy.h"

#define talloc(type, num) (type *) malloc(sizeof(type)*(num))
Expand Down Expand Up @@ -120,6 +121,7 @@ int main(int argc, char **argv)
int *erasures, *erased;
double mstats[3], sstats[3];
uint32_t seed;
static gf2_t g;

if (argc != 5) usage(NULL);
if (sscanf(argv[1], "%d", &k) == 0 || k <= 0) usage("Bad k");
Expand All @@ -128,7 +130,7 @@ int main(int argc, char **argv)
if (sscanf(argv[4], "%d", &seed) == 0) usage("Bad seed");
if (w < 30 && (k+m) > (1 << w)) usage("k + m is too big");

matrix = cauchy_original_coding_matrix(k, m, w);
matrix = cauchy_original_coding_matrix(&g, k, m, w);
if (matrix == NULL) {
usage("couldn't make coding matrix");
}
Expand Down Expand Up @@ -159,11 +161,11 @@ int main(int argc, char **argv)
jerasure_print_matrix(matrix, m, k, w);
printf("</pre>\n");

bitmatrix = jerasure_matrix_to_bitmatrix(k, m, w, matrix);
bitmatrix = jerasure_matrix_to_bitmatrix(&g, k, m, w, matrix);

no = 0;
for (i = 0; i < k*m; i++) {
no += cauchy_n_ones(matrix[i], w);
no += cauchy_n_ones(&g, matrix[i], w);
}

printf("The bitmatrix, which has %d one%s:<p><pre>\n", no, (no == 1) ? "" : "s");
Expand Down Expand Up @@ -191,11 +193,11 @@ int main(int argc, char **argv)
ccopy[i] = talloc(char, sizeof(long)*w);
}

jerasure_bitmatrix_encode(k, m, w, bitmatrix, data, coding, w*sizeof(long), sizeof(long));
jerasure_bitmatrix_encode(&g, k, m, w, bitmatrix, data, coding, w*sizeof(long), sizeof(long));
jerasure_get_stats(mstats);

schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix);
jerasure_schedule_encode(k, m, w, schedule, data, ccopy, w*sizeof(long), sizeof(long));
jerasure_schedule_encode(&g, k, m, w, schedule, data, ccopy, w*sizeof(long), sizeof(long));
jerasure_get_stats(sstats);

printf("<p>Encoding with jerasure_bitmatrix_encode() - Bytes XOR'd: %.0lf.<br>\n", mstats[0]);
Expand Down Expand Up @@ -234,7 +236,7 @@ int main(int argc, char **argv)
print_array(coding, m, sizeof(long)*w, sizeof(long), "C");
printf("<hr>\n");

jerasure_bitmatrix_decode(k, m, w, bitmatrix, 0, erasures, data, coding, w*sizeof(long), sizeof(long));
jerasure_bitmatrix_decode(&g, k, m, w, bitmatrix, 0, erasures, data, coding, w*sizeof(long), sizeof(long));
jerasure_get_stats(mstats);

printf("<p>Decoded with jerasure_bitmatrix_decode - Bytes XOR'd: %.0lf.<br>\n", mstats[0]);
Expand All @@ -250,7 +252,7 @@ int main(int argc, char **argv)
bzero((erasures[i] < k) ? data[erasures[i]] : coding[erasures[i]-k], sizeof(long)*w);
}

jerasure_schedule_decode_lazy(k, m, w, bitmatrix, erasures, data, coding, w*sizeof(long), sizeof(long), 1);
jerasure_schedule_decode_lazy(&g, k, m, w, bitmatrix, erasures, data, coding, w*sizeof(long), sizeof(long), 1);
jerasure_get_stats(sstats);

printf("jerasure_schedule_decode_lazy - Bytes XOR'd: %.0lf.<br>\n", sstats[0]);
Expand Down
18 changes: 10 additions & 8 deletions Examples/cauchy_03.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <string.h>
#include <gf_rand.h>
#include "jerasure.h"
#include "galois.h"
#include "cauchy.h"

#define talloc(type, num) (type *) malloc(sizeof(type)*(num))
Expand Down Expand Up @@ -125,6 +126,7 @@ int main(int argc, char **argv)
double mstats[3], sstats[3];
uint32_t seed;
int *X, *Y;
static gf2_t g;

if (argc != 5) usage(NULL);
if (sscanf(argv[1], "%d", &k) == 0 || k <= 0) usage("Bad k");
Expand All @@ -138,7 +140,7 @@ int main(int argc, char **argv)
for (i = 0; i < m; i++) X[i] = i;
for (i = 0; i < k; i++) Y[i] = m+i;

matrix = cauchy_xy_coding_matrix(k, m, w, X, Y);
matrix = cauchy_xy_coding_matrix(&g, k, m, w, X, Y);
if (matrix == NULL) {
usage("couldn't make coding matrix");
}
Expand Down Expand Up @@ -167,7 +169,7 @@ int main(int argc, char **argv)
jerasure_print_matrix(matrix, m, k, w);
printf("</pre>\n");

cauchy_improve_coding_matrix(k, m, w, matrix);
cauchy_improve_coding_matrix(&g, k, m, w, matrix);

printf("<hr>\n");
printf("Here is the matrix improved with <b>cauchy_improve_coding_matrix()</b>.\n");
Expand All @@ -176,11 +178,11 @@ int main(int argc, char **argv)
jerasure_print_matrix(matrix, m, k, w);
printf("</pre>\n");

bitmatrix = jerasure_matrix_to_bitmatrix(k, m, w, matrix);
bitmatrix = jerasure_matrix_to_bitmatrix(&g, k, m, w, matrix);

no = 0;
for (i = 0; i < k*m; i++) {
no += cauchy_n_ones(matrix[i], w);
no += cauchy_n_ones(&g, matrix[i], w);
}

printf("The bitmatrix, which has %d one%s:<p><pre>\n", no, (no == 1) ? "" : "s");
Expand Down Expand Up @@ -209,11 +211,11 @@ int main(int argc, char **argv)
ccopy[i] = talloc(char, sizeof(long)*w);
}

jerasure_bitmatrix_encode(k, m, w, bitmatrix, data, coding, w*sizeof(long), sizeof(long));
jerasure_bitmatrix_encode(&g, k, m, w, bitmatrix, data, coding, w*sizeof(long), sizeof(long));
jerasure_get_stats(mstats);

schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix);
jerasure_schedule_encode(k, m, w, schedule, data, ccopy, w*sizeof(long), sizeof(long));
jerasure_schedule_encode(&g, k, m, w, schedule, data, ccopy, w*sizeof(long), sizeof(long));
jerasure_get_stats(sstats);

printf("<p>Encoding with jerasure_bitmatrix_encode() - Bytes XOR'd: %.0lf.<br>\n", mstats[0]);
Expand Down Expand Up @@ -252,7 +254,7 @@ int main(int argc, char **argv)
print_array(coding, m, sizeof(long)*w, sizeof(long), "C");
printf("<hr>\n");

jerasure_bitmatrix_decode(k, m, w, bitmatrix, 0, erasures, data, coding, w*sizeof(long), sizeof(long));
jerasure_bitmatrix_decode(&g, k, m, w, bitmatrix, 0, erasures, data, coding, w*sizeof(long), sizeof(long));
jerasure_get_stats(mstats);

printf("<p>Decoded with jerasure_bitmatrix_decode - Bytes XOR'd: %.0lf.<br>\n", mstats[0]);
Expand All @@ -268,7 +270,7 @@ int main(int argc, char **argv)
bzero((erasures[i] < k) ? data[erasures[i]] : coding[erasures[i]-k], sizeof(long)*w);
}

jerasure_schedule_decode_lazy(k, m, w, bitmatrix, erasures, data, coding, w*sizeof(long), sizeof(long), 1);
jerasure_schedule_decode_lazy(&g, k, m, w, bitmatrix, erasures, data, coding, w*sizeof(long), sizeof(long), 1);
jerasure_get_stats(sstats);

printf("jerasure_schedule_decode_lazy - Bytes XOR'd: %.0lf.<br>\n", sstats[0]);
Expand Down
16 changes: 9 additions & 7 deletions Examples/cauchy_04.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <string.h>
#include <gf_rand.h>
#include "jerasure.h"
#include "galois.h"
#include "cauchy.h"

#define talloc(type, num) (type *) malloc(sizeof(type)*(num))
Expand Down Expand Up @@ -121,6 +122,7 @@ int main(int argc, char **argv)
int *erasures, *erased;
double mstats[3], sstats[3];
uint32_t seed;
static gf2_t g;

if (argc != 5) usage(NULL);
if (sscanf(argv[1], "%d", &k) == 0 || k <= 0) usage("Bad k");
Expand All @@ -129,7 +131,7 @@ int main(int argc, char **argv)
if (sscanf(argv[4], "%d", &seed) == 0) usage("Bad seed");
if (w < 30 && (k+m) > (1 << w)) usage("k + m is too big");

matrix = cauchy_good_general_coding_matrix(k, m, w);
matrix = cauchy_good_general_coding_matrix(&g, k, m, w);
if (matrix == NULL) {
usage("couldn't make coding matrix");
}
Expand Down Expand Up @@ -158,11 +160,11 @@ int main(int argc, char **argv)
jerasure_print_matrix(matrix, m, k, w);
printf("</pre>\n");

bitmatrix = jerasure_matrix_to_bitmatrix(k, m, w, matrix);
bitmatrix = jerasure_matrix_to_bitmatrix(&g, k, m, w, matrix);

no = 0;
for (i = 0; i < k*m; i++) {
no += cauchy_n_ones(matrix[i], w);
no += cauchy_n_ones(&g, matrix[i], w);
}

printf("The bitmatrix, which has %d one%s:<p><pre>\n", no, (no == 1) ? "" : "s");
Expand Down Expand Up @@ -191,11 +193,11 @@ int main(int argc, char **argv)
ccopy[i] = talloc(char, sizeof(long)*w);
}

jerasure_bitmatrix_encode(k, m, w, bitmatrix, data, coding, w*sizeof(long), sizeof(long));
jerasure_bitmatrix_encode(&g, k, m, w, bitmatrix, data, coding, w*sizeof(long), sizeof(long));
jerasure_get_stats(mstats);

schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix);
jerasure_schedule_encode(k, m, w, schedule, data, ccopy, w*sizeof(long), sizeof(long));
jerasure_schedule_encode(&g, k, m, w, schedule, data, ccopy, w*sizeof(long), sizeof(long));
jerasure_get_stats(sstats);

printf("<p>Encoding with jerasure_bitmatrix_encode() - Bytes XOR'd: %.0lf.<br>\n", mstats[0]);
Expand Down Expand Up @@ -234,7 +236,7 @@ int main(int argc, char **argv)
print_array(coding, m, sizeof(long)*w, sizeof(long), "C");
printf("<hr>\n");

jerasure_bitmatrix_decode(k, m, w, bitmatrix, 0, erasures, data, coding, w*sizeof(long), sizeof(long));
jerasure_bitmatrix_decode(&g, k, m, w, bitmatrix, 0, erasures, data, coding, w*sizeof(long), sizeof(long));
jerasure_get_stats(mstats);

printf("<p>Decoded with jerasure_bitmatrix_decode - Bytes XOR'd: %.0lf.<br>\n", mstats[0]);
Expand All @@ -250,7 +252,7 @@ int main(int argc, char **argv)
bzero((erasures[i] < k) ? data[erasures[i]] : coding[erasures[i]-k], sizeof(long)*w);
}

jerasure_schedule_decode_lazy(k, m, w, bitmatrix, erasures, data, coding, w*sizeof(long), sizeof(long), 1);
jerasure_schedule_decode_lazy(&g, k, m, w, bitmatrix, erasures, data, coding, w*sizeof(long), sizeof(long), 1);
jerasure_get_stats(sstats);

printf("jerasure_schedule_decode_lazy - Bytes XOR'd: %.0lf.<br>\n", sstats[0]);
Expand Down
17 changes: 9 additions & 8 deletions Examples/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ int main (int argc, char **argv) {
double tsec;
double totalsec;

static gf2_t g;

signal(SIGQUIT, ctrl_bs_handler);

Expand Down Expand Up @@ -225,18 +226,18 @@ int main (int argc, char **argv) {
case No_Coding:
break;
case Reed_Sol_Van:
matrix = reed_sol_vandermonde_coding_matrix(k, m, w);
matrix = reed_sol_vandermonde_coding_matrix(&g, k, m, w);
break;
case Reed_Sol_R6_Op:
matrix = reed_sol_r6_coding_matrix(k, w);
matrix = reed_sol_r6_coding_matrix(&g, k, w);
break;
case Cauchy_Orig:
matrix = cauchy_original_coding_matrix(k, m, w);
bitmatrix = jerasure_matrix_to_bitmatrix(k, m, w, matrix);
matrix = cauchy_original_coding_matrix(&g, k, m, w);
bitmatrix = jerasure_matrix_to_bitmatrix(&g, k, m, w, matrix);
break;
case Cauchy_Good:
matrix = cauchy_good_general_coding_matrix(k, m, w);
bitmatrix = jerasure_matrix_to_bitmatrix(k, m, w, matrix);
matrix = cauchy_good_general_coding_matrix(&g, k, m, w);
bitmatrix = jerasure_matrix_to_bitmatrix(&g, k, m, w, matrix);
break;
case Liberation:
bitmatrix = liberation_coding_bitmatrix(k, w);
Expand Down Expand Up @@ -319,10 +320,10 @@ int main (int argc, char **argv) {

/* Choose proper decoding method */
if (tech == Reed_Sol_Van || tech == Reed_Sol_R6_Op) {
i = jerasure_matrix_decode(k, m, w, matrix, 1, erasures, data, coding, blocksize);
i = jerasure_matrix_decode(&g, k, m, w, matrix, 1, erasures, data, coding, blocksize);
}
else if (tech == Cauchy_Orig || tech == Cauchy_Good || tech == Liberation || tech == Blaum_Roth || tech == Liber8tion) {
i = jerasure_schedule_decode_lazy(k, m, w, bitmatrix, erasures, data, coding, blocksize, packetsize, 1);
i = jerasure_schedule_decode_lazy(&g, k, m, w, bitmatrix, erasures, data, coding, blocksize, packetsize, 1);
}
else {
fprintf(stderr, "Not a valid coding technique.\n");
Expand Down
25 changes: 13 additions & 12 deletions Examples/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ int main (int argc, char **argv) {
/* Find buffersize */
int up, down;

static gf2_t g;

signal(SIGQUIT, ctrl_bs_handler);

Expand Down Expand Up @@ -438,18 +439,18 @@ int main (int argc, char **argv) {
case No_Coding:
break;
case Reed_Sol_Van:
matrix = reed_sol_vandermonde_coding_matrix(k, m, w);
matrix = reed_sol_vandermonde_coding_matrix(&g, k, m, w);
break;
case Reed_Sol_R6_Op:
break;
case Cauchy_Orig:
matrix = cauchy_original_coding_matrix(k, m, w);
bitmatrix = jerasure_matrix_to_bitmatrix(k, m, w, matrix);
matrix = cauchy_original_coding_matrix(&g, k, m, w);
bitmatrix = jerasure_matrix_to_bitmatrix(&g, k, m, w, matrix);
schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix);
break;
case Cauchy_Good:
matrix = cauchy_good_general_coding_matrix(k, m, w);
bitmatrix = jerasure_matrix_to_bitmatrix(k, m, w, matrix);
matrix = cauchy_good_general_coding_matrix(&g, k, m, w);
bitmatrix = jerasure_matrix_to_bitmatrix(&g, k, m, w, matrix);
schedule = jerasure_smart_bitmatrix_to_schedule(k, m, w, bitmatrix);
break;
case Liberation:
Expand Down Expand Up @@ -507,25 +508,25 @@ int main (int argc, char **argv) {
case No_Coding:
break;
case Reed_Sol_Van:
jerasure_matrix_encode(k, m, w, matrix, data, coding, blocksize);
jerasure_matrix_encode(&g, k, m, w, matrix, data, coding, blocksize);
break;
case Reed_Sol_R6_Op:
reed_sol_r6_encode(k, w, data, coding, blocksize);
reed_sol_r6_encode(&g, k, w, data, coding, blocksize);
break;
case Cauchy_Orig:
jerasure_schedule_encode(k, m, w, schedule, data, coding, blocksize, packetsize);
jerasure_schedule_encode(&g, k, m, w, schedule, data, coding, blocksize, packetsize);
break;
case Cauchy_Good:
jerasure_schedule_encode(k, m, w, schedule, data, coding, blocksize, packetsize);
jerasure_schedule_encode(&g, k, m, w, schedule, data, coding, blocksize, packetsize);
break;
case Liberation:
jerasure_schedule_encode(k, m, w, schedule, data, coding, blocksize, packetsize);
jerasure_schedule_encode(&g, k, m, w, schedule, data, coding, blocksize, packetsize);
break;
case Blaum_Roth:
jerasure_schedule_encode(k, m, w, schedule, data, coding, blocksize, packetsize);
jerasure_schedule_encode(&g, k, m, w, schedule, data, coding, blocksize, packetsize);
break;
case Liber8tion:
jerasure_schedule_encode(k, m, w, schedule, data, coding, blocksize, packetsize);
jerasure_schedule_encode(&g, k, m, w, schedule, data, coding, blocksize, packetsize);
break;
case RDP:
case EVENODD:
Expand Down
6 changes: 4 additions & 2 deletions Examples/jerasure_01.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ int main(int argc, char **argv)
matrix = talloc(int, r*c);

n = 1;
gf2_t* g = galois_init_empty();
for (i = 0; i < r*c; i++) {
matrix[i] = n;
n = galois_single_multiply(n, 2, w);
n = galois_single_multiply(g, n, 2, w);
}

galois_destroy(g);

printf("<HTML><TITLE>jerasure_01");
for (i = 1; i < argc; i++) printf(" %s", argv[i]);
printf("</TITLE>\n");
Expand Down
Loading