[Openmp-commits] [PATCH] D159119: [OpenMP] Enable optimization level for memory_manager.cpp OpenMP test.

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Aug 31 09:36:02 PDT 2023


tianshilei1992 added a comment.

In D159119#4631612 <https://reviews.llvm.org/D159119#4631612>, @protze.joachim wrote:

> In D159119#4631583 <https://reviews.llvm.org/D159119#4631583>, @tianshilei1992 wrote:
>
>> I don’t think that is the cause of the issue. The default device is 0, at least for OpenMP.
>
> The default device is not 0. At least not according to the OpenMP spec. Check OpenMP-5.2, page 41, lines 10-13:
>
>> If target-offload-var is mandatory and the number of non-host devices is zero then the default-device-var is initialized to **omp_invalid_device**. Otherwise, **the initial value is an implementation-defined non-negative integer** that is less than or, if target-offload-var is not mandatory, equal to omp_get_initial_device().
>
> I didn't claim, that this caused the issue. I just noted that according to the OpenMP spec, the test was sailing in implementation-defined waters.
>
> Thanks Doru for fixing the test :D

I meant to say "for LLVM OpenMP" but somehow missed the "LLVM". ;-)

On paper you are right. In practice, for LLVM OpenMP, `omp_get_default_device` returns 0 *by default*. This still holds for the case we are discussing here because:

- Our test config doesn't change the value via env.
- For each test we require the corresponding "test feature", and also only compile for the corresponding target.

All of this can guarantee that device 0 used for API corresponds to the default device for target region. I think that is also the reason that almost all libomptarget tests don't explicitly specify device number on the target construct.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159119/new/

https://reviews.llvm.org/D159119



More information about the Openmp-commits mailing list