Open
Description
spec 6.0 says
Support for the disabled value is implementation defined. If an implementation supports it, the behavior is as if the only device is the host device.
Based on the above spec, when the environment variable OMP_TARGET_OFFLOAD=disabled
is set, the expected return from omp_get_default_device
should agree with omp_get_initial_device
which reports the host device. This is not the current case
reproducer.cpp
#include <omp.h>
#include <iostream>
int main(){
std::cout << "num_of_device = " << omp_get_num_devices() << std::endl;
std::cout << "initial_device = " << omp_get_initial_device() << std::endl;
std::cout << "default_device = " << omp_get_default_device() << std::endl;
int a[8];
#pragma omp target enter data map(to: a[:8])
int* b = (int *)omp_get_mapped_ptr(a, omp_get_default_device());
std::cout << "a_ptr = " << a << " b_ptr = " << b << std::endl;
}
compile and run
yeluo@epyc-server:~/temp$ clang++ -fopenmp --offload-arch=gfx906 main.cpp
yeluo@epyc-server:~/temp$ OMP_TARGET_OFFLOAD=disabled ./a.out
num_of_device = 1
initial_device = 1
default_device = 0
a_ptr = 0x7ffdd63e4440 b_ptr = 0
yeluo@epyc-server:~/temp$ OMP_TARGET_OFFLOAD=mandatory ./a.out
num_of_device = 1
initial_device = 1
default_device = 0
a_ptr = 0x7fff3355e020 b_ptr = 0x721958200000
default_device doesn't behave as expected.