Anonymous avatar Anonymous committed e4b8389

renamed reduction to elimination

Comments (0)

Files changed (6)

src/brilliantrussian.c

   const int ka = k/2;
   const int kb = k-k/2;
 
+#ifdef HAVE_OPENMP
+#pragma omp parallel for private(r) shared(startrow, stoprow) schedule(dynamic,32) if(stoprow-startrow > 128)
+#endif
   for(r=startrow; r<stoprow; r++) {
     const int x0 = L0[ (int)mzd_read_bits(M, r, startcol, ka)];
     const int x1 = L1[ (int)mzd_read_bits(M, r, startcol+ka, kb)];
   const int kb = k/3 + ((rem>=1) ? 1 : 0);
   const int kc = k/3;
 
+#ifdef HAVE_OPENMP
+#pragma omp parallel for private(r) shared(startrow, stoprow) schedule(dynamic,32) if(stoprow-startrow > 128)
+#endif
   for(r=startrow; r<stoprow; r++) {
     const int x0 = L0[ (int)mzd_read_bits(M, r, startcol, ka)];
     const int x1 = L1[ (int)mzd_read_bits(M, r, startcol+ka, kb)];
   const int kc = k/4 + ((rem>=1) ? 1 : 0);
   const int kd = k/4;
 
+#ifdef HAVE_OPENMP
+#pragma omp parallel for private(r) shared(startrow, stoprow) schedule(dynamic,32) if(stoprow-startrow > 128)
+#endif
   for(r=startrow; r<stoprow; r++) {
     const int x0 = L0[ (int)mzd_read_bits(M, r, startcol, ka)];
     const int x1 = L1[ (int)mzd_read_bits(M, r, startcol+ka, kb)];
   const int kd = k/5 + ((rem>=1) ? 1 : 0);
   const int ke = k/5;
 
+#ifdef HAVE_OPENMP
+#pragma omp parallel for private(r) shared(startrow, stoprow) schedule(dynamic,32) if(stoprow-startrow > 128)
+#endif
   for(r=startrow; r<stoprow; r++) {
     const int x0 = L0[ (int)mzd_read_bits(M, r, startcol, ka)];
     const int x1 = L1[ (int)mzd_read_bits(M, r, startcol+ka, kb)];
   const int ke = k/6 + ((rem>=1) ? 1 : 0);;
   const int kf = k/6;
 
+#ifdef HAVE_OPENMP
+#pragma omp parallel for private(r) shared(startrow, stoprow) schedule(dynamic,32) if(stoprow-startrow > 128)
+#endif
   for(r=startrow; r<stoprow; r++) {
     const int x0 = L0[ (int)mzd_read_bits(M, r, startcol, ka)];
     const int x1 = L1[ (int)mzd_read_bits(M, r, startcol+ka, kb)];
 
   if (k == 0) {
     k = m4ri_opt_k(A->nrows, A->ncols, 0);
-    if (k>5) {
+    if (k>6) {
+      k -= 5;
+    } else if (k>5) {
       k -= 4;
     }
   }

testsuite/Makefile

 
 
 
-PRGS=test_reduction test_multiplication bench_reduction bench_multiplication bench_addition
+PRGS=test_elimination test_multiplication bench_elimination bench_multiplication bench_addition
 
 CPUCYCLES_DIR=./cpucycles-20060326
 

testsuite/bench_elimination.c

+#include <stdlib.h>
+#include "packedmatrix.h"
+#include "brilliantrussian.h"
+#include "grayflex.h"
+#include "cpucycles.h"
+
+int main(int argc, char **argv) {
+  int n;
+  unsigned long long t;
+  packedmatrix *A;
+
+  //initialise the library
+  m4ri_build_all_codes();
+  if (argc != 2) {
+    m4ri_die("Parameter n expected.\n");
+  }
+  n = atoi(argv[1]);
+  A = mzd_init(n, n);
+  mzd_randomize(A);
+  
+  t = cpucycles();
+  // standard parameter
+  mzd_reduce_m4ri(A, 1, 0, NULL, NULL);
+  printf("n: %5d, cpu cycles: %llu\n",n, cpucycles() - t);
+
+  mzd_free(A);
+  m4ri_destroy_all_codes();
+}

testsuite/bench_reduction.c

-#include <stdlib.h>
-#include "packedmatrix.h"
-#include "brilliantrussian.h"
-#include "grayflex.h"
-#include "cpucycles.h"
-
-int main(int argc, char **argv) {
-  int n;
-  unsigned long long t;
-  packedmatrix *A;
-
-  //initialise the library
-  m4ri_build_all_codes();
-  if (argc != 2) {
-    m4ri_die("Parameter n expected.\n");
-  }
-  n = atoi(argv[1]);
-  A = mzd_init(n, n);
-  mzd_randomize(A);
-  
-  t = cpucycles();
-  // standard parameter
-  mzd_reduce_m4ri(A, 1, 0, NULL, NULL);
-  printf("n: %5d, cpu cycles: %llu\n",n, cpucycles() - t);
-
-  mzd_free(A);
-  m4ri_destroy_all_codes();
-}

testsuite/test_elimination.c

+#include <stdlib.h>
+#include "m4ri.h"
+
+int elim_test_equality(int nr, int nc) {
+  packedmatrix *A, *B, *C, *D, *E, *F;
+  int ret = 0; 
+
+  printf("red: m: %4d, n: %4d\n",nr,nc);
+
+  A = mzd_init(nr, nc);
+  mzd_randomize(A);
+  B = mzd_copy(NULL, A);
+  C = mzd_copy(NULL, A);
+  D = mzd_copy(NULL, A);
+  E = mzd_copy(NULL, A);
+  F = mzd_copy(NULL, A);
+
+  mzd_reduce_m4ri(A, 1, 0, NULL, NULL);
+
+  mzd_reduce_m4ri(B, 1, 8, NULL, NULL);
+
+  mzd_reduce_m4ri(C, 0, 0, NULL, NULL);
+  mzd_top_reduce_m4ri(C, 0, NULL, NULL);
+
+  mzd_reduce_m4ri(D, 0, 4, NULL, NULL);
+  mzd_top_reduce_m4ri(D, 4, NULL, NULL);
+
+  mzd_reduce_naiv(E, 1);
+
+  mzd_reduce_naiv(F, 0);
+  mzd_top_reduce_m4ri(F, 0, NULL, NULL);
+  
+  if(mzd_equal(A, B) != TRUE) {
+    printf("FAIL: A != B\n");
+    ret -= 1;
+  }
+ 
+  if(mzd_equal(B, C) != TRUE) {
+    printf("FAIL: B != C\n");
+    ret -= 1;
+  }
+
+  if(mzd_equal(D, E) != TRUE) {
+    printf("FAIL: D != E\n");
+    ret -= 1;
+  }
+
+  if(mzd_equal(E, F) != TRUE) {
+    printf("FAIL: E != F\n");
+    ret -= 1;
+  }
+
+  if(mzd_equal(F, A) != TRUE) {
+    printf("FAIL: F != A\n");
+    ret -= 1;
+  }
+
+  mzd_free(A);
+  mzd_free(B);
+  mzd_free(C);
+  mzd_free(D);
+  mzd_free(E);
+
+  return ret;
+}
+
+int main(int argc, char **argv) {
+  m4ri_build_all_codes();
+
+  int status = 0;
+  status += elim_test_equality(100, 100);
+  status += elim_test_equality(21, 171);
+  status += elim_test_equality(31, 121);
+  status += elim_test_equality(193, 65);
+  status += elim_test_equality(1025, 1025);
+  status += elim_test_equality(2048, 2048);
+
+  if (status == 0) {
+    printf("All tests passed.\n");
+  }
+
+  m4ri_destroy_all_codes();
+  return 0;
+}

testsuite/test_reduction.c

-#include <stdlib.h>
-#include "m4ri.h"
-
-int red_test_equality(int nr, int nc) {
-  packedmatrix *A, *B, *C, *D, *E, *F;
-  int ret = 0; 
-
-  printf("red: m: %4d, n: %4d\n",nr,nc);
-
-  A = mzd_init(nr, nc);
-  mzd_randomize(A);
-  B = mzd_copy(NULL, A);
-  C = mzd_copy(NULL, A);
-  D = mzd_copy(NULL, A);
-  E = mzd_copy(NULL, A);
-  F = mzd_copy(NULL, A);
-
-  mzd_reduce_m4ri(A, 1, 0, NULL, NULL);
-
-  mzd_reduce_m4ri(B, 1, 8, NULL, NULL);
-
-  mzd_reduce_m4ri(C, 0, 0, NULL, NULL);
-  mzd_top_reduce_m4ri(C, 0, NULL, NULL);
-
-  mzd_reduce_m4ri(D, 0, 4, NULL, NULL);
-  mzd_top_reduce_m4ri(D, 4, NULL, NULL);
-
-  mzd_reduce_naiv(E, 1);
-
-  mzd_reduce_naiv(F, 0);
-  mzd_top_reduce_m4ri(F, 0, NULL, NULL);
-  
-  if(mzd_equal(A, B) != TRUE) {
-    printf("FAIL: A != B\n");
-    ret -= 1;
-  }
- 
-  if(mzd_equal(B, C) != TRUE) {
-    printf("FAIL: B != C\n");
-    ret -= 1;
-  }
-
-  if(mzd_equal(D, E) != TRUE) {
-    printf("FAIL: D != E\n");
-    ret -= 1;
-  }
-
-  if(mzd_equal(E, F) != TRUE) {
-    printf("FAIL: E != F\n");
-    ret -= 1;
-  }
-
-  if(mzd_equal(F, A) != TRUE) {
-    printf("FAIL: F != A\n");
-    ret -= 1;
-  }
-
-  mzd_free(A);
-  mzd_free(B);
-  mzd_free(C);
-  mzd_free(D);
-  mzd_free(E);
-
-  return ret;
-}
-
-int main(int argc, char **argv) {
-  m4ri_build_all_codes();
-
-  int status = 0;
-  status += red_test_equality(100, 100);
-  status += red_test_equality(21, 171);
-  status += red_test_equality(31, 121);
-  status += red_test_equality(193, 65);
-  status += red_test_equality(1025, 1025);
-  status += red_test_equality(2048, 2048);
-
-  if (status == 0) {
-    printf("All tests passed.\n");
-  }
-
-  m4ri_destroy_all_codes();
-  return 0;
-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.