llvm-project/openmp/runtime/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

28 lines
465 B
C

// RUN: %libomp-compile-and-run
// Linking fails for icc 18
// UNSUPPORTED: icc-18
#include <stdio.h>
#include "omp_testsuite.h"
int test_omp_get_device_num()
{
/* checks that omp_get_device_num */
int device_num = omp_get_device_num();
return (device_num == omp_get_num_devices());
}
int main()
{
int i;
int num_failed=0;
for(i = 0; i < REPETITIONS; i++) {
if(!test_omp_get_device_num()) {
num_failed++;
}
}
return num_failed;
}