Files
TheRock/debug-tools/rocgdb/source/gdb/testsuite/gdb.rocm/shared-memory.exp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

127 lines
4.0 KiB
Plaintext

# Copyright 2024 Free Software Foundation, Inc.
# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test that when a program allocates shared memory, the content of the
# memory is not lost when reaching a breakpoint.
load_lib rocm.exp
# Python support is required to use $_streq.
require allow_hip_tests allow_python_tests
# The debug behavior this test checks (inspecting device locals
# and/or single-stepping) is not reliable on optimized device
# code, so skip it for optimized builds.
require no_optimized_code
standard_testfile .cpp -size.cpp
proc get_shared_size {} {
if {[build_executable "failed to prepare" $::testfile $::srcfile2 {debug hip}]} {
return
}
clean_restart $::binfile
set bploc [gdb_get_line_number "Break here\." $::srcfile2]
with_rocm_gpu_lock {
if {![runto "$bploc" {message "runto end"}]} {
return 0
}
set shared_size [get_valueof "" "props.sharedMemPerBlock" "0"]
return $shared_size
}
}
proc do_test {shared_size nonstop} {
if {[build_executable "failed to prepare" $::testfile $::srcfile \
[list debug hip additional_flags=-DSHARED_SIZE=$shared_size]]} {
return
}
save_vars { ::GDBFLAGS } {
if { $nonstop } {
append ::GDBFLAGS " -ex \"set non-stop on\""
}
clean_restart $::binfile
}
with_rocm_gpu_lock {
if ![runto_main] {
return
}
set bploc [gdb_get_line_number "Break here\."]
# We want to stop one thread of the work-group with X coordinate 23
# (this is arbitrary, one value had to be picked). We cannot know a
# priori how many waves make a work-group, but there must be at least
# 2, so we can look for the wave which has $_dispatch_pos equal to
# "(23,0,0)/1".
# Other work-groups can run freely (but still need to report the
# breakpoint). Other threads in the work-group can also run freely.
gdb_breakpoint "$bploc if \$_streq(\$_dispatch_pos, \"(23,0,0)/1\")" \
allow-pending
set thread_num 0
gdb_test_multiple "continue" "continue to breakpoint" {
-re "Thread ($::decimal) .* hit Breakpoint" {
set thread_num $expect_out(1,string)
exp_continue
}
-re "$::gdb_prompt " {
gdb_assert { $thread_num != 0} $gdb_test_name
}
}
if { $nonstop } {
gdb_test "thread $thread_num" ".*Switching to thread.*" \
"select thread"
}
# Check values inside shared memory. Those are set by the "generator"
# lambda in the device code.
gdb_test "p/x shared_buffer\[0\]" "= 0xdeadbeef"
gdb_test "p/x shared_buffer\[1\]" "= 0x17"
gdb_test "p/x shared_buffer\[2\]" "= 0x0"
gdb_test "p/x shared_buffer\[3\]" "= 0x0"
gdb_test "p/x shared_buffer\[4\]" "= 0xaaaaaaaa"
gdb_test "p/x shared_buffer\[shared_buffer_size / 2\]" "= 0xbadf00d"
gdb_test "p/x shared_buffer\[shared_buffer_size - 1\]" "= 0x123abcd"
# Keep the written values in sync with shared-memory.cpp.
gdb_test "p/x shared_buffer\[shared_buffer_size / 2\] = 0xffffffff" \
"= 0xffffffff"
gdb_test "p/x shared_buffer\[shared_buffer_size - 1\] = 0xabcd0123" \
"= 0xabcd0123"
gdb_test "p/x shared_buffer\[0\] = 0" "= 0x0"
# Once it is resumed, the test program asserts that the shared_buffer
# array has been updated with the specific values we've written above.
with_timeout_factor 2 {
gdb_continue_to_end "continue to end" "continue" 1
}
}
}
set shared_size [get_shared_size]
if {$shared_size == 0} {
return
}
foreach_with_prefix nonstop { on off } {
do_test $shared_size $nonstop
}