]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.opencl/callfuncs.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.opencl / callfuncs.exp
CommitLineData
1d506c26 1# Copyright 2011-2024 Free Software Foundation, Inc.
54fcddd0
UW
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>. */
15#
16# Contributed by Ulrich Weigand <ulrich.weigand@de.ibm.com>.
17#
18# Tests OpenCL function calling conventions.
19
54fcddd0
UW
20load_lib opencl.exp
21
afb75473 22require allow_opencl_tests
54fcddd0
UW
23
24set testfile "callfuncs"
25set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
26
27# Compile the generic OpenCL host app
28if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
5b362f04 29 untested "failed to compile"
54fcddd0
UW
30 return -1
31}
32
49e118b6 33clean_restart [standard_testfile $testfile]
54fcddd0
UW
34
35# Set breakpoint at the OpenCL kernel
36gdb_test "tbreak testkernel" \
37 "" \
38 "Set pending breakpoint" \
39 ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" \
40 "y"
41
42gdb_run_cmd
43gdb_test "" ".*reakpoint.*1.*testkernel.*" "run"
44
45# Continue to the marker
46gdb_breakpoint [gdb_get_line_number "marker" "${clprogram}"]
47gdb_continue_to_breakpoint "marker"
48
49# Check if the language was switched to opencl
50gdb_test "show language" "The current source language is \"auto; currently opencl\"\."
51
52# Prevent multi-threaded execution during inferior calls
53gdb_test_no_output "set scheduler-locking on"
54
55# Retrieve some information about the OpenCL version and the availability of extensions
56set opencl_version [get_integer_valueof "opencl_version" 0]
57set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
58set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
59
60# Check function call / return sequence
61proc call_test { type var } {
62 global opencl_version
63
64 gdb_test "print/d call_${type} (${var}, ${var})" " = 2"
65 gdb_test "print/d call_${type}2 (${var}2, ${var}2)" " = \\{2, 4\\}"
66 if { ${opencl_version} >= 110 } {
67 gdb_test "print/d call_${type}3 (${var}3, ${var}3)" " = \\{2, 4, 6\\}"
68 }
69 gdb_test "print/d call_${type}4 (${var}4, ${var}4)" " = \\{2, 4, 6, 8\\}"
70 gdb_test "print/d call_${type}8 (${var}8, ${var}8)" " = \\{2, 4, 6, 8, 10, 12, 14, 16\\}"
71 gdb_test "print/d call_${type}16 (${var}16, ${var}16)" " = \\{2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32\\}"
72}
73
74call_test "char" "c"
75call_test "uchar" "uc"
76call_test "short" "s"
77call_test "ushort" "us"
78call_test "int" "i"
79call_test "uint" "ui"
80call_test "long" "l"
81call_test "ulong" "ul"
82if { ${have_cl_khr_fp16} } {
83 call_test "half" "h"
84}
85call_test "float" "f"
86if { ${have_cl_khr_fp64} } {
87 call_test "double" "d"
88}
89
90# Delete the OpenCL program source
91remote_file target delete ${clprogram}