Skip to content

Instantly share code, notes, and snippets.

@matt-42
Created June 24, 2016 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matt-42/30b7caf73c345c28e55b7cfd82f5540c to your computer and use it in GitHub Desktop.
Save matt-42/30b7caf73c345c28e55b7cfd82f5540c to your computer and use it in GitHub Desktop.
Minimal Android OpenMP Benchmark
// 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);
}
Copy link

ghost commented May 12, 2017

works nice but i didn't find what is timer so i used omp_get_wtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment