我在计算机上进行实验时遇到问题。我已经完成了300个并行算法(32个线程)的测试,发现大约10%的测试的运行时间少于其他测试。看起来是这样的:我们有100个测试,每个运行时约100毫秒,然后我们有30个测试,运行时约80毫秒,再有170个测试,运行时约100毫秒。每次实验都会发生。我使用了OpenMP,TBB,PTHREAD,std :: Thread,并且每种并行技术都会发生这种情况。是什么原因呢?
CPU:英特尔®酷睿™i7 Kaby Lake H 2800-3800 MHz内核:4个线程:8
此外,我已经在另一台计算机(Intel®Core™m3-6Y30)上进行了测试,但是到期没有这种问题。
我无法显示我的实验情节(信誉欠佳),但是其中一部分以文本格式显示:
841618
846348
859046
847833
841801
847680
849084
... (about 115 tests with avg ~840000-860000 ms)
784754
784754
759525
... (about 40 tests with avg ~750000-790000 ms)
855215
846631
850249
847015
...(about 120 tests with avg ~840000-860000 ms)
778716
765774
...(about 30 tests with avg ~750000-780000 ms)
等
我还记录了计算机参数,例如CPU温度和功率,并看到了相同的结果。所以我不知道为什么参数会以这种方式运行。 有代码,我在其中测量了实验时间(使用了std :: chrono):
std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
std::size_t total;
start = std::chrono::high_resolution_clock::now();
std::complex<double> * X = DirectTransform(compl_val);
end = std::chrono::high_resolution_clock::now();
total = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
编译脚本就在其中:
g++ ./fourier/main.cpp -o ./build/fourier.out
g++ -pthread ./fourier-h/main.cpp -o ./build/fourier-std.out
g++ -fopenmp ./fourier-omp/main.cpp -o ./build/fourier-omp.out
g++ -ltbb ./fourier-tbb/main.cpp -o ./build/fourier-tbb.out
g++ -pthread ./fourier-pth/main.cpp -o ./build/fourier-pth.out
硬件概述: