[GRASS-SVN] r42052 - in grass/trunk/lib: gmath gmath/test gpde

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Apr 28 11:24:33 EDT 2010


Author: huhabla
Date: 2010-04-28 11:24:32 -0400 (Wed, 28 Apr 2010)
New Revision: 42052

Modified:
   grass/trunk/lib/gmath/solvers_direct_cholesky_band.c
   grass/trunk/lib/gmath/symmetric_band_matrix.c
   grass/trunk/lib/gmath/test/bench_blas2.c
   grass/trunk/lib/gmath/test/test_blas2.c
   grass/trunk/lib/gpde/Makefile
Log:
Fixed some OpenMP related bugs. Removed obsolete comments from Makefile.


Modified: grass/trunk/lib/gmath/solvers_direct_cholesky_band.c
===================================================================
--- grass/trunk/lib/gmath/solvers_direct_cholesky_band.c	2010-04-28 10:41:14 UTC (rev 42051)
+++ grass/trunk/lib/gmath/solvers_direct_cholesky_band.c	2010-04-28 15:24:32 UTC (rev 42052)
@@ -166,7 +166,7 @@
 
     double **T = NULL;
     double *vect = NULL;
-    int i, j, k, start, end;
+    int i, j, k, start;
     double sum;
 
     T = G_alloc_matrix(rows, bandwidth);

Modified: grass/trunk/lib/gmath/symmetric_band_matrix.c
===================================================================
--- grass/trunk/lib/gmath/symmetric_band_matrix.c	2010-04-28 10:41:14 UTC (rev 42051)
+++ grass/trunk/lib/gmath/symmetric_band_matrix.c	2010-04-28 15:24:32 UTC (rev 42052)
@@ -123,9 +123,9 @@
 void G_math_Ax_sband(double ** A, double *x, double *y, int rows, int bandwidth)
 {
     int i, j;
-
     double tmp;
 
+
 #pragma omp for schedule (static) private(i, j, tmp)
     for (i = 0; i < rows; i++) {
 	tmp = 0;
@@ -135,7 +135,9 @@
 	}
 	y[i] = tmp;
     }
-#pragma omp for schedule (static) private(i, j, tmp)
+
+#pragma omp single
+    {
     for (i = 0; i < rows; i++) {
 	tmp = 0;
 	for (j = 1; j < bandwidth; j++) {
@@ -143,6 +145,6 @@
 			y[i + j] += A[i][j]*x[i];
 	}
     }
-
+    }
     return;
 }

Modified: grass/trunk/lib/gmath/test/bench_blas2.c
===================================================================
--- grass/trunk/lib/gmath/test/bench_blas2.c	2010-04-28 10:41:14 UTC (rev 42051)
+++ grass/trunk/lib/gmath/test/bench_blas2.c	2010-04-28 15:24:32 UTC (rev 42052)
@@ -51,6 +51,8 @@
 
     G_math_les *les;
     les = create_normal_unsymmetric_les(rows);
+    G_math_les *bles;
+    bles = create_symmetric_band_les(rows);
     G_math_les *sples;
     sples = create_sparse_unsymmetric_les(rows);
 
@@ -63,6 +65,7 @@
     fill_d_vector_range_1(x, 1, rows);
 
     gettimeofday(&tstart, NULL);
+
 #pragma omp parallel default(shared)
 {
     G_math_Ax_sparse(sples->Asp, x, z, rows);
@@ -72,6 +75,13 @@
     gettimeofday(&tstart, NULL);
 #pragma omp parallel default(shared)
 {
+    G_math_Ax_sband(bles->A, x, z, rows, rows);
+}
+    gettimeofday(&tend, NULL);
+    G_important_message("Computation time G_math_Ax_sband: %g\n", compute_time_difference(tstart, tend));
+    gettimeofday(&tstart, NULL);
+#pragma omp parallel default(shared)
+{
     G_math_d_Ax(les->A, x, z, rows, rows);
 }
     gettimeofday(&tend, NULL);
@@ -101,6 +111,7 @@
     G_free_vector(z);
 
     G_math_free_les(les);
+    G_math_free_les(bles);
     G_math_free_les(sples);
 
     if(A)

Modified: grass/trunk/lib/gmath/test/test_blas2.c
===================================================================
--- grass/trunk/lib/gmath/test/test_blas2.c	2010-04-28 10:41:14 UTC (rev 42051)
+++ grass/trunk/lib/gmath/test/test_blas2.c	2010-04-28 15:24:32 UTC (rev 42052)
@@ -21,7 +21,7 @@
 #include <math.h>
 #include "test_gmath_lib.h"
 
-#define EPSILON 0.0000001
+#define EPSILON 0.00001
 
 /* prototypes */
 static int test_blas_level_2_double(void);
@@ -47,15 +47,6 @@
 
     return sum;
 }
-/*
-extern double *G_math_Ax_sparse(G_math_spvector **, double *, double *, int );
-extern double *G_math_d_Ax(double **, double *, double *, int , int );
-extern float *G_math_f_Ax(float **, float *, float *, int , int );
-extern double **G_math_d_x_dyad_y(double *, double *, double **, int, int );
-extern float **G_math_f_x_dyad_y(float *, float *, float **, int, int );
-extern double *G_math_d_aAx_by(double **, double *, double *, double , double , double *, int , int );
-extern float *G_math_f_aAx_by(float **, float *, float *, float , float , float *, int , int );
-*/
 
 /* *************************************************************** */
 /* ************** D O U B L E ************************************ */
@@ -88,46 +79,51 @@
 
 #pragma omp parallel default(shared)
 {
-    G_message("Testing G_math_Ax_sparse");
     G_math_Ax_sparse(sples->Asp, x, sples->b, rows);
-    G_math_print_les(sples);
+}
     G_math_d_asum_norm(sples->b, &a, rows);
-
-    G_message("Testing G_math_Ax_band");
+#pragma omp parallel default(shared)
+{
     G_math_Ax_sband(bles->A, x, bles->b, rows, rows);
-    G_math_print_les(bles);
+}
     G_math_d_asum_norm(bles->b, &j, rows);
-
-    G_message("Testing G_math_d_Ax");
+#pragma omp parallel default(shared)
+{
     G_math_d_Ax(les->A, x, z, rows, rows);
+}
     G_math_d_asum_norm(z, &b, rows);
-
-    G_message("Testing G_math_d_aAx_by");
+#pragma omp parallel default(shared)
+{
     G_math_d_aAx_by(les->A, x, y, 1.0, 1.0, z, rows, rows);
+}
     G_math_d_asum_norm(z, &c, rows);
-
-    G_message("Testing G_math_d_aAx_by");
+#pragma omp parallel default(shared)
+{
     G_math_d_aAx_by(les->A, x, y, -1.0, 1.0, z, rows, rows);
+}
     G_math_d_asum_norm(z, &d, rows);
-
-    G_message("Testing G_math_d_aAx_by");
+#pragma omp parallel default(shared)
+{
     G_math_d_aAx_by(les->A, x, y, 1.0, 0.0, z, rows, rows);
+}
     G_math_d_asum_norm(z, &e, rows);
-
-    G_message("Testing G_math_d_aAx_by");
+#pragma omp parallel default(shared)
+{
     G_math_d_aAx_by(les->A, x, y, -1.0, -1.0, z, rows, rows);
+}
     G_math_d_asum_norm(z, &f, rows);
-
-    G_message("Testing G_math_d_x_dyad_y");
+#pragma omp parallel default(shared)
+{
     G_math_d_x_dyad_y(x, x, A, rows, rows);
     G_math_d_Ax(A, x, z, rows, rows);
+}
     G_math_d_asum_norm(z, &g, rows);
-
-    G_message("Testing G_math_d_x_dyad_y");
+#pragma omp parallel default(shared)
+{
     G_math_d_x_dyad_y(x, x, C, rows, rows);
     G_math_d_Ax(A, x, z, rows, rows);
+}
     G_math_d_asum_norm(z, &h, rows);
-}
 
     G_math_d_asum_norm(les->b, &i, rows);
 
@@ -225,38 +221,44 @@
 
 #pragma omp parallel default(shared)
 {
-    G_message("Testing G_math_f_Ax");
     G_math_f_Ax(les->A, x, z, rows, rows);
+}
     G_math_f_asum_norm(z, &b, rows);
-
-    G_message("Testing G_math_f_aAx_by");
+#pragma omp parallel default(shared)
+{
     G_math_f_aAx_by(les->A, x, y, 1.0, 1.0, z, rows, rows);
+}
     G_math_f_asum_norm(z, &c, rows);
-
-    G_message("Testing G_math_f_aAx_by");
+#pragma omp parallel default(shared)
+{
     G_math_f_aAx_by(les->A, x, y, -1.0, 1.0, z, rows, rows);
+}
     G_math_f_asum_norm(z, &d, rows);
-
-    G_message("Testing G_math_f_aAx_by");
+#pragma omp parallel default(shared)
+{
     G_math_f_aAx_by(les->A, x, y, 1.0, 0.0, z, rows, rows);
+}
     G_math_f_asum_norm(z, &e, rows);
-
-    G_message("Testing G_math_f_aAx_by");
+#pragma omp parallel default(shared)
+{
     G_math_f_aAx_by(les->A, x, y, -1.0, -1.0, z, rows, rows);
+}
     G_math_f_asum_norm(z, &f, rows);
-
-    G_message("Testing G_math_f_x_dyad_y");
+#pragma omp parallel default(shared)
+{
     G_math_f_x_dyad_y(x, x, A, rows, rows);
     G_math_f_Ax(A, x, z, rows, rows);
+}
     G_math_f_asum_norm(z, &g, rows);
-
-    G_message("Testing G_math_f_x_dyad_y");
+#pragma omp parallel default(shared)
+{
     G_math_f_x_dyad_y(x, x, C, rows, rows);
     G_math_f_Ax(A, x, z, rows, rows);
+}
     G_math_f_asum_norm(z, &h, rows);
-}
 
 
+
     G_math_f_asum_norm(les->b, &i, rows);
 
     if(b - i > EPSILON) {

Modified: grass/trunk/lib/gpde/Makefile
===================================================================
--- grass/trunk/lib/gpde/Makefile	2010-04-28 10:41:14 UTC (rev 42051)
+++ grass/trunk/lib/gpde/Makefile	2010-04-28 15:24:32 UTC (rev 42052)
@@ -2,13 +2,6 @@
 
 EXTRA_LIBS=$(GISLIB) $(RASTERLIB) $(G3DLIB) $(GMATHLIB) $(MATHLIB)
 
-
-# GCC >4.2: openMP support
-#EXTRA_CFLAGS=-fopenmp
-#EXTRA_LIBS=$(GISLIB) $(RASTERLIB) $(G3DLIB) -lgomp $(GMATHLIB) $(MATHLIB)
-# ?? EXTRA_LIBS += -lgomp
-
-
 LIB_NAME = $(GPDE_LIBNAME)
 
 include $(MODULE_TOPDIR)/include/Make/Lib.make



More information about the grass-commit mailing list