Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
}
@ghost

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.