cc -Os +Op -noparallel -o hoge hoge.c -lpthreads -lc_r
でOK。最初の -Os は man によると
-O4 -loopfuse -loopsplit=2 -pvec -parallel=3 -coalescing -cyclic -syncreduce=2
-approx-dis-bracket -divmove -expmove
を設定して、実行時間が最短になるようにする最適化オプションだそうだ。
ちなみに次の +Op は man から読み取ると
If +Op is specified, compiler assumes that there is no dependency between each argument in the same invocation of function.
(参考訳)ある関数呼び出しにおける引数同士の間には依存がないことを仮定する
とのことらしい。これは具体例を挙げて説明しておこう。
int multiply(int* z[], int* x[], int* y[]){
for( int i = 0 ; i < N ; i++ ) z[i] = x[i] * y[i];
}
ここで、x, y, z として確保されている領域(正確には読まれる領域と書き込む領域)が重複しないということを仮定するということです。つまりこの関数を呼び出す時に
ret = multiply(xx, xx, yy);
なんてことをしてはいないという仮定です。