[PATCH v2 44/47] testsuite, sycl: add test for scheduler-locking

Tankut Baris Aktemur
2024-12-13T16:20:30Z

Add a new test to check that scheduler-locking when inside a SYCL
kernel works fine.
---
gdb/testsuite/gdb.sycl/scheduler-locking.exp | 67 ++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)

diff --git a/gdb/testsuite/gdb.sycl/scheduler-locking.exp b/gdb/testsuite/gdb.sycl/scheduler-locking.exp
new file mode 100644
index 0000000000000000000000000000000000000000..a5e9d23c03d2095117d94a20ce278b6e77255b56
--- /dev/null
+++ b/gdb/testsuite/gdb.sycl/scheduler-locking.exp
@@ -0,0 +1,67 @@
+# Copyright 2020-2024 Free Software Foundation, Inc.
+
+# 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 the scheduler-locker for resuming inside a SYCL kernel.
+
+load_lib sycl.exp
+
+standard_testfile parallel-for-1D.cpp
+
+set sycl_device_list [init_sycl_devices_list]
+if {[llength $sycl_device_list] == 0} {
+ unsupported "target does not support SYCL"
+ return 0
+}
+
+if {[build_executable "failed to compile $srcfile" \
+ "${binfile}" $srcfile {sycl debug}]} {
+ return -1
+}
+
+foreach device $sycl_device_list {
+ sycl_with_intelgt_lock $device {
+ clean_restart "${binfile}"
+
+ if {![sycl_start $device]} {
+ continue
+ }
+
+ set first_line [gdb_get_line_number "kernel-first-line"]
+ set second_line [expr $first_line + 1]
+ set third_line [expr $first_line + 2]
+ set fourth_line [expr $first_line + 3]
+ gdb_breakpoint $first_line
+ gdb_breakpoint $second_line
+ gdb_breakpoint $third_line
+ gdb_breakpoint $fourth_line
+
+ gdb_continue_to_breakpoint "hit the first line" \
+ ".*$srcfile:$first_line.*"
+
+ gdb_test_no_output "set scheduler-locking on"
+
+ # Resuming should make only the current thread move.
+ set current_thread [get_current_thread "line $first_line"]
+ gdb_test "continue" \
+ "Thread $current_thread \[^\r\n\]+$srcfile:$second_line.*" \
+ "hit the second line"
+ gdb_test "continue" \
+ "Thread $current_thread \[^\r\n\]+$srcfile:$third_line.*" \
+ "hit the third line"
+ gdb_test "continue" \
+ "Thread $current_thread \[^\r\n\]+$srcfile:$fourth_line.*" \
+ "hit the fourth line"
+ }
+}