Issue 140748
Summary [XRay] XRay flag cannot be used when offload (e.g. OpenMP target) is used
Labels new issue
Assignees
Reporter Thyre
    This issue is generally similar to https://github.com/llvm/llvm-project/issues/59799.

---

While looking into XRay support for [Score-P](https://www.vi-hps.org/projects/score-p), we stumbled upon a small, but significant, issue when trying to use XRay for OpenMP target programs.

Given the following program:

```c
#include <omp.h>
#include <stdio.h>

int main( void )
{
    int code_ran_on_gpu = 0;
    #pragma omp target map(from: code_ran_on_gpu)
    {
 code_ran_on_gpu = omp_is_initial_device();
    }
    printf("Hello World from GPU? %s\n", code_ran_on_gpu ? "no" : "yes");
    return 0;
}
```

One can build and run the program as expected:

```console
$ clang --version
clang version 21.0.0git (https://github.com/llvm/llvm-project.git a04cff172f31aaa8c5932cf1b204c161b95b1b0a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/apps/software/Clang/trunk/bin
Build config: +assertions
$ clang -fopenmp --offload-arch=gfx1101 --rocm-path=/opt/apps/software/ROCm/6.4.0 hello-world.c
$ OMP_TARGET_OFFLOAD=mandatory ./a.out
Hello World from GPU? yes
```

Trying to use `-fxray-instrument` however causes issues:

```console
$ clang -fxray-instrument -fopenmp --offload-arch=gfx1101 --rocm-path=/opt/apps/software/ROCm/6.4.0 hello-world.c
clang: error: unsupported option '-fxray-instrument' for target 'amdgcn-amd-amdhsa'
```

`-Xarch_host` only helps partially. We are able to build the program, but the sleds are missing. This is also the case without `--offload-arch`:

```console
$ clang -Xarch_host -fxray-instrument -Xarch_host -fxray-instruction-threshold=1 -fopenmp --offload-arch=gfx1101 --rocm-path=/opt/apps/software/ROCm/6.4.0 hello-world.c
$ XRAY_OPTIONS="patch_premain=false verbosity=1 xray_naive_log=false xray_logfile_base=custom-event-logging.xray-" ./a.out
Hello World from GPU? yes
$ objdump -h ./a.out 2>&1 | grep xray || echo "Not found" 
Not found
```

This unfortunately significantly reduces the functionality. Having XRay work with `-Xarch_host` would be ideal, as I fully understand why it doesn't work on offload architectures.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to