How can I load values from memory without polluting the cache?

前端 未结 2 1060
醉梦人生
醉梦人生 2021-02-13 05:19

I want to read a memory location without polluting the cache. I am working on X86 Linux machine. I tried using MOVNTDQA assembler instruction:

  asm(\"movntdqa %         


        
2条回答
  •  广开言路
    2021-02-13 05:40

    MOVNTDQA is only available with SSE.

    Why are you trying to avoid using the cache? CPUs are generally pretty good at deciding what to kick out of the cache when. If do genuinely need to, one way would be to arrange for an alias of the memory area you are reading from to be mapped into your address space with caching disabled and reading from there.

    If what you are trying to achieve is actually to minimise your code's impact on another function's working set being held in cache at the time, this should be doable by issuing appropriate prefetch and invalidate instructions.

提交回复
热议问题