Merge "Add more openmp tests"
diff --git a/tests/device/test-openmp/jni/Android.mk b/tests/device/test-openmp/jni/Android.mk
index ed7f548..96e24b4 100644
--- a/tests/device/test-openmp/jni/Android.mk
+++ b/tests/device/test-openmp/jni/Android.mk
@@ -7,3 +7,17 @@
 LOCAL_LDFLAGS += -fopenmp
 include $(BUILD_EXECUTABLE)
 
+include $(CLEAR_VARS)
+LOCAL_MODULE := openmp2
+LOCAL_SRC_FILES := openmp2.c
+LOCAL_CFLAGS += -fopenmp
+LOCAL_LDFLAGS += -fopenmp
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := fib
+LOCAL_SRC_FILES := fib.c
+LOCAL_CFLAGS += -fopenmp
+LOCAL_LDFLAGS += -fopenmp
+include $(BUILD_EXECUTABLE)
+
diff --git a/tests/device/test-openmp/jni/fib.c b/tests/device/test-openmp/jni/fib.c
new file mode 100644
index 0000000..c2ec2e9
--- /dev/null
+++ b/tests/device/test-openmp/jni/fib.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <omp.h>
+#include <unistd.h>
+#define MAX 33 //41
+int Fibonacci(int n)
+{   int x, y;
+    if (n < 2)
+        return n;
+    else {
+        x = Fibonacci(n - 1);
+        y = Fibonacci(n - 2);
+        return (x + y);
+}    }
+int FibonacciTask(int n)
+{   int x, y;
+    if (n < 2)
+        return n;
+    else {
+#pragma omp task shared(x)
+        x = Fibonacci(n - 1);
+#pragma omp task shared(y)
+        y = Fibonacci(n - 2);
+#pragma omp taskwait
+        return (x + y);
+ }    }
+
+int main(int argc, char * argv[])
+{int FibNumber[MAX] = {0};
+  struct timeval time_start, time_end;
+  int i = 0;
+  // openmp related print message
+  printf("CPU_ONLN= %d\n", sysconf(_SC_NPROCESSORS_ONLN));
+  printf("Number of CPUs=%d\n", omp_get_num_procs());
+  printf("Number of max threads=%d\n", omp_get_max_threads());
+  printf("Number of executing thread=%d\n", omp_get_thread_num());
+  printf("Number of threads=%d\n", omp_get_num_threads());
+  omp_set_num_threads( omp_get_num_procs()  );
+  gettimeofday(&time_start, NULL);
+#pragma omp parallel
+    {
+#pragma omp single private(i)
+        for(i = 1; i < MAX; i++) {
+            FibNumber[i] = FibonacciTask(i);
+    }    }
+   gettimeofday(&time_end, NULL);
+   time_end.tv_usec = time_end.tv_usec-time_start.tv_usec;
+   time_end.tv_sec = time_end.tv_sec-time_start.tv_sec;
+   time_end.tv_usec += (time_end.tv_sec*1000000);
+   printf("Time of Fibonacci with OpenMP : %lf sec\n",      time_end.tv_usec / 1000000.0);
+   for(i = 0; i < MAX; i++)
+       printf("%d ", FibNumber[i]);
+   printf("\n-------------------------------\n");
+   return 0;
+}
diff --git a/tests/device/test-openmp/jni/openmp2.c b/tests/device/test-openmp/jni/openmp2.c
new file mode 100644
index 0000000..c1788ce
--- /dev/null
+++ b/tests/device/test-openmp/jni/openmp2.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <omp.h>
+#include <sys/sysconf.h>
+
+int main (int argc, char *argv[])
+{
+    int nthreads, tid;
+    printf("SC_NPROCESSORS_ONLN: %d\n", sysconf (_SC_NPROCESSORS_ONLN));
+  #pragma omp parallel default(shared) private(nthreads, tid)
+    /* Fork a team of threads giving them their own copies of variables */
+    {
+      /* Obtain thread number */
+        tid = omp_get_thread_num();
+        printf("Hello World from thread = %d\n", tid);
+      /* Only master thread does this */
+        if (tid == 0)
+        {
+            nthreads = omp_get_num_threads();
+            printf("Number of threads = %d\n", nthreads);
+        }
+    }  /* All threads join master thread and disband */
+
+  return 0;
+}