[PATCH v4 41/44] testsuite, sycl: add test for scheduler-locking

Markus Metzger <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
From: Tankut Baris Aktemur <[email protected]>

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

diff --git a/gdb/testsuite/gdb.sycl/scheduler-locking.exp b/gdb/testsuite/gdb.sycl/scheduler-locking.exp
new file mode 100644
index 00000000000..96f7d58b8bc
--- /dev/null
+++ b/gdb/testsuite/gdb.sycl/scheduler-locking.exp
@@ -0,0 +1,63 @@
+# Copyright 2020-2026 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
+}
+
+if {[build_executable "failed to compile $srcfile" "$binfile" "$srcfile" \
+	 {sycl debug}]} {
+    return
+}
+
+foreach device $sycl_device_list {
+    sycl_with_intelgt_lock $device {
+	clean_restart $testfile
+
+	if {![sycl_start $device]} {
+	    continue
+	}
+
+	set first_line [gdb_get_line_number "kernel-first-line"]
+	set last_line [gdb_get_line_number "kernel-last-line"]
+	gdb_breakpoint $first_line
+	gdb_breakpoint $last_line
+
+	for {set i 1} {$i <= 5} {incr i} {
+	    with_test_prefix "trip $i" {
+		gdb_test_no_output "set scheduler-locking off"
+		gdb_continue_to_breakpoint ".*kernel-first-line.*"
+
+		# Resuming should make only the current thread move.
+		set current_thread [get_current_thread "kernel-first-line"]
+
+		gdb_test_no_output "set scheduler-locking step"
+		gdb_test "next" "int in_elem = .*"
+
+		gdb_test_no_output "set scheduler-locking on"
+		gdb_test "continue" \
+		    "Thread $current_thread \[^\r\n\]+$srcfile:$last_line.*"
+	    }
+	}
+    }
+}
-- 
2.43.0

________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.