-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
ye-luo commentedon Jun 30, 2025
021a1f6 already took care of this issue. I'm going to submit a test to safe guard working cases.
[libomptarget] Add a test for OMP_TARGET_OFFLOAD=disabled (#146385)
llvmbot commentedon Jun 30, 2025
@llvm/issue-subscribers-offload
Author: Ye Luo (ye-luo)
Based on the above spec, when the environment variable
OMP_TARGET_OFFLOAD=disabled
is set, the expected return fromomp_get_default_device
should agree withomp_get_initial_device
which reports the host device. This is not the current casereproducer.cpp
compile and run
default_device doesn't behave as expected.
Automerge: [libomptarget] Add a test for OMP_TARGET_OFFLOAD=disabled …