Hi! On 2025-04-25T10:33:39+0000, Andrew Stubbs <a...@baylibre.com> wrote: > --- /dev/null > +++ b/libgomp/testsuite/libgomp.c/interop-hsa.c > @@ -0,0 +1,203 @@ > +/* { dg-additional-options "-ldl" } */ > +/* { dg-require-effective-target offload_device_gcn } */
This means that a GCN offloading device must be available (and, implicitly, GCN offloading compilation must be available), but doesn't make sure that only GCN offloading compilation is attempted. But then: > +/* This code fragment must be optimized or else the host-fallback kernel has > + * invalid ASM inserts. The rest of the file can be compiled safely at -O0. > */ > +#pragma omp declare target > +uintptr_t __attribute__((optimize("O1"))) > +get_kernel_ptr () > +{ > + uintptr_t val; > + if (!omp_is_initial_device ()) > + /* "main._omp_fn.0" is the name GCC gives the first OpenMP target > + * region in the "main" function. > + * The ".kd" suffix is added by the LLVM assembler when it creates the > + * kernel meta-data, and this is what we need to launch a kernel. */ > + asm ("s_getpc_b64 %0\n\t" > + "s_add_u32 %L0, %L0, main._omp_fn.0.kd@rel32@lo+4\n\t" > + "s_addc_u32 %H0, %H0, main._omp_fn.0.kd@rel32@hi+4" > + : "=Sg"(val)); > + return val; > +} > +#pragma omp end declare target ... this code isn't valid for anything but GCN offloading compilation (and host compilation, via dead code elimination). We could do some OpenMP 'declare variant' thing, I suppose, but as that whole test case really is applicable to GCN offloading only, I've pushed to trunk branch commit 85ad0d84fcec720c1d94b9bda9a617ced70ba5d2 "'libgomp.c/interop-hsa.c': GCN offloading only", see attached. Grüße Thomas
>From 85ad0d84fcec720c1d94b9bda9a617ced70ba5d2 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tschwi...@baylibre.com> Date: Mon, 5 May 2025 10:19:30 +0200 Subject: [PATCH] 'libgomp.c/interop-hsa.c': GCN offloading only Fix-up for commit 8d84ea28510054fbbb8a2b7441916bd75e29163f "OpenMP, GCN: Add interop-hsa testcase", which added 'libgomp.c/interop-hsa.c'. If nvptx offloading compilation is enabled in addition to GCN, the former ICEs: during RTL pass: final [...]/libgomp.c/interop-hsa.c: In function 'get_kernel_ptr': [...]/libgomp.c/interop-hsa.c:34:1: internal compiler error: RTL check: expected code 'subreg', have 'reg' in nvptx_print_operand, at config/nvptx/nvptx.cc:3082 0x1ccdb96 internal_error(char const*, ...) [...]/gcc/diagnostic-global-context.cc:517 0x7446c3 rtl_check_failed_code1(rtx_def const*, rtx_code, char const*, int, char const*) [...]/gcc/rtl.cc:770 0x7fa533 nvptx_print_operand [...]/gcc/config/nvptx/nvptx.cc:3082 0xb25f34 output_operand(rtx_def*, int) [...]/gcc/final.cc:3641 0xb26f07 output_asm_insn(char const*, rtx_def**) [...]/gcc/final.cc:3534 0xb29d91 output_asm_insn(char const*, rtx_def**) [...]/gcc/final.cc:2639 0xb29d91 final_scan_insn_1 [...]/gcc/final.cc:2642 0xb2a59f final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*) [...]/gcc/final.cc:2892 0xb2a68c final_1 [...]/gcc/final.cc:1983 0xb2b378 rest_of_handle_final [...]/gcc/final.cc:4250 0xb2b378 execute [...]/gcc/final.cc:4328 Regardless of the issue that nvptx offloading compilation probably shouldn't ICE, the 'asm' insert clearly is valid for GCN only. libgomp/ * testsuite/libgomp.c/interop-hsa.c: GCN offloading only. --- libgomp/testsuite/libgomp.c/interop-hsa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libgomp/testsuite/libgomp.c/interop-hsa.c b/libgomp/testsuite/libgomp.c/interop-hsa.c index cf8bc90bb9c..21ac91c1b58 100644 --- a/libgomp/testsuite/libgomp.c/interop-hsa.c +++ b/libgomp/testsuite/libgomp.c/interop-hsa.c @@ -1,5 +1,7 @@ /* { dg-additional-options "-ldl" } */ -/* { dg-require-effective-target offload_device_gcn } */ +/* { dg-require-effective-target offload_device_gcn } + The 'asm' insert is valid for GCN only: + { dg-additional-options -foffload=amdgcn-amdhsa } */ #include <stdio.h> #include <stdlib.h> -- 2.34.1