llvm-project/openmp/libomptarget/test/api/omp_get_device_num.c
Jose M Monsalve Diaz 616dd9ae14 [OpenMP] Implementing omp_get_device_num()
This patch implements omp_get_device_num() in the host and the device.

It uses the already existing getDeviceNum in the device config for the device.
And in the host it uses the omp_get_num_devices().

Two simple tests added

Differential Revision: https://reviews.llvm.org/D128347
2022-06-29 02:18:21 -05:00

34 lines
556 B
C

// RUN: %libomptarget-compile-run-and-check-generic
#include <stdio.h>
#include <omp.h>
int test_omp_get_device_num()
{
/* checks that omp_get_device_num() == omp_get_num_devices() in the host */
int device_num = omp_get_device_num();
printf("device_num = %d\n", device_num);
#pragma omp target
{}
return (device_num == omp_get_num_devices());
}
int main()
{
int i;
int failed=0;
if (!test_omp_get_device_num()) {
failed++;
}
if (failed)
printf("FAIL\n");
else
printf("PASS\n");
return failed;
}
// CHECK: PASS