Files
openmp/runtime/test/api/omp_get_num_devices.c
Jonathan Peyton a999c520ac [OpenMP] Add omp_get_device_num() and update several other device API functions
Add omp_get_device_num() function for 5.0 which returns the number of the
device the current thread is running on. Currently, we are leaving it to the
compiler to handle this properly if it is called inside target.

Also, did some cleanup and updating of duplicate device API functions (in both
libomp and libomptarget) to make them into weak functions that check for the
symbol from libomptarget, and will call the version in libomptarget if it is
present. If any additional device API functions are implemented also in
libomptarget in the future, we should add the dlsym calls to the host functions.
Also, if the omp_target_* functions are to be implemented for the host (this has
been requested), they should attempt to call the libomptarget versions as well.

Patch by Terry Wilmarth

Differential Revision: https://reviews.llvm.org/D55578


git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@350352 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-03 21:14:19 +00:00

25 lines
398 B
C

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