[gdal-dev] How to add OpenMP to GDAL?

=?GBK?B?y87Qoei0?= talent_sxl at 126.com
Fri Nov 4 17:07:07 EDT 2011


Dear sir,


I've  used GDALWarper to develop a program for image resampling, resolution of 10m up to 2.5m. In this process I found that the ChunkAndWarpImage( ) in GDALWarpOperation was too slow that it almost took me an hour to get a sence of QuickBird image. After checking source codes, I would like to promote two ways to get this process faster.


1. Set the dfWarpMemoryLimit larger than 64. Since the computer I am using has a RAM of 12GB, 64M is a little smaller under this condition. Besides, the smaller dfWarpMemoryLimit is, the more chunks will be creat. That means we have to do lots of RasterIO( ), which takes a long time to complete. ( Thanks for your advice in the declaration before the definition, in which you have advice that we should try various schemes to query physical RAM. I just wanna offer some help to somebody who has the same confusion with me, in case they could find a solution here by google or something else.)


2. Add parallelization support to GDAL build options, such as OpenMP or CUDA. (I've been able to use CUDA along with GDAL.) Then question comes: how can I add OpenMP to GDAL? I konw nothing about Cmake or gcc. After googling I tried the following metrods:


In nmake.opt, add:
# Any extra libraries needed on this platform?
# Basic Makefile for OpenMP
OMP_CFLAGS = -fopenmp


In alg\makefile.vc, add:
!IFDEF OMP_CFLAGS
OMP_CFLAGS = $(OMP_CFLAGS) -DOMP_SUPPORT
!ENDIF


Finally a little test for OpenMP in alg\gdalwarpkernel.cpp:
#include <omp.h>
...Ln2706:
int ncore = omp_get_num_procs();
#pragma omp parallel for num_threads(ncore*2)
for(...)...


I put vcomp90.dll and Microsoft.VC90.OpenMP.manifest in the same path as makegdal90.sln, rebuilded the makegdal solution and re-made a brand new gdal18.dll with no error appearing. However, when I tried to run my program for image resampling, only 4 of the 8 cores of my cpu were running effectively, and it still took a long time, just as no OpenMP used.


Since OpenMP could speed up codes so easily, would you please help me to add it into GDAL? I'm using GDAL1.8.0 and VS2009, Win7 Ultimate.


Thank you!


 Xiaolu Song 
2011-11-05 
 -- 
Xiaolu Song 
Center for Earth Observation and Digital Earth Chinese Academy of Sciences 
No.9 Dengzhuang South Road, Haidian District, Beijing 100094, China 
Tel: +86-010-82178188 +86-18610335605 
Email:talent_sxl at 126.com 
Öйú¿ÆѧԺ¶ÔµØ¹Û²âÓëÊý×ÖµØÇò¿ÆѧÖÐÐÄ 
±±¾©Êк£µíÇøµËׯÄÏ·9ºÅ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20111105/0784d47e/attachment.html


More information about the gdal-dev mailing list