<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: GDAL meets EDINA</title>
	<atom:link href="http://mateusz.loskot.net/2009/12/09/gdal-meets-edina/feed/" rel="self" type="application/rss+xml" />
	<link>http://mateusz.loskot.net/2009/12/09/gdal-meets-edina/</link>
	<description>mloskot&#039;s life, programming, c++, geo and adventures</description>
	<lastBuildDate>Tue, 24 Jan 2012 22:38:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: GIS-Lab Blog&#187; ????? ????? &#187; ??????? ??????</title>
		<link>http://mateusz.loskot.net/2009/12/09/gdal-meets-edina/comment-page-1/#comment-2537</link>
		<dc:creator>GIS-Lab Blog&#187; ????? ????? &#187; ??????? ??????</dc:creator>
		<pubDate>Mon, 14 Dec 2009 15:20:57 +0000</pubDate>
		<guid isPermaLink="false">http://mateusz.loskot.net/?p=1633#comment-2537</guid>
		<description>[...] ??????? GDAL ?? Mateusz Loskot. [...]</description>
		<content:encoded><![CDATA[<p>[...] ??????? GDAL ?? Mateusz Loskot. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mloskot</title>
		<link>http://mateusz.loskot.net/2009/12/09/gdal-meets-edina/comment-page-1/#comment-2530</link>
		<dc:creator>mloskot</dc:creator>
		<pubDate>Thu, 10 Dec 2009 18:46:12 +0000</pubDate>
		<guid isPermaLink="false">http://mateusz.loskot.net/?p=1633#comment-2530</guid>
		<description>It&#039;s getting clearer. &lt;a href=&quot;http://doc.trolltech.com/4.5/threads.html#reentrancy-and-thread-safety&quot; rel=&quot;nofollow&quot;&gt;Qt admits that it adapts the terms&lt;/a&gt; very differently to how it is understood by C or POSIX:

&lt;blockquote&gt;POSIX uses a somewhat different definition of reentrancy and thread-safety for its C APIs&lt;/blockquote&gt;

In any case, reentrancy is different animal than thread-safety. According to traditional understanding of both in Unix world, reentrancy implies thread-safety.

GDALRasterIO would be thread-safe if code of the function can be safely executed by multiple, meaning concurrent, threads.
GDALRasterIO would be reentrant if it is safe to perform another execution of GDALRasterIO while previous one was interrupted. In the latter case there are no implications or assumption about number of threads executing it.

GDALRasterIO can be thread-safe, using one of locking mechanisms internally, but this will not necessary make the function reentrant.

In your pseudo-code examples, the first case does not require thread-safety but reentrancy. The second example, IMHO, requires both, because hDataset is not thread safe object itself.</description>
		<content:encoded><![CDATA[<p>It&#8217;s getting clearer. <a href="http://doc.trolltech.com/4.5/threads.html#reentrancy-and-thread-safety" rel="nofollow">Qt admits that it adapts the terms</a> very differently to how it is understood by C or POSIX:</p>
<blockquote><p>POSIX uses a somewhat different definition of reentrancy and thread-safety for its C APIs</p></blockquote>
<p>In any case, reentrancy is different animal than thread-safety. According to traditional understanding of both in Unix world, reentrancy implies thread-safety.</p>
<p>GDALRasterIO would be thread-safe if code of the function can be safely executed by multiple, meaning concurrent, threads.<br />
GDALRasterIO would be reentrant if it is safe to perform another execution of GDALRasterIO while previous one was interrupted. In the latter case there are no implications or assumption about number of threads executing it.</p>
<p>GDALRasterIO can be thread-safe, using one of locking mechanisms internally, but this will not necessary make the function reentrant.</p>
<p>In your pseudo-code examples, the first case does not require thread-safety but reentrancy. The second example, IMHO, requires both, because hDataset is not thread safe object itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Even Rouault</title>
		<link>http://mateusz.loskot.net/2009/12/09/gdal-meets-edina/comment-page-1/#comment-2529</link>
		<dc:creator>Even Rouault</dc:creator>
		<pubDate>Thu, 10 Dec 2009 13:32:48 +0000</pubDate>
		<guid isPermaLink="false">http://mateusz.loskot.net/?p=1633#comment-2529</guid>
		<description>About re-entrancy and thread-safety definitions, this is becoming funny...

I think I&#039;ve been consistant with the definitions given in http://trac.osgeo.org/gdal/wiki/rfc16_ogr_reentrancy, that is pretty close to http://qt.nokia.com/doc/4.6/threads-reentrancy.html which also says :
&quot;Hence, a thread-safe function is always reentrant, but a reentrant function is not always thread-safe.&quot;

But the wikipedia page (http://en.wikipedia.org/wiki/Reentrant_(subroutine)) that deals with re-entrency seem to agree with your definitions : &quot;Every reentrant function is thread-safe; however, not every thread-safe function is reentrant&quot; .

So, as often, words are the source of confusions ;-) 

Let the (pseudo)code speak for me. What I mean is you can (currently) do :
- Thread T1 : GDALRasterIO(hDataset1, GF_Read, ...)
- Thread T2 : GDALRasterIO(hDataset2, GF_Read, ...)

But you cannot (generally (*)) do (without external lock) :
- Thread T1 : GDALRasterIO(hDataset, GF_Read, ...)
- Thread T2 : GDALRasterIO(hDataset, GF_Read, ...)

(*) : this would work if the pixel window that is read is already in the block cache. In this scenario, the IReadBlock() method of the underlying driver does not need to be called and as the relevant part in GDAL core is thread-safe, this would work. Of course, this is not very practical to check.</description>
		<content:encoded><![CDATA[<p>About re-entrancy and thread-safety definitions, this is becoming funny&#8230;</p>
<p>I think I&#8217;ve been consistant with the definitions given in <a href="http://trac.osgeo.org/gdal/wiki/rfc16_ogr_reentrancy" rel="nofollow">http://trac.osgeo.org/gdal/wiki/rfc16_ogr_reentrancy</a>, that is pretty close to <a href="http://qt.nokia.com/doc/4.6/threads-reentrancy.html" rel="nofollow">http://qt.nokia.com/doc/4.6/threads-reentrancy.html</a> which also says :<br />
&#8220;Hence, a thread-safe function is always reentrant, but a reentrant function is not always thread-safe.&#8221;</p>
<p>But the wikipedia page (<a href="http://en.wikipedia.org/wiki/Reentrant_(subroutine)" rel="nofollow">http://en.wikipedia.org/wiki/Reentrant_(subroutine)</a>) that deals with re-entrency seem to agree with your definitions : &#8220;Every reentrant function is thread-safe; however, not every thread-safe function is reentrant&#8221; .</p>
<p>So, as often, words are the source of confusions ;-) </p>
<p>Let the (pseudo)code speak for me. What I mean is you can (currently) do :<br />
- Thread T1 : GDALRasterIO(hDataset1, GF_Read, &#8230;)<br />
- Thread T2 : GDALRasterIO(hDataset2, GF_Read, &#8230;)</p>
<p>But you cannot (generally (*)) do (without external lock) :<br />
- Thread T1 : GDALRasterIO(hDataset, GF_Read, &#8230;)<br />
- Thread T2 : GDALRasterIO(hDataset, GF_Read, &#8230;)</p>
<p>(*) : this would work if the pixel window that is read is already in the block cache. In this scenario, the IReadBlock() method of the underlying driver does not need to be called and as the relevant part in GDAL core is thread-safe, this would work. Of course, this is not very practical to check.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mloskot</title>
		<link>http://mateusz.loskot.net/2009/12/09/gdal-meets-edina/comment-page-1/#comment-2528</link>
		<dc:creator>mloskot</dc:creator>
		<pubDate>Thu, 10 Dec 2009 00:09:30 +0000</pubDate>
		<guid isPermaLink="false">http://mateusz.loskot.net/?p=1633#comment-2528</guid>
		<description>Even, 

Re-entrancy, as stronger requirement, assumes thread-safety. However, thread-safety does not necessarily mean re-entrancy. So, how you think to provide re-entrancy but dropping thread-safety at the same time. Perhaps you mix concept of parallelism - GDAL performing multiple tasks in parallel, internally as a black box.

Also, it is feasible to provide mechanism to disable thread-safety features during compile-time. Similarly to well-written parallel implementation of an algorithm, if it&#039;s well designed, it should compile and execute in single-threaded mode as well as in multi-threaded mode.

Regarding the cost of thread safety, in my opinion it hardly would be comparable to general cost of operations performed by GDAL. GDAL does hard work that costs a lot itself. Of course, assuming there are no locks per pixel or short scanline, etc.

Another issue is that making GDAL re-entrant will most likely require substantial alternation of GDAL public API. Given GDAL development process, I can&#039;t really imagine it happening in near future. There are many show stoppers on the horizon :-)

Regarding the reading, note in the FAQ says &#039;&#039;as long as no two threads access the same GDALDataset object at the same time&#039;&#039;. If it is more pessimistic than the actual status of implementation, would be good if someone knowledgeable could update it.

I&#039;m no longer subscribed to gdal-dev, so I&#039;ll take the liberty to continue posting here from time to time.

By the way, in case it&#039;s relevant, a simple example of well-designed (simple) algorithms for raster processing can be found as small 2 headers extension to &lt;a href=&quot;http://www.boost.org/doc/libs/release/libs/gil/doc/index.html&quot; rel=&quot;nofollow&quot;&gt;Adobe/Boost GIL&lt;/a&gt; library, it is &lt;a href=&quot;http://github.com/bogado/gil_threaded&quot; rel=&quot;nofollow&quot;&gt;gil threaded&lt;/a&gt;. The idea of algorithmic approach to thread-safety is interesting, from &lt;a href=&quot;http://github.com/bogado/gil_threaded/blob/master/readme&quot; rel=&quot;nofollow&quot;&gt;readme&lt;/a&gt;: alg(x + y) = alg(x) + alg(y)

Thanks for sharing your thoughts Even!

Mat</description>
		<content:encoded><![CDATA[<p>Even, </p>
<p>Re-entrancy, as stronger requirement, assumes thread-safety. However, thread-safety does not necessarily mean re-entrancy. So, how you think to provide re-entrancy but dropping thread-safety at the same time. Perhaps you mix concept of parallelism &#8211; GDAL performing multiple tasks in parallel, internally as a black box.</p>
<p>Also, it is feasible to provide mechanism to disable thread-safety features during compile-time. Similarly to well-written parallel implementation of an algorithm, if it&#8217;s well designed, it should compile and execute in single-threaded mode as well as in multi-threaded mode.</p>
<p>Regarding the cost of thread safety, in my opinion it hardly would be comparable to general cost of operations performed by GDAL. GDAL does hard work that costs a lot itself. Of course, assuming there are no locks per pixel or short scanline, etc.</p>
<p>Another issue is that making GDAL re-entrant will most likely require substantial alternation of GDAL public API. Given GDAL development process, I can&#8217;t really imagine it happening in near future. There are many show stoppers on the horizon :-)</p>
<p>Regarding the reading, note in the FAQ says &#8221;as long as no two threads access the same GDALDataset object at the same time&#8221;. If it is more pessimistic than the actual status of implementation, would be good if someone knowledgeable could update it.</p>
<p>I&#8217;m no longer subscribed to gdal-dev, so I&#8217;ll take the liberty to continue posting here from time to time.</p>
<p>By the way, in case it&#8217;s relevant, a simple example of well-designed (simple) algorithms for raster processing can be found as small 2 headers extension to <a href="http://www.boost.org/doc/libs/release/libs/gil/doc/index.html" rel="nofollow">Adobe/Boost GIL</a> library, it is <a href="http://github.com/bogado/gil_threaded" rel="nofollow">gil threaded</a>. The idea of algorithmic approach to thread-safety is interesting, from <a href="http://github.com/bogado/gil_threaded/blob/master/readme" rel="nofollow">readme</a>: alg(x + y) = alg(x) + alg(y)</p>
<p>Thanks for sharing your thoughts Even!</p>
<p>Mat</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Even Rouault</title>
		<link>http://mateusz.loskot.net/2009/12/09/gdal-meets-edina/comment-page-1/#comment-2527</link>
		<dc:creator>Even Rouault</dc:creator>
		<pubDate>Wed, 09 Dec 2009 22:57:52 +0000</pubDate>
		<guid isPermaLink="false">http://mateusz.loskot.net/?p=1633#comment-2527</guid>
		<description>I don&#039;t necessarily agree that GDAL should be entirely thread-safe. This is a topic where pros and cons must be properly weighted. Thread safety has a cost that can be not neglectable in use cases where people don&#039;t need it. IMHO, the true target is to achieve proper re-entrency.

And, in read-only scenarios, GDAL can be safely used in a multithreading context as GDAL core and drivers for most popular formats are re-entrant (the note on the wiki sounds a bit too pessimistic with respect to the current situation).

To achieve that, I see 2 possibilities :
* either you use distinct dataset handles for each thread. The obvious drawback is that you can&#039;t benefit from potential shared cached blocks.
* either you use the same dataset handle under explicit locking. That&#039;s what a thread-safe GDAL API would do in fact : for file based formats, you must be sure that one thread will not mess with the file pointer used by another thread, so you would necessarily end up by serializing access to the dataset, which makes the interest of sharing the dataset less obvious... 

I&#039;d also note that the documentation of GDALOpenShared() insists on the fact the returned handle cannot be used at the same time by different threads. In case people wonder about the interest of GDALOpenShared() , I&#039;d mention the VRT driver where the same underlying dataset can be referenced by the sources from different bands.

The whole subject would be certainly interesting to discuss on gdal-dev ;-) By the way, a recently proposed RFC (http://trac.osgeo.org/gdal/wiki/rfc26_blockcache) discusses about thread-safety considerations in GDAL global block cache.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t necessarily agree that GDAL should be entirely thread-safe. This is a topic where pros and cons must be properly weighted. Thread safety has a cost that can be not neglectable in use cases where people don&#8217;t need it. IMHO, the true target is to achieve proper re-entrency.</p>
<p>And, in read-only scenarios, GDAL can be safely used in a multithreading context as GDAL core and drivers for most popular formats are re-entrant (the note on the wiki sounds a bit too pessimistic with respect to the current situation).</p>
<p>To achieve that, I see 2 possibilities :<br />
* either you use distinct dataset handles for each thread. The obvious drawback is that you can&#8217;t benefit from potential shared cached blocks.<br />
* either you use the same dataset handle under explicit locking. That&#8217;s what a thread-safe GDAL API would do in fact : for file based formats, you must be sure that one thread will not mess with the file pointer used by another thread, so you would necessarily end up by serializing access to the dataset, which makes the interest of sharing the dataset less obvious&#8230; </p>
<p>I&#8217;d also note that the documentation of GDALOpenShared() insists on the fact the returned handle cannot be used at the same time by different threads. In case people wonder about the interest of GDALOpenShared() , I&#8217;d mention the VRT driver where the same underlying dataset can be referenced by the sources from different bands.</p>
<p>The whole subject would be certainly interesting to discuss on gdal-dev ;-) By the way, a recently proposed RFC (<a href="http://trac.osgeo.org/gdal/wiki/rfc26_blockcache" rel="nofollow">http://trac.osgeo.org/gdal/wiki/rfc26_blockcache</a>) discusses about thread-safety considerations in GDAL global block cache.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

