Markus Metz wrote:
> The core of the lidar tools is the lidarlib, that is AFAICT
> robust and working. Bugs are most likely in modules, so I'll try
> to add comments there. I have reorganized the code for v.surf.bspline
> in the hope that it is now easier to read.
Slightly off-topic, but while we are thinking about this code ...
A while back I did some crude profiling of the v.lidar tools and found
that it was spending lots and lots of time in the Tcholetsky decomposition
loop (3-for loops deep).
It seemed like a good & simple test case for using OpenMP to multi-thread
it, but I got stuck with it segfaulting. AFAIR the problem was that OpenMP
wanted you to malloc the entire thing before starting, and this could
get big.
if it interests you, see the attached patch and
https://trac.osgeo.org/grass/ticket/657
http://lists.osgeo.org/pipermail/grass-dev/2009-June/044709.html
http://lists.osgeo.org/pipermail/grass-dev/2009-June/044705.html
http://grass.osgeo.org/wiki/OpenMP
> I forgot to mention, there is a problem with sqlite, it is much slower
> than dbf, no idea if this is a problem of my system or of the grass
> sqlite driver or of the way auxiliary tables are accessed by the lidar
> tools.
that sounds vaguely familiar, but as a general thing not necessarily
to do with v.lidar. probably something about it in the archives?
Hamish
Index: vector/lidar/lidarlib/TcholBand.c
===================================================================
--- vector/lidar/lidarlib/TcholBand.c (revision 39459)
+++ vector/lidar/lidarlib/TcholBand.c (working copy)
@@ -1,9 +1,13 @@
#include <stdlib.h> /* imported libraries */
#include <stdio.h>
#include <math.h>
-#include <grass/gis.h>
-#include <grass/PolimiFunct.h>
+#ifndef HAVE_OPENMP_H
+#include <omp.h>
+#endif
+
+#include "PolimiFunct.h"
+
/*--------------------------------------------------------------------------------------*/
/* Tcholetsky decomposition -> T= Lower Triangular Matrix */
@@ -12,8 +16,19 @@
int i, j, k, end;
double somma;
+#ifndef HAVE_OPENMP_H
+; // omp_set_num_threads(omp_get_num_procs());
+//printf("nthreads=%d\n", omp_get_num_procs() );
+#endif
G_debug(2, "tcholDec(): n=%d BW=%d", n, BW);
+//#pragma omp parallel for schedule(static) shared(i,N,BW,T) private(j,k,somma)
+//#pragma omp for schedule (static) private(j,k,somma)
+#pragma omp parallel shared(i,N,BW,T) private(j,k,somma)
+{
+// #pragma omp for schedule(dynamic,10)
+//#pragma omp parallel for reduction(+:somma)
+//#pragma omp parallel for
for (i = 0; i < n; i++) {
G_percent(i, n, 2);
for (j = 0; j < BW; j++) {
@@ -32,8 +47,11 @@
T[i][j] = somma / T[i][0];
}
}
+}
+//#pragma omp single
+// G_percent(i, n, 2);
+ G_percent(1,1,2);
- G_percent(i, n, 2);
return;
}
Index: vector/lidar/lidarlib/Makefile
===================================================================
--- vector/lidar/lidarlib/Makefile (revision 39459)
+++ vector/lidar/lidarlib/Makefile (working copy)
@@ -4,6 +4,12 @@
EXTRA_INC = $(VECT_INC)
EXTRA_CFLAGS = $(VECT_CFLAGS)
+# GCC >4.2: openMP support
+ifndef HAVE_OPENMP_H
+ EXTRA_LIBS += -lgomp
+ EXTRA_CFLAGS += -fopenmp
+endif
+
LIB = LIDAR
include $(MODULE_TOPDIR)/include/Make/Lib.make
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev