Created
June 24, 2016 07:03
-
-
Save matt-42/30b7caf73c345c28e55b7cfd82f5540c to your computer and use it in GitHub Desktop.
Minimal Android OpenMP Benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Results one OnePlus two (snapdragon 810 - 8 cores ARMv8): | |
// with optimization -fopenmp -Ofast -mcpu=cortex-a57.cortex-a53 | |
// Serial time: 19.480000 ms | |
// OpenMP time: 10.000000 ms | |
{ | |
const int S = 10e6; | |
auto A = new int[S]; | |
auto B = new int[S]; | |
timer timer; | |
const int K = 100; | |
timer.start(); | |
for (int k = 0; k < K; k++) | |
for (int i = 0; i < S; i++) | |
A[i] = A[i] + B[i]; | |
timer.end(); | |
__android_log_print(ANDROID_LOG_INFO, "bench", "Serial time %f ms", float(timer.ms()) / K); | |
timer.start(); | |
omp_set_num_threads(4); | |
for (int k = 0; k < K; k++) | |
#pragma omp parallel for simd | |
for (int i = 0; i < S; i++) | |
A[i] = A[i] + B[i]; | |
timer.end(); | |
__android_log_print(ANDROID_LOG_INFO, "bench", "OpenMP time %f ms", float(timer.ms()) / K); | |
} |
I think that today this benchmark is a outdated. Compilers have evolved and processors too.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
4 threads/cores for 2X speedup only?
Doesn't that imply twice overhead introduced by OpenMP?