<?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>topic Memory reordering: Can loads be reordered with earlier stores t in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773439#M153</link>
    <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Hi everybody,&lt;BR /&gt;&lt;BR /&gt;I'd like to reiterate interest in that really great post and here are results of my investifation.&lt;BR /&gt;&lt;BR /&gt;Quoting &lt;A jquery1345508768593="60" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=99850" href="https://community.intel.com/en-us/profile/99850/" class="basic"&gt;jimdempseyatthecove&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;I&gt;...Then modifying your original post, assume that your var spanned two cache lines (var.individual_var[0] in one cach line, [1] in the next cache line)...&lt;/I&gt;&lt;/DIV&gt;&lt;BR /&gt;Jim, Is it really possible? Please take a look at my comments.&lt;BR /&gt;&lt;BR /&gt;This is a &lt;STRONG&gt;C union&lt;/STRONG&gt; andthis is not a &lt;STRONG&gt;C struct&lt;/STRONG&gt;. Because of this a memory for'&lt;STRONG&gt;shared&lt;/STRONG&gt;' 64-bit component of the unionis&lt;BR /&gt;&lt;SPAN style="text-decoration: underline;"&gt;shared&lt;/SPAN&gt; between two 32-bit '&lt;STRONG&gt;individual&lt;/STRONG&gt;' components ( array of two )of the same union.&lt;BR /&gt;&lt;BR /&gt;Then, C++ compilers for Windows platforms have 8-byte default alignment.If a &lt;STRONG&gt;_declspec( align(#) )&lt;/STRONG&gt; specificator&lt;BR /&gt;is not used, as inour case,a C++ compiler should align data on natural boundaries and in that case this is 8-byte alignment.&lt;BR /&gt;&lt;BR /&gt; sizeof( my_union_t ) = 8&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;I'd like to re-phrase your question&lt;/STRONG&gt;:&lt;BR /&gt;&lt;BR /&gt; Is it possible that in case ofa 64-bit variable &lt;STRONG&gt;V&lt;/STRONG&gt;thelow-part &lt;STRONG&gt;VL&lt;/STRONG&gt;( 32-bit )will be in a &lt;STRONG&gt;cache line A&lt;/STRONG&gt; and&lt;BR /&gt; the high-part &lt;STRONG&gt;VH&lt;/STRONG&gt;( 32-bit ) will be in a &lt;STRONG&gt;cache line B&lt;/STRONG&gt;?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Sergey&lt;/DIV&gt;</description>
    <pubDate>Tue, 21 Aug 2012 02:15:11 GMT</pubDate>
    <dc:creator>SergeyKostrov</dc:creator>
    <dc:date>2012-08-21T02:15:11Z</dc:date>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores to different but encompassing location?</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773434#M148</link>
      <description>&lt;DIV class="post-text" itemprop="description"&gt;&lt;P&gt;In intel's processor manual:&lt;A href="http://download.intel.com/products/processor/manual/253668.pdf" rel="nofollow"&gt;link&lt;/A&gt;in section 8.2.3.4 it is stated that loads may be reordered with earlier stores to different locations, but not with earlier stores to the same location.&lt;/P&gt;&lt;P&gt;So I understand that the following two operations can be reordered:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;x = 1;
y = z;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And that the following two operations can not be reordered:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;x = 1;
y = x;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But what happens when the store and the load are for different locations, but the load encompasses the store completely, e.g:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;typedef union {
  uint64_t shared_var;
  uint32_t individual_var[2];
} my_union_t;

my_union_t var;
var.shared_var = 0;

var.individual_var[1] = 1;
int y = var.shared_var;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So can 'y' in this case be 0?&lt;/P&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 05 Aug 2012 14:13:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773434#M148</guid>
      <dc:creator>syljak</dc:creator>
      <dc:date>2012-08-05T14:13:49Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773435#M149</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1344310587625="60" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=572866" href="https://community.intel.com/en-us/profile/572866/" class="basic"&gt;syljak&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;EM&gt;...But what happens when the store and the load are for different locations, but the load encompasses the store completely, e.g:&lt;/EM&gt;&lt;DIV itemprop="description" class="post-text"&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;EM&gt;typedef &lt;/EM&gt;&lt;STRONG&gt;union&lt;/STRONG&gt;&lt;EM&gt; {
  uint64_t shared_var;
  uint32_t individual_var[2];
} my_union_t;&lt;BR /&gt;
my_union_t var;&lt;BR /&gt;
&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;var.shared_var = 0;
var.individual_var[1] = 1;&lt;BR /&gt;
&lt;BR /&gt;int y = var.shared_var;&lt;BR /&gt;
&lt;/EM&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;So can 'y' in this case be 0?&lt;/STRONG&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;No.I use &lt;STRONG&gt;C unions&lt;/STRONG&gt; extensively and they are at the core of some &lt;STRONG&gt;C union&lt;/STRONG&gt; basedfunctionality. It would be a complete&lt;BR /&gt;technical disaster ifa CPUwould re-order these twoassignments.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Sergey&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2012 03:45:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773435#M149</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-07T03:45:38Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773436#M150</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1344311380828="60" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=572866" href="https://community.intel.com/en-us/profile/572866/" class="basic"&gt;syljak&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;EM&gt;In intel's processor manual:&lt;/EM&gt;&lt;A rel="nofollow" href="http://download.intel.com/products/processor/manual/253668.pdf"&gt;&lt;EM&gt;link&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;in section 8.2.3.4 it is stated that loads may be reordered with earlier&lt;BR /&gt;stores to &lt;/EM&gt;&lt;STRONG&gt;different locations&lt;/STRONG&gt;&lt;EM&gt;...&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;Two union members shown in your example are not at different memoryaddresslocations.&lt;BR /&gt;&lt;BR /&gt;Please take a look in a Debugger(Memory window)what happens when 1st assignment is done and then howthe 2nd assignment&lt;BR /&gt;changes the value at the same memory address forsome variable of type '&lt;STRONG&gt;my_union_t&lt;/STRONG&gt;'.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Sergey&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2012 03:58:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773436#M150</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-07T03:58:01Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773437#M151</link>
      <description>Syljak,&lt;BR /&gt;&lt;BR /&gt;Keep in mind that the inner levels of the CPU deal in cache line sized data with respect to loads and stores.&lt;BR /&gt;&lt;BR /&gt;Then modifying your original post, assume that your var spanned two cache lines (var.individual_var[0] in one cach line, [1] in the next cache line). Assume further that the var components are not in cache.&lt;BR /&gt;&lt;BR /&gt;var.shared_var = 0;&lt;BR /&gt; post read into cache RAM containing [0]&lt;BR /&gt; post read into cache RAM containing [1]&lt;BR /&gt; post modify [0] portion of cache line containing [0]&lt;BR /&gt; post modify [1] portion of cache line containing [1]&lt;BR /&gt; (writes may reorder)&lt;BR /&gt;&lt;BR /&gt;var.individual_var[1] = 1;&lt;BR /&gt; cach hit on [1], read of cache line stalls while write pending for same cache line&lt;BR /&gt; when prior write complete, post write [1] portion of cache line containing [1]&lt;BR /&gt; Note, write ordering assures [0] portion written first on = 0 statement&lt;BR /&gt;&lt;BR /&gt;int y = var.shared_var;&lt;BR /&gt; cache hit on [0] portion&lt;BR /&gt; cache hit on [1] portion, but write may be pending, so pipeline may stall for write to cach to complete&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;IOW you will never see 0 in y (unless CPU microcode is defective)&lt;BR /&gt;&lt;BR /&gt;The above is descriptive as opposed to technical. The CPU designers are very good at their job. In the above circumstance, the refetch may bypass the write completion (at least for same core). &lt;BR /&gt;&lt;BR /&gt;Jim Dempsey</description>
      <pubDate>Tue, 07 Aug 2012 12:43:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773437#M151</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-08-07T12:43:57Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773438#M152</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1344388138687="60" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=99850" href="https://community.intel.com/en-us/profile/99850/" class="basic"&gt;jimdempseyatthecove&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;EM&gt;...Then modifying your original post, assume that your &lt;/EM&gt;&lt;STRONG&gt;var spanned two cache lines&lt;/STRONG&gt;&lt;EM&gt; ( &lt;/EM&gt;&lt;STRONG&gt;var.individual_var[0] in one cach line, [1] in the next cache line &lt;/STRONG&gt;&lt;EM&gt;)...&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;Thank you, Jim! It is a verygoodexample.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Sergey&lt;/DIV&gt;</description>
      <pubDate>Wed, 08 Aug 2012 01:14:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773438#M152</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-08T01:14:16Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773439#M153</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Hi everybody,&lt;BR /&gt;&lt;BR /&gt;I'd like to reiterate interest in that really great post and here are results of my investifation.&lt;BR /&gt;&lt;BR /&gt;Quoting &lt;A jquery1345508768593="60" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=99850" href="https://community.intel.com/en-us/profile/99850/" class="basic"&gt;jimdempseyatthecove&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;I&gt;...Then modifying your original post, assume that your var spanned two cache lines (var.individual_var[0] in one cach line, [1] in the next cache line)...&lt;/I&gt;&lt;/DIV&gt;&lt;BR /&gt;Jim, Is it really possible? Please take a look at my comments.&lt;BR /&gt;&lt;BR /&gt;This is a &lt;STRONG&gt;C union&lt;/STRONG&gt; andthis is not a &lt;STRONG&gt;C struct&lt;/STRONG&gt;. Because of this a memory for'&lt;STRONG&gt;shared&lt;/STRONG&gt;' 64-bit component of the unionis&lt;BR /&gt;&lt;SPAN style="text-decoration: underline;"&gt;shared&lt;/SPAN&gt; between two 32-bit '&lt;STRONG&gt;individual&lt;/STRONG&gt;' components ( array of two )of the same union.&lt;BR /&gt;&lt;BR /&gt;Then, C++ compilers for Windows platforms have 8-byte default alignment.If a &lt;STRONG&gt;_declspec( align(#) )&lt;/STRONG&gt; specificator&lt;BR /&gt;is not used, as inour case,a C++ compiler should align data on natural boundaries and in that case this is 8-byte alignment.&lt;BR /&gt;&lt;BR /&gt; sizeof( my_union_t ) = 8&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;I'd like to re-phrase your question&lt;/STRONG&gt;:&lt;BR /&gt;&lt;BR /&gt; Is it possible that in case ofa 64-bit variable &lt;STRONG&gt;V&lt;/STRONG&gt;thelow-part &lt;STRONG&gt;VL&lt;/STRONG&gt;( 32-bit )will be in a &lt;STRONG&gt;cache line A&lt;/STRONG&gt; and&lt;BR /&gt; the high-part &lt;STRONG&gt;VH&lt;/STRONG&gt;( 32-bit ) will be in a &lt;STRONG&gt;cache line B&lt;/STRONG&gt;?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Sergey&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Aug 2012 02:15:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773439#M153</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-21T02:15:11Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773440#M154</link>
      <description>&lt;STRONG&gt;Here is a test-case&lt;/STRONG&gt;:&lt;BR /&gt;[cpp]...
typedef unsigned __int64	RTuint64;
typedef __int32			    RTint32;
...
typedef union tagMyUnion_t
{
	RTuint64 shared_var;
	RTint32 individual_var[2];
} MyUnion_t;

MyUnion_t uVar;

RTuint64 uiVar64;
RTint32 iVar32;

printf( "&amp;gt;&amp;gt; Size of Data type &amp;lt;&lt;N&gt;&amp;gt; Alignment Requirements of Data types &amp;lt;&lt;N&gt;&amp;gt; Case 1 &amp;lt;&lt;N&gt;&amp;gt; Case 2 &amp;lt;&lt;N&gt;&amp;gt; Case 3 &amp;lt;&lt;N&gt;&amp;gt; Case 4 &amp;lt;&lt;N&gt;&amp;gt; Case 5 &amp;lt;&lt;N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;</description>
      <pubDate>Tue, 21 Aug 2012 02:18:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773440#M154</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-21T02:18:30Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773441#M155</link>
      <description>&lt;STRONG&gt;Here is output of the test-case&lt;/STRONG&gt;:&lt;BR /&gt;[cpp]...
&amp;gt;&amp;gt; Size of Data type &amp;lt;&amp;lt;
        Sizeof( MyUnion_t ) = 8 bytes

&amp;gt;&amp;gt; Alignment Requirements of Data types &amp;lt;&amp;lt;
        __alignof( MyUnion_t ) = 8 bytes
        __alignof( RTuint64  ) = 8 bytes
        __alignof( RTint32   ) = 4 bytes

&amp;gt;&amp;gt; Case 1 &amp;lt;&amp;lt;
        uVar.shared_var = 0

        MyUnion_t.shared_var        = 0
        MyUnion_t.individual_var[0] = 0
        MyUnion_t.individual_var[1] = 0

&amp;gt;&amp;gt; Case 2 &amp;lt;&amp;lt;
        uVar.individual_var[0] = 1

        MyUnion_t.shared_var        = 1
        MyUnion_t.individual_var[0] = 1
        MyUnion_t.individual_var[1] = 0

&amp;gt;&amp;gt; Case 3 &amp;lt;&amp;lt;
        uVar.individual_var[1] = 1

        MyUnion_t.shared_var        = 4294967297
        MyUnion_t.individual_var[0] = 1
        MyUnion_t.individual_var[1] = 1

&amp;gt;&amp;gt; Case 4 &amp;lt;&amp;lt;
        uVar.individual_var[0] = 55
        uVar.individual_var[1] = 77

        MyUnion_t.shared_var        = 330712481847
        MyUnion_t.individual_var[0] = 55
        MyUnion_t.individual_var[1] = 77

&amp;gt;&amp;gt; Case 5 &amp;lt;&amp;lt;
        RTint64 y = uVar.shared_var

        Variable 'y'                = 330712481847
...
[/cpp]</description>
      <pubDate>Tue, 21 Aug 2012 02:19:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773441#M155</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-21T02:19:28Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773442#M156</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1345514329921="60" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=572866" href="https://community.intel.com/en-us/profile/572866/" class="basic"&gt;syljak&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;EM&gt;...&lt;BR /&gt;&lt;/EM&gt;&lt;CODE&gt;&lt;EM&gt;typedef union {&lt;BR /&gt; uint64_t shared_var;&lt;BR /&gt; uint32_t individual_var[2];&lt;BR /&gt;} my_union_t;&lt;BR /&gt;&lt;BR /&gt;my_union_t var;&lt;BR /&gt;&lt;BR /&gt;var.shared_var = 0;&lt;BR /&gt;var.individual_var[1] = 1;&lt;BR /&gt;&lt;BR /&gt;int y = var.shared_var;&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/CODE&gt;&lt;STRONG&gt;So can 'y' in this case be 0?&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&amp;gt;&amp;gt; &lt;STRONG&gt;Case 1&lt;/STRONG&gt; &amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt; If assignments are done in the above order ('&lt;STRONG&gt;shared&lt;/STRONG&gt;' first, '&lt;STRONG&gt;individual[1]&lt;/STRONG&gt;' second, and then '&lt;STRONG&gt;y&lt;/STRONG&gt;')output is as follows:&lt;BR /&gt;&lt;BR /&gt; var.shared_var = 4294967296&lt;BR /&gt; var.individual_var[0] = 0&lt;BR /&gt; var.individual_var[1] = 1&lt;BR /&gt;&lt;BR /&gt; &lt;STRONG&gt;y = 4294967296&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; &lt;STRONG&gt;Case 2&lt;/STRONG&gt; &amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt; If assignments are &lt;SPAN style="text-decoration: underline;"&gt;re-ordered&lt;/SPAN&gt; ('&lt;STRONG&gt;individual[1]&lt;/STRONG&gt;'first,'&lt;STRONG&gt;shared&lt;/STRONG&gt;' second, and then '&lt;STRONG&gt;y&lt;/STRONG&gt;')outpit isas follows:&lt;BR /&gt;&lt;BR /&gt; var.shared_var =0&lt;BR /&gt; var.individual_var[0] = 0&lt;BR /&gt; var.individual_var[1] =0&lt;BR /&gt;&lt;BR /&gt; &lt;STRONG&gt;y = 0&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 02:20:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773442#M156</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-21T02:20:06Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773443#M157</link>
      <description>&amp;gt;&amp;gt;Then, C++ compilers for Windows platforms have 8-byte default alignment.If a &lt;STRONG&gt;_declspec( align(#) )&lt;/STRONG&gt; specificator is not used, as inour case,a C++ compiler should align data on natural boundaries and in that case this is 8-byte alignment.&lt;BR /&gt;&lt;BR /&gt;The above is a false assumption. There is nothing in the C++ (or C) specification that assures such an alignment without compiler supported alignment directive (that also enforceable). In the event that a given version of a compiler (and runtime system) provides natural alignment, there is no assurance that a next version, or some other vendor's compilerwill assure such alignment.&lt;BR /&gt;&lt;BR /&gt;On Windows 7 x64, VS 2010, 32-bit application:&lt;BR /&gt;[cpp]// my_union.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include &lt;IOSTREAM&gt;

#define uint64_t __int64
#define uint32_t __int32

typedef union {
  uint64_t shared_var;
  uint32_t individual_var[2];
} my_union_t;



int _tmain(int argc, _TCHAR* argv[])
{
	my_union_t	var1;
	char	c;
	my_union_t	var2;

	std::cout &amp;lt;&amp;lt; &amp;amp;var1 &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; &amp;amp;var2 &amp;lt;&amp;lt; std::endl;
	// displays 0037FBF0 0037FBD4
	my_union_t* avar1 = new my_union_t;
	my_union_t* avar2 = new my_union_t;
	std::cout &amp;lt;&amp;lt; &amp;amp;avar1-&amp;gt;shared_var &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; &amp;amp;avar2-&amp;gt;shared_var &amp;lt;&amp;lt; std::endl;
	return 0;
}

[/cpp]&lt;BR /&gt;Note the comment after the cout, the var2 address is not on a multiple of 8. This is what was displayed on the above mentioned system.&lt;BR /&gt;&lt;BR /&gt;When compiling as 64-bit application we see:&lt;BR /&gt;&lt;BR /&gt;[cpp]000000000028FE28 000000000028FE48
[/cpp]&lt;BR /&gt;Which is aligned on natural boundary.&lt;BR /&gt;&lt;BR /&gt;---------------&lt;BR /&gt;&lt;BR /&gt;The natural alignment of a union is not the focus of the issue of this thread. Instead, the focus of this thread is "Can loads be reorder... with respect to writes". The "assumes" of my post were to construct a scenario whereby there is a plausibility or conceivability that your question could be tested. Create a test scenario that tests the memory order issue of your concern.&lt;BR /&gt;&lt;BR /&gt;Note, the assumptions in my post specified a cache line split between individual_var[0] and [1], but not inside either individual_var[0] of[1], IOW the union was at least 32-bit aligned.&lt;BR /&gt;&lt;BR /&gt;The argument you wish (need) to resolve is not specific to your my_union_t but rather in general to reads and writes.&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;/IOSTREAM&gt;</description>
      <pubDate>Tue, 21 Aug 2012 14:41:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773443#M157</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-08-21T14:41:34Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773444#M158</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1345595386390="60" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=99850" href="https://community.intel.com/en-us/profile/99850/" class="basic"&gt;jimdempseyatthecove&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;EM&gt;&amp;gt;&amp;gt;Then, C++ compilers for Windows platforms have 8-byte default alignment.If a &lt;STRONG&gt;_declspec( align(#) )&lt;/STRONG&gt; specificator is not used, as inour case,a C++ compiler should align data on natural boundaries and in that case this is 8-byte alignment.&lt;BR /&gt;&lt;BR /&gt;The above is a false assumption.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt; [&lt;STRONG&gt;SergeyK&lt;/STRONG&gt;] Could we trust to &lt;STRONG&gt;MSDN&lt;/STRONG&gt;? It looks like No and a software developer should always verify statements.&lt;BR /&gt;&lt;EM&gt;&lt;BR /&gt;...Note, the assumptions in my post specified a cache line split between individual_var[0] and [1], but not inside either individual_var[0] of[1], IOW the union was at least 32-bit aligned...&lt;/EM&gt;&lt;/DIV&gt;&lt;BR /&gt;I didn't mean inside of '&lt;STRONG&gt;individual_var&lt;/STRONG&gt;' members. There is another member '&lt;STRONG&gt;shared_var&lt;/STRONG&gt;'of the union and this is the 64-bit data type.&lt;BR /&gt;&lt;BR /&gt;I wanted to stress thatthese three members are sharing the same memory blockof 8 bytes in the union. Also, there is a mapping&lt;BR /&gt;between these members of the union, like:&lt;BR /&gt;&lt;BR /&gt; 32-bit&lt;STRONG&gt;individual_var[0]&lt;/STRONG&gt;is a lower part of 64-bit&lt;STRONG&gt;shared_var&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;and&lt;BR /&gt;&lt;BR /&gt; 32-bit&lt;STRONG&gt;individual_var[1]&lt;/STRONG&gt; is ahigher part of 64-bit&lt;STRONG&gt;shared_var&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;It means that theunion '&lt;STRONG&gt;my_union_t&lt;/STRONG&gt;' can not be splitted in two cache lines. Sorry for a little deviation from the main subject.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Sergey&lt;/DIV&gt;</description>
      <pubDate>Wed, 22 Aug 2012 00:49:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773444#M158</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-22T00:49:03Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773445#M159</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1345596633484="60" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=99850" href="https://community.intel.com/en-us/profile/99850/" class="basic"&gt;jimdempseyatthecove&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;I&gt;...The argument you wish (need) to resolve is not specific to your my_union_t but rather in general to reads and writes...&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;Let me repeat my question:&lt;BR /&gt;&lt;BR /&gt; Is it possible that in case ofa &lt;SPAN style="text-decoration: underline;"&gt;64-bit variable&lt;/SPAN&gt; &lt;STRONG&gt;V&lt;/STRONG&gt;thelow-part &lt;STRONG&gt;VL&lt;/STRONG&gt;( 32-bit )will be in a &lt;STRONG&gt;cache line A&lt;/STRONG&gt; and&lt;BR /&gt; the high-part &lt;STRONG&gt;VH&lt;/STRONG&gt;( 32-bit ) will be in a &lt;STRONG&gt;cache line B&lt;/STRONG&gt;?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Sergey&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2012 00:53:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773445#M159</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-22T00:53:14Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773446#M160</link>
      <description>&amp;gt;&amp;gt;It means that theunion '&lt;STRONG&gt;my_union_t&lt;/STRONG&gt;' can not be splitted in two cache lines. Sorry for a little deviation from the main subject&lt;BR /&gt;&lt;BR /&gt;Did you read the comment in the source code I posted. It contains the display values for the addresses of two of your my_uniont_t structs. (x32 app)&lt;BR /&gt;&lt;BR /&gt;std::cout &amp;lt;&amp;lt; &amp;amp;var1 &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; &amp;amp;var2 &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;// displays 0037FBF0 0037FBD4&lt;BR /&gt;&lt;BR /&gt;The first var lies on 16 byte aligned address, the secone lies on 4 byte aligned address. Meaing your 64-bit variable shared_var could be split across two cache lines.&lt;BR /&gt;&lt;BR /&gt;Jim</description>
      <pubDate>Wed, 22 Aug 2012 12:31:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773446#M160</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2012-08-22T12:31:59Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773447#M161</link>
      <description>&lt;DIV id="tiny_quote"&gt;&lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A jquery1345685597250="60" rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=99850" href="https://community.intel.com/en-us/profile/99850/" class="basic"&gt;jimdempseyatthecove&lt;/A&gt;&lt;/DIV&gt;&lt;DIV style="background-color: #e5e5e5; margin-left: 2px; margin-right: 2px; border: 1px inset; padding: 5px;"&gt;&lt;EM&gt;...std::cout &amp;lt;&amp;lt; &amp;amp;var1 &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; &amp;amp;var2 &amp;lt;&amp;lt; std::endl;&lt;BR /&gt;// displays 0037FBF0 0037FBD4&lt;BR /&gt;&lt;BR /&gt;The first var lies on &lt;/EM&gt;&lt;STRONG&gt;16 byte aligned address&lt;/STRONG&gt;&lt;EM&gt;, the secone lies &lt;/EM&gt;&lt;STRONG&gt;on 4 byte aligned address&lt;/STRONG&gt;&lt;EM&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt; [&lt;STRONG&gt;SergeyK&lt;/STRONG&gt;] Yes, I read it and even verified with Windows Calculator.&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;Meaing your &lt;/EM&gt;&lt;STRONG&gt;64-bit variable shared_var &lt;SPAN style="text-decoration: underline;"&gt;could be split&lt;/SPAN&gt; across two cache lines&lt;/STRONG&gt;&lt;EM&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt; [&lt;STRONG&gt;SergeyK&lt;/STRONG&gt;] I see. Thank you, Jim.&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Sergey&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2012 01:37:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773447#M161</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2012-08-23T01:37:07Z</dc:date>
    </item>
    <item>
      <title>Memory reordering: Can loads be reordered with earlier stores t</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773448#M162</link>
      <description>I've created a small&lt;B&gt;test-case&lt;/B&gt; in &lt;B&gt;C++&lt;/B&gt; that uses some &lt;B&gt;OpenMP&lt;/B&gt; functionalityand compiled it with &lt;B&gt;Intel C++ compiler&lt;/B&gt;.&lt;BR /&gt;I could post the source codes if you need and please confirm me.</description>
      <pubDate>Sun, 26 Aug 2012 12:47:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/Memory-reordering-Can-loads-be-reordered-with-earlier-stores-to/m-p/773448#M162</guid>
      <dc:creator>sureshgupta22</dc:creator>
      <dc:date>2012-08-26T12:47:58Z</dc:date>
    </item>
  </channel>
</rss>

