Optimizing linear access to arrays with pre-fetching and cache in C

前端 未结 3 676
[愿得一人]
[愿得一人] 2021-02-12 19:16

disclosure: I\'ve tried similar question on programmers.stack, but that place is nowhere near activity stack is.

Intro

I tend to work with lots

3条回答
  •  梦如初夏
    2021-02-12 19:54

    You should compile with a recent GCC (so having compiled your GCC 5.2 is a good idea, in November 2015), and you should enable optimizations for your particular platform, so I suggest compiling with gcc -Wall -O2 -march=native at least (try also to replace -O2 with -O3).

    (Don't benchmark your programs without enabling optimizations in your compiler)

    If you are concerned with cache effects, you might play with __builtin_prefetch, but see this.

    Read also about OpenMP, OpenCL, OpenACC.

提交回复
热议问题