<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Intel® Moderncode for Parallel ArchitecturesのトピックRe: full-blown experiential smr-based reference counted pointer</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/full-blown-experiential-smr-based-reference-counted-pointer-impl/m-p/993015#M6299</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;HR /&gt;

&lt;DIV&gt;
&lt;DIV&gt;Any questions and/or comments on smr-based reference counted pointers?&lt;BR /&gt;
&lt;HR /&gt;
&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;
&lt;DIV&gt;You could use the logic to create a simple atomic COW buffer like this:&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// buffer is assumed to be an efficent thread-safe buffer...&lt;BR /&gt;&lt;FONT face="Courier New"&gt;typedef local_smr_ptr&amp;lt; buffer &amp;gt; local_bufptr_t;&lt;BR /&gt;typedef shared_smr_ptr&amp;lt; buffer &amp;gt; shared_bufptr_t;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// shared&lt;BR /&gt;&lt;FONT face="Courier New"&gt;static shared_bufptr_t g_buf( new buffer( "init" ) );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// COW /w CAS&lt;BR /&gt;&lt;FONT face="Courier New"&gt;local_bufptr_t cmp, xchg( new buffer );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;do&lt;BR /&gt;{ cmp = g_buf;&lt;BR /&gt; cmp-&amp;gt;copy_to( xchg );&lt;BR /&gt; xchg-&amp;gt;append( " updated via. CAS" );&lt;BR /&gt;} while ( ! g_buf.cas( cmp, xchg ) );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// COW /w XCHG&lt;BR /&gt;&lt;FONT face="Courier New"&gt;local_bufptr_t xchg( new buffer ),&lt;BR /&gt; cmp( g_buf );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;cmp-&amp;gt;copy_to( xchg );&lt;BR /&gt;xchg-&amp;gt;append( " updated via. XCHG" );&lt;BR /&gt;g_buf.xchg( xchg );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;Or you could use the SMR pointer to create robust synchronization objects &lt;BR /&gt;that will never be destroyed if there any threads that have references to &lt;BR /&gt;them:&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// mutex is assumed to be an efficent mutex...&lt;BR /&gt;&lt;FONT face="Courier New"&gt;typedef local_smr_ptr&amp;lt; mutex &amp;gt; local_mutexptr_t;&lt;BR /&gt;typedef shared_smr_ptr&amp;lt; mutex &amp;gt; shared_mutexptr_t;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// shared&lt;BR /&gt;&lt;FONT face="Courier New"&gt;static shared_mutexptr_t g_mutex( new mutex );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// Lock/Unlock&lt;BR /&gt;&lt;FONT face="Courier New"&gt;local_mutexptr_t l_mutex( g_mutex );&lt;BR /&gt;if ( ! l_mutex ) { return; }&lt;BR /&gt;l_mutex-&amp;gt;lock();&lt;BR /&gt;// whatever&lt;BR /&gt;l_mutex-&amp;gt;unlock();&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;The smr atomic pointer has an expensive (store/load) before the reference &lt;BR /&gt;count can even be incremented. So, its a fairly costly when you load a &lt;BR /&gt;shared pointer into a local pointer. You would not want to use this for &lt;BR /&gt;everything. &lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 31 Mar 2005 19:24:57 GMT</pubDate>
    <dc:creator>Chris_M__Thomasson</dc:creator>
    <dc:date>2005-03-31T19:24:57Z</dc:date>
    <item>
      <title>full-blown experiential smr-based reference counted pointer impl...</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/full-blown-experiential-smr-based-reference-counted-pointer-impl/m-p/993014#M6298</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;I have implemented an experimental reference counted pointer C api based on SMR. I also includedtwo extremely quick and dirty atomic C++ smart pointer classes that are based on the reference count api. Its basically just a proof of concept. There is a MSVC++ 6.0 workspace and two Dev-C++ projects included, so you can buildAppCore on Windowsright away. The projects build the appcore.dll in the c:/winnt/system32 directory, so you may need to change this to fit your needs:&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;A href="http://appcore.home.comcast.net/appcore_3_30_2005.zip" target="_blank"&gt;http://appcore.home.comcast.net/appcore_3_30_2005.zip&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I am currently working on Linux build instructions. You basically need to assemble the ac_i686_gcc.asm files and link against the resulting object file.&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Any questions and/or comments on smr-based reference counted pointers?&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Enjoy! ;)&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 31 Mar 2005 10:59:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/full-blown-experiential-smr-based-reference-counted-pointer-impl/m-p/993014#M6298</guid>
      <dc:creator>Chris_M__Thomasson</dc:creator>
      <dc:date>2005-03-31T10:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: full-blown experiential smr-based reference counted pointer</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/full-blown-experiential-smr-based-reference-counted-pointer-impl/m-p/993015#M6299</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;HR /&gt;

&lt;DIV&gt;
&lt;DIV&gt;Any questions and/or comments on smr-based reference counted pointers?&lt;BR /&gt;
&lt;HR /&gt;
&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;
&lt;DIV&gt;You could use the logic to create a simple atomic COW buffer like this:&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// buffer is assumed to be an efficent thread-safe buffer...&lt;BR /&gt;&lt;FONT face="Courier New"&gt;typedef local_smr_ptr&amp;lt; buffer &amp;gt; local_bufptr_t;&lt;BR /&gt;typedef shared_smr_ptr&amp;lt; buffer &amp;gt; shared_bufptr_t;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// shared&lt;BR /&gt;&lt;FONT face="Courier New"&gt;static shared_bufptr_t g_buf( new buffer( "init" ) );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// COW /w CAS&lt;BR /&gt;&lt;FONT face="Courier New"&gt;local_bufptr_t cmp, xchg( new buffer );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;do&lt;BR /&gt;{ cmp = g_buf;&lt;BR /&gt; cmp-&amp;gt;copy_to( xchg );&lt;BR /&gt; xchg-&amp;gt;append( " updated via. CAS" );&lt;BR /&gt;} while ( ! g_buf.cas( cmp, xchg ) );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// COW /w XCHG&lt;BR /&gt;&lt;FONT face="Courier New"&gt;local_bufptr_t xchg( new buffer ),&lt;BR /&gt; cmp( g_buf );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Courier New"&gt;cmp-&amp;gt;copy_to( xchg );&lt;BR /&gt;xchg-&amp;gt;append( " updated via. XCHG" );&lt;BR /&gt;g_buf.xchg( xchg );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;Or you could use the SMR pointer to create robust synchronization objects &lt;BR /&gt;that will never be destroyed if there any threads that have references to &lt;BR /&gt;them:&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// mutex is assumed to be an efficent mutex...&lt;BR /&gt;&lt;FONT face="Courier New"&gt;typedef local_smr_ptr&amp;lt; mutex &amp;gt; local_mutexptr_t;&lt;BR /&gt;typedef shared_smr_ptr&amp;lt; mutex &amp;gt; shared_mutexptr_t;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// shared&lt;BR /&gt;&lt;FONT face="Courier New"&gt;static shared_mutexptr_t g_mutex( new mutex );&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;// Lock/Unlock&lt;BR /&gt;&lt;FONT face="Courier New"&gt;local_mutexptr_t l_mutex( g_mutex );&lt;BR /&gt;if ( ! l_mutex ) { return; }&lt;BR /&gt;l_mutex-&amp;gt;lock();&lt;BR /&gt;// whatever&lt;BR /&gt;l_mutex-&amp;gt;unlock();&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;The smr atomic pointer has an expensive (store/load) before the reference &lt;BR /&gt;count can even be incremented. So, its a fairly costly when you load a &lt;BR /&gt;shared pointer into a local pointer. You would not want to use this for &lt;BR /&gt;everything. &lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 31 Mar 2005 19:24:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/full-blown-experiential-smr-based-reference-counted-pointer-impl/m-p/993015#M6299</guid>
      <dc:creator>Chris_M__Thomasson</dc:creator>
      <dc:date>2005-03-31T19:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: full-blown experiential smr-based reference counted pointer</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/full-blown-experiential-smr-based-reference-counted-pointer-impl/m-p/993016#M6300</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;I noticed that I was not aligning the per-thread hazard pointer &lt;BR /&gt;data-structures on separate cache-lines!!! This is not a bug, it is just a &lt;BR /&gt;fairly major performance issue... You should probably re-download:&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;A href="http://appcore.home.comcast.net/appcore_4_1_2005.zip" target="_blank"&gt;http://appcore.home.comcast.net/appcore_4_1_2005.zip&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Aligning the per-thread SMR data-structures on separate cache-lines shaves &lt;BR /&gt;off an average of 2 - 3 seconds of runtime from nearly all of my tests!&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;Sorry! :O &lt;BR /&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 01 Apr 2005 17:18:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/full-blown-experiential-smr-based-reference-counted-pointer-impl/m-p/993016#M6300</guid>
      <dc:creator>Chris_M__Thomasson</dc:creator>
      <dc:date>2005-04-01T17:18:09Z</dc:date>
    </item>
  </channel>
</rss>

