[gdal-dev] gdalwarp_multithreading

Even Rouault even.rouault at mines-paris.org
Tue Sep 25 04:19:42 PDT 2012


Selon DmitriyS <sazonov at scanex.ru>:

> Excuse me for the question, I am a beginner at GDAL development and have a
> problem. I develop GUI (c++) application for a reprojection, using
> "gdalwarp" (special class is written based on this utility). I wish to
> perform warp operation for each input images in separate threads
> (...beginthreadex(...CreateOutImgFile...). But in this case of two threads
> one does not succeeded. Method "GDALDataset::IRasterIO" returns CE_Failure
> and thats all. Can you tell the reason of this trouble? Moreover, when only
> one thread works warp operation produces no mistakes.
> Best regards, Dmitriy.
>

First you should check that your GDAL is built with threads support, otherwise
chaos might occur. On Windows, this is the default. On Linux, in recent GDAL
versions (1.8.0 or later), it is also the default provided that pthread is
available.

Then, I'd recommand using the CPLCreateThread() function of the GDAL API to
create your thread (although I think this is not a hard requirement, but just to
be safe)

You should also make sure that the threads deal with different input and output
files, but from your above description, it looks as if it is the case.

You didn't mention which format/driver is used. A few drivers aren't thread-safe
at all, but the most popular ones are generally OK.

If it isn't a threading error in your code, then it might be that you are
unlucky and run into a known issue in the design of the block cache in GDAL.
This is a bit discussed in http://trac.osgeo.org/gdal/wiki/rfc26_blockcache and
the tickets referenced by that RFC, although I'd think that the related problems
aren't so easy to be triggered in real-world situations. So it would be a last
resort hypothesis.


>
>
> --
> View this message in context:
> http://osgeo-org.1560.n6.nabble.com/gdalwarp-multithreading-tp5004224.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>




More information about the gdal-dev mailing list