title: How can I load values from memory without polluting the cache?
body: <p>I want to read a memory location without polluting the cache. I am working on X86 Linux machine. I tried using MOVNTDQA assembler instruction:</p>
  
  <pre><code>  asm("movntdqa %[source], %[dest] \n\t"
        : [dest] "=x" (my_var) : [source] "m" (my_mem[0]) : "memory");
  </code></pre>
  
  <p>my_mem is an int* allocated with new, my_var is an int.</p>
  
  <p>I have two problems with this approach:</p>
  
  <ol>
  <li>The code compiles but I am getting "Illegal Instruction" error when running it. Any ideas why?</li>
  <li>I am not sure what type of memory is allocated with new. I would assume that WB. According to documentation, the MOVNTDQA instruction will work only will USWC memory type. How can I know what memory type I am working on?</li>
  </ol>
  
  <p>To summarize, my question is:</p>
  
  <p>How can I read a memory location without polluting the cache on an X86 machine? Is my approach in the right direction, and can it be fixed to work?</p>
  
  <p>Thanks.</p>