xref: /llvm-project/offload/test/offloading/wtime.c (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compileopt-and-run-generic
2 
3 // UNSUPPORTED: amdgcn-amd-amdhsa
4 
5 #include <assert.h>
6 #include <omp.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 
10 #define N (1024 * 1024 * 256)
11 
main(int argc,char * argv[])12 int main(int argc, char *argv[]) {
13   int *data = (int *)malloc(N * sizeof(int));
14   double duration = 0.0;
15 
16 #pragma omp target map(from : data[0 : N]) map(from : duration)
17   {
18     double start = omp_get_wtime();
19     for (int i = 0; i < N; ++i)
20       data[i] = i;
21     double end = omp_get_wtime();
22     duration = end - start;
23   }
24   assert(duration > 0.0);
25   free(data);
26   return 0;
27 }
28