mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 13:19:18 -08:00
…onization (Repush of https://github.com/llvm/llvm-project/pull/223730 updated private.h to still print synchronization line even if debug info is not available, before if it wasent the line was skipped causing the force-usm test to fail.) This PR improves `LIBOMPTARGET_INFO` diagnostics so data-transfer and synchronization messages carry a source location, and so runtime-internal transfers show a meaningful name instead of `unknown`. ### Changes - Thread the region's source location (`ident_t *Loc`) through the submit/retrieve/copy-info paths and append `, at <file>:<line>:<col>` to "Copying data…" messages (emitting nothing when no location is available, avoiding `unknown:0:0`). - Emit a new `Waiting for asynchronous operations to complete` message, with source location, before the runtime synchronizes. - Add an optional name for runtime-internal transfers so they report `DeviceEnvironment` / `IndirectCallTable` instead of `unknown`. ### Effect Given a simple `target map(tofrom: value)` region: ``` fortran program omp_target_map_test implicit none integer :: value value = 0 !$omp target map(tofrom: value) value = 1 !$omp end target print *, value if (value /= 1) then stop 1 end if end program omp_target_map_test ``` ``` bash Copying data from host to device, ... Name=DeviceEnvironment Copying data from host to device, ... Name=value, at test.f90:7:7 Copying data from device to host, ... Name=value, at test.f90:7:7 Waiting for asynchronous operations to complete at test.f90:7:7 ``` The `, at test.f90:7:7` suffixes only appear when [llvm/llvm-project#222389](https://github.com/llvm/llvm-project/pull/222389) is also present — that change supplies the source-location argument from the front end into the runtime. Without it, the transfers still print (and internal transfers are still named), just without the location suffix. ### Tests Updated `offload/test/offloading/info.c` and `offload/test/offloading/force-usm.cpp` to check the location suffix, the new synchronization message, and the named internal transfer. I did not create an RFC for these changes as my original goal was to simply fix / remove the unknown file line info in the debug outputs, but If desired I can create one for this PR for the expanded functionality that this change presents Assisted-by: Opus 4.8
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
// clang-format off
|
|
// RUN: %libomptarget-compilexx-generic
|
|
// RUN: env LIBOMPTARGET_INFO=32 %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=NO-USM
|
|
//
|
|
// RUN: %libomptarget-compilexxx-generic-force-usm
|
|
// RUN: env HSA_XNACK=1 LIBOMPTARGET_INFO=32 \
|
|
// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic --check-prefix=FORCE-USM
|
|
//
|
|
// REQUIRES: unified_shared_memory
|
|
//
|
|
// UNSUPPORTED: nvptx64-nvidia-cuda
|
|
// UNSUPPORTED: nvptx64-nvidia-cuda-LTO
|
|
// UNSUPPORTED: intelgpu
|
|
// clang-format on
|
|
|
|
#include <cassert>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
|
|
int GI;
|
|
#pragma omp declare target
|
|
int *pGI;
|
|
#pragma omp end declare target
|
|
|
|
int main(void) {
|
|
|
|
GI = 0;
|
|
// Implicit mappings
|
|
int alpha = 1;
|
|
int beta[3] = {2, 5, 8};
|
|
|
|
// Require map clauses for non-USM execution
|
|
pGI = (int *)malloc(sizeof(int));
|
|
*pGI = 42;
|
|
|
|
#pragma omp target map(pGI[ : 1], GI)
|
|
{
|
|
GI = 1 * alpha;
|
|
*pGI = 2 * beta[1];
|
|
}
|
|
|
|
assert(GI == 1);
|
|
assert(*pGI == 10);
|
|
|
|
printf("SUCCESS\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
// clang-format off
|
|
// NO-USM: device 0 info: Copying data from host to device, HstPtr={{.*}}, TgtPtr={{.*}}, Size=4
|
|
// NO-USM: device 0 info: Copying data from host to device, HstPtr={{.*}}, TgtPtr={{.*}}, Size=12
|
|
// NO-USM-NEXT: device 0 info: Copying data from host to device, HstPtr={{.*}}, TgtPtr={{.*}}, Size=4
|
|
// NO-USM-NEXT: device 0 info: Copying data from host to device, HstPtr={{.*}}, TgtPtr={{.*}}, Size=8, Name=pGI
|
|
// NO-USM-NEXT: device 0 info: Copying data from device to host, TgtPtr={{.*}}, HstPtr={{.*}}, Size=4
|
|
// NO-USM-NEXT: device 0 info: Copying data from device to host, TgtPtr={{.*}}, HstPtr={{.*}}, Size=12
|
|
// NO-USM-NEXT: device 0 info: Copying data from device to host, TgtPtr={{.*}}, HstPtr={{.*}}, Size=4
|
|
// NO-USM-NEXT: device 0 info: Waiting for asynchronous operations to complete
|
|
// NO-USM-NEXT: SUCCESS
|
|
|
|
// FORCE-USM: SUCCESS
|
|
//
|
|
// clang-format on
|