<p>This is a somewhat low-level question.  In x86 assembly there are two SSE instructions: </p>

<blockquote>
  <p><code>MOVDQA <i><em>xmmi, m128</em></i></code></p>
</blockquote>

<p>and  </p>

<blockquote>
  <p><code>MOVNTDQA <i><em>xmmi, m128</em></i></code></p>
</blockquote>

<p>The IA-32 Software Developer's Manual says that the <em>NT</em> in MOVNTDQA stands for <em>Non-Temporal</em>, and that otherwise it's the same as MOVDQA.</p>

<p>My question is, what does <em>Non-Temporal</em> mean?  </p>

[{'answer_id': 37092, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 8, 'selected': True, 'text': '<p>Non-Temporal SSE instructions (MOVNTI, MOVNTQ, etc.), don\'t follow the normal cache-coherency rules. Therefore non-temporal stores must be followed by an SFENCE instruction in order for their results to be seen by other processors in a timely fashion.</p>\n\n<p>When data is produced and not (immediately) consumed again, the fact that memory store operations read a full cache line first and then modify the cached data is detrimental to performance. This operation pushes data out of the caches which might be needed again in favor of data which will not be used soon. This is especially true for large data structures, like matrices, which are filled and then used later. Before the last element of the matrix is filled the sheer size evicts the first elements, making caching of the writes ineffective.</p>\n\n<p>For this and similar situations, processors provide support for non-temporal write operations. Non-temporal in this context means the data will not be reused soon, so there is no reason to cache it. These non-temporal write operations do not read a cache line and then modify it; instead, the new content is directly written to memory. </p>\n\n<p>Source: <a href="http://lwn.net/Articles/255364/" rel="noreferrer">http://lwn.net/Articles/255364/</a></p>\n'}, {'answer_id': 38089, 'author': 'Pramod', 'author_id': 1386292, 'author_profile': 'https://Stackoverflow.com/users/1386292', 'pm_score': 5, 'selected': False, 'text': '<p>Espo is pretty much bang on target. Just wanted to add my two cents:</p>\n\n<p>The "non temporal" phrase means lacking temporal locality. Caches exploit two kinds of locality - spatial and temporal, and by using a non-temporal instruction you\'re signaling to the processor that you don\'t expect the data item be used in the near future.</p>\n\n<p>I am a little skeptical about the hand-coded assembly that uses the cache control instructions. In my experience these things lead to more evil bugs than any effective performance increases.</p>\n'}, {'answer_id': 53199688, 'author': 'chus', 'author_id': 1037634, 'author_profile': 'https://Stackoverflow.com/users/1037634', 'pm_score': 4, 'selected': False, 'text': '<p>According to the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1: Basic Architecture,\n&quot;Programming with Intel Streaming SIMD Extensions (Intel SSE)&quot; chapter:</p>\n<p><strong>Caching of Temporal vs. Non-Temporal Data</strong></p>\n<blockquote>\n<p>Data referenced by a program can be temporal (data will be used again) or non-temporal (data will be referenced once and not reused in the immediate future). For example, program code is generally temporal, whereas, multimedia data, such as the display list in a 3-D graphics application, is often non-temporal. To make efficient use of the processor’s caches, it is generally desirable to cache temporal data and not cache non-temporal data. Overloading the processor’s caches with non-temporal data is sometimes referred to as &quot;polluting the caches&quot;. The SSE and SSE2 cacheability control instructions enable a program to write non-temporal data to memory in a manner that minimizes pollution of caches.</p>\n</blockquote>\n<p>Description of non-temporal load and store instructions.\nSource: Intel 64 and IA-32 Architectures Software Developer’s Manual, Volume 2: Instruction Set Reference</p>\n<p><strong>LOAD (MOVNTDQA—Load Double Quadword Non-Temporal Aligned Hint)</strong></p>\n<blockquote>\n<p>Loads a double quadword from the source operand (second operand) to the destination operand (first operand) using a non-temporal hint if the memory source is WC (write combining) memory type [...]</p>\n<p>[...] the processor does not read the data into the cache hierarchy, nor does it fetch the corresponding cache line from memory into the cache hierarchy.</p>\n</blockquote>\n<p>Note that, as Peter Cordes comments, it\'s not useful on normal WB (write-back) memory on current processors because the NT hint is ignored (probably because there are no NT-aware HW prefetchers) and the full strongly-ordered load semantics apply. <code>prefetchnta</code> can be used as a pollution-reducing load from WB memory</p>\n<p><strong>STORE (MOVNTDQ—Store Packed Integers Using Non-Temporal Hint)</strong></p>\n<blockquote>\n<p>Moves the packed integers in the source operand (second operand) to the destination operand (first operand) using a non-temporal hint to prevent caching of the data during the write to memory.</p>\n<p>[...] the processor does not write the data into the cache hierarchy, nor does it fetch the corresponding cache line from memory into the cache hierarchy.</p>\n</blockquote>\n<p>Using the terminology defined in <a href="http://www.hpl.hp.com/techreports/Compaq-DEC/WRL-91-12.pdf" rel="noreferrer">Cache Write Policies and Performance</a>, they can be considered as write-around (no-write-allocate, no-fetch-on-write-miss).</p>\n<p>Finally, it may be interesting to review <a href="https://sites.utexas.edu/jdm4372/2018/01/01/notes-on-non-temporal-aka-streaming-stores/" rel="noreferrer">John McAlpin notes about non-temporal stores</a>.</p>\n'}]
['https://Stackoverflow.com/questions/37070', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1084/']