AMDGPU provides a fixed frequency clock since some generations back. However, the frequency is variable by card and must be looked up at runtime. This patch adds a new device environment line for the clock frequency so that we can use it in the same way as NVPTX. This is the correct implementation and the version in ASO should be replaced. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D154456
26 lines
540 B
C
26 lines
540 B
C
// RUN: %libomptarget-compileopt-and-run-generic
|
|
|
|
#include <assert.h>
|
|
#include <omp.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define N (1024 * 1024 * 256)
|
|
|
|
int main(int argc, char *argv[]) {
|
|
int *data = (int *)malloc(N * sizeof(int));
|
|
double duration = 0.0;
|
|
|
|
#pragma omp target map(from : data[0 : N]) map(from : duration)
|
|
{
|
|
double start = omp_get_wtime();
|
|
for (int i = 0; i < N; ++i)
|
|
data[i] = i;
|
|
double end = omp_get_wtime();
|
|
duration = end - start;
|
|
}
|
|
assert(duration > 0.0);
|
|
free(data);
|
|
return 0;
|
|
}
|