[Proj] PROJ.4 and OpenMP

José Luis García Pallero jgpallero at gmail.com
Thu Jul 2 10:37:16 EST 2015


2015-07-02 17:34 GMT+02:00 Even Rouault <even.rouault at spatialys.com>:
> Le jeudi 02 juillet 2015 16:25:50, José Luis García Pallero a écrit :
>> Hello:
>>
>> Since version 4.8.0, PROJ.4 has some thread safety facilities
>> (https://trac.osgeo.org/proj/wiki/ThreadSafety) and also the source
>> code contains an example program in which Posix Threads are used. But
>> I'm a bit confused about how to use this thread safety with OpenMP.
>> Could someone, please, upload a code example of using PROJ with
>> OpenMP? Such example could be also added to the distributed source
>> code
>
> José,
>
> I don't have a working example to propose nor I am an OpenMP expert, but based
> on https://en.wikipedia.org/wiki/OpenMP, I guess you must use a thread-private
> identifier to select projPJ objects specific to each thread.
>
> The global workflow could be :
>
> - initialization :
>
> projCtxt* tabProjCtx;
> projPJ* tabProjSrc;
> projPJ* tabProjDst;
> int nThreads;
> #pragma omp parallel
> {
>     #pragma omp single
>     nThreads =  omp_get_num_threads()
>     /* TODO: allocate tabProjCtx, tabProjSrc and tabProjDst to be nThreads
> large */
>     /* TODO: loop over nThreads and initialize each tabProjCtx[i],
> tabProjSrc[i] and tabProjDst[i] */
> }
>
> - and then use something like :
>
> int th_id;
> #pragma omp parallel for private(th_id)
> for(i=0;i<...;i++)
> {
>      th_id = omp_get_thread_num();
>      pj_transform(tabProjSrc[th_id], tabProjDst[th_id], ...)
> }
>
> Completely untested of course...
>
> If you manage to get a working example, please contribute it.

Thanks!

>
> Even
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com



-- 
*****************************************
José Luis García Pallero
jgpallero at gmail.com
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************


More information about the Proj mailing list