楼上的代码,稍微改了一下openmp线程数=16
$ g++ -DNTHREADS=16 -std=c++20 -Wall -O3 -ffast-math -fopenmp -mavx2 -o out-avx2 test.cxx
$ ./out-avx2
OpenMP init.
Run0 resut is 4999999950000000.00, done in 0.347654 s!
Run1 resut is 4999999950000000.00, done in 0.022820 s!
Run2 resut is 4999999950000000.00, done in 0.022877 s!
Run3 resut is 4999999950000000.00, done in 0.022880 s!
Run4 resut is 4999999950000000.00, done in 0.024044 s!
Run5 resut is 4999999950000000.00, done in 0.001822 s!
Run6 resut is 4999999950000000.00, done in 0.001357 s!
CPU:
model name : Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz
编译器:
$ g++ --version
g++ (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
【 在 finlab 的大作中提到: 】
: 还有, 我在vc中设了 /fp:fast 选项,但是好像效果不明显,您也可以试下。
: 这个选项对应numba的fastmath=True
--
修改:haha103 FROM 182.150.115.*
FROM 182.150.115.*