Skip to content

Commit 42d183e

Browse files
motokultivatorspatrang
authored andcommitted
Skip unsupported tests in case of optimized code
For tests whose semantics cannot be reconciled with optimised code, gate them so they UNSUPPORTED-out cleanly instead of failing. - "require no_optimized_code" at the top of: aspace-user- input, aspace-watchpoint, convenience_variables, device- barrier, finish, fork-exec-non-gpu-to-gpu, lane-execution, mi-aspace, mi-lanes, nonstop-displaced, precise-memory- warning-watchpoint, register-watchpoint, runtime-core, shared-memory. - "require no_lto" at the top of: hip-builtin-variables, hip-lang-detect, mi-aspace, watchpoint-at-end-of-shader. - watchpoint-basic.exp: proc-level skip of test_non_write_watchpoint_before_runtime_load's rwatch/ awatch sub-cases under optimisation. The HIP runtime is initialised before main() reaches "Break before runtime load", so amd-dbgapi is already attached and rejects the host-side read/access watchpoint at insert time. Only this sub-test depends on the "before runtime load" premise; the other procs still work under optimisation, so use a proc-level check_for_any_flags skip rather than a file-level "require no_optimized_code". Co-Authored-By: Andrey Kasaurov <andrey.kasaurov@amd.com> Co-Authored-By: Luis Machado <luis.machado@amd.com> Change-Id: I750d64e842413429e281bb8f7d85c4f46319a627 Signed-off-by: Sarang Patrange <spatrang@amd.com>
1 parent 2afff59 commit 42d183e

36 files changed

Lines changed: 128 additions & 76 deletions

gdb/testsuite/gdb.rocm/alu-exceptions.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@
2121
#include <limits>
2222
#include <cstdlib>
2323

24-
__device__ void
24+
/* The debugger sets a breakpoint on this function and uses an inferior
25+
call to enable ALU exceptions before each kernel launches. We need:
26+
- noinline, so the breakpoint reliably fires at each call site, and
27+
- an observable side effect the optimiser cannot prove away,
28+
otherwise IPO removes every call (the function would appear pure)
29+
and then dead-strips the now-uncalled function.
30+
An empty volatile asm with a memory clobber is the cheapest way to
31+
give the function an effect the compiler must preserve, and codegens
32+
to nothing on amdgcn. */
33+
34+
__device__ __attribute__ ((noinline)) void
2535
enable_alu_exceptions ()
2636
{
27-
/* By default, ALU exceptions are not enabled. Break here and use the
28-
debugger to enable exceptions. */
29-
volatile int i = 0;
37+
asm volatile ("" ::: "memory");
3038
}
3139

3240
__global__ void

gdb/testsuite/gdb.rocm/aspace-user-input.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
load_lib rocm.exp
2323

2424
require allow_hipcc_tests
25+
require no_optimized_code
2526

2627
standard_testfile bit-extract.cpp
2728

gdb/testsuite/gdb.rocm/aspace-watchpoint.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
load_lib rocm.exp
2626

2727
require allow_hipcc_tests
28+
require no_optimized_code
2829

2930
standard_testfile .cpp
3031

gdb/testsuite/gdb.rocm/convenience_variables.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
load_lib rocm.exp
2323

2424
require allow_hipcc_tests
25+
require no_optimized_code
2526

2627
standard_testfile .cpp
2728

gdb/testsuite/gdb.rocm/corefile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
} \
3434
} while (0)
3535

36-
__device__ int
37-
bar () __attribute__((optnone))
36+
__device__ int __attribute__((optnone))
37+
bar ()
3838
{
3939
return threadIdx.x;
4040
}

gdb/testsuite/gdb.rocm/deep-stack.exp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ with_rocm_gpu_lock {
4747
gdb_test "continue" "Thread $decimal \"hip_deep\" hit Breakpoint $decimal.*"
4848
gdb_test "backtrace" \
4949
[multi_line \
50-
"#0 .* base_case .*" \
51-
"#1 .* deep<0u> .*" \
52-
"#2 .* deep<1u> .*" \
53-
"#3 .* deep<2u> .*" \
54-
"#4 .* deep<3u> .*" \
55-
"#5 .* deep<4u> .*" \
56-
"#6 .* deep<5u> .*" \
57-
"#7 .* deep<6u> .*" \
58-
"#8 .* deep<7u> .*" \
59-
"#9 .* deep<8u> .*" \
60-
"#10 .*deep<9u> .*" \
61-
"#11 .*deep<10u> .*" \
62-
"#12 .*hip_deep .*"]
50+
"#0 +((0x.* in )?base_case) .*" \
51+
"#1 +((0x.* in )?deep<0u>) .*" \
52+
"#2 +((0x.* in )?deep<1u>) .*" \
53+
"#3 +((0x.* in )?deep<2u>) .*" \
54+
"#4 +((0x.* in )?deep<3u>) .*" \
55+
"#5 +((0x.* in )?deep<4u>) .*" \
56+
"#6 +((0x.* in )?deep<5u>) .*" \
57+
"#7 +((0x.* in )?deep<6u>) .*" \
58+
"#8 +((0x.* in )?deep<7u>) .*" \
59+
"#9 +((0x.* in )?deep<8u>) .*" \
60+
"#10 +((0x.* in )?deep<9u>) .*" \
61+
"#11 +((0x.* in )?deep<10u>) .*" \
62+
"#12 +((0x.* in )?hip_deep) .*"]
6363
}

gdb/testsuite/gdb.rocm/deref-scoped-pointer.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,12 @@
3232
} \
3333
}
3434

35-
/* Non-static + noinline so a line-breakpoint at the "done ()" call
36-
site below has a stable instruction address under -O1/-O2/-O3.
37-
Without these, the empty body is inlined into its caller, so
38-
there is no instruction at the call-site line for GDB to insert
39-
the breakpoint at. */
35+
/* Non-static so a line breakpoint at the "done ()" call site below
36+
has a stable address at -O0. */
4037

41-
__device__ void __attribute__((noinline))
38+
__device__ void
4239
done ()
4340
{
44-
asm volatile ("" : : : "memory");
4541
}
4642

4743
/* This is initialized by the kernel function below. */
@@ -50,16 +46,10 @@ __device__ size_t *global_ptr = nullptr;
5046
/* This is initialized by GDB. */
5147
__device__ size_t *global_ptr2 = nullptr;
5248

53-
/* kernel() is marked __attribute__((optnone)) and "local_var" is
54-
declared "volatile" so the variable remains addressable from the
55-
"done" call site through the end of the function under
56-
-O1/-O2/-O3. The test takes the address of local_var via GDB
57-
expressions, which requires it to have an lvalue/storage. */
58-
59-
__global__ void __attribute__((optnone))
49+
__global__ void
6050
kernel ()
6151
{
62-
volatile size_t local_var = blockIdx.x * blockDim.x + threadIdx.x;
52+
size_t local_var = blockIdx.x * blockDim.x + threadIdx.x;
6353

6454
/* This will be zero for the first HIP thread, or lane. */
6555
if (local_var == 0)

gdb/testsuite/gdb.rocm/deref-scoped-pointer.exp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ load_lib rocm.exp
2828

2929
require allow_hipcc_tests
3030

31+
# At -O1+ the HIP compiler drops the DWARF name->location mapping for
32+
# kernel locals (e.g. "local_var") at arbitrary line breakpoints, even
33+
# when their address is escaped and the storage is kept live, so GDB
34+
# reports them as <optimized out>. This test relies on resolving
35+
# "local_var" symbolically at the "set breakpoint here" location, so
36+
# restrict it to non-optimised builds until the toolchain improves
37+
# debug info for HIP kernels under optimisation.
38+
require no_optimized_code
39+
3140
standard_testfile .cpp
3241

3342
if {[build_executable "failed to prepare" $testfile $srcfile {debug hip}]} {

gdb/testsuite/gdb.rocm/device-barrier.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
load_lib rocm.exp
2121

2222
require allow_hipcc_tests
23+
require no_optimized_code
2324

2425
standard_testfile .cpp
2526

gdb/testsuite/gdb.rocm/finish.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
load_lib rocm.exp
2424

2525
require allow_hipcc_tests
26+
require no_optimized_code
2627

2728
standard_testfile .cpp
2829

0 commit comments

Comments
 (0)