xref: /netbsd-src/external/gpl3/gdb/dist/gdb/testsuite/gdb.opencl/convs_casts.exp (revision 7bdf38e5b7a28439665f2fdeff81e36913eef7dd)
1# Copyright 2010-2024 Free Software Foundation, Inc.
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 Ken Werner <ken.werner@de.ibm.com>.
17#
18# Tests GDBs support for OpenCL type conversions and casts.
19
20load_lib opencl.exp
21
22require allow_opencl_tests
23
24set testfile "convs_casts"
25set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
26
27# Compile the generic OpenCL host app
28if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
29    untested "failed to compile"
30    return -1
31}
32
33# Load the OpenCL app
34clean_restart ${testfile}
35
36# Set breakpoint at the OpenCL kernel
37gdb_test "tbreak testkernel" \
38    "" \
39    "Set pending breakpoint" \
40    ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" \
41    "y"
42
43gdb_run_cmd
44gdb_test "" ".*reakpoint.*1.*testkernel.*" "run"
45
46# Continue to the marker
47gdb_breakpoint [gdb_get_line_number "marker" "${clprogram}"]
48gdb_continue_to_breakpoint "marker"
49
50# Retrieve some information about availability of OpenCL extensions
51set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
52set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
53
54proc vec_casts { name } {
55  global have_cl_khr_fp16 have_cl_khr_fp64
56  set types {"char" "uchar" "short" "ushort" "int" "uint" "long" "ulong" "half" "float" "double"}
57  set len [llength ${types}]
58
59  for {set i 0} {$i < ${len}} {incr i} {
60    set type [lindex ${types} $i]
61
62    gdb_test "print/d (${type}2)${name}" " = \\{123, 123\\}"
63    gdb_test "print/d (${type}3)${name}" " = \\{123, 123, 123\\}"
64    gdb_test "print/d (${type}4)${name}" " = \\{123, 123, 123, 123\\}"
65    gdb_test "print/d (${type}8)${name}" " = \\{123, 123, 123, 123, 123, 123, 123, 123\\}"
66    gdb_test "print/d (${type}16)${name}" " = \\{123 <repeats 16 times>\\}"
67
68    gdb_test "ptype (${type}2)${name}" "${type}2"
69    gdb_test "ptype (${type}3)${name}" "${type}3"
70    gdb_test "ptype (${type}4)${name}" "${type}4"
71    gdb_test "ptype (${type}8)${name}" "${type}8"
72    gdb_test "ptype (${type}16)${name}" "${type}16"
73  }
74}
75
76vec_casts "c"
77vec_casts "uc"
78vec_casts "s"
79vec_casts "us"
80vec_casts "i"
81vec_casts "ui"
82vec_casts "l"
83vec_casts "ul"
84if { ${have_cl_khr_fp16} } {
85  vec_casts "h"
86}
87vec_casts "f"
88if { ${have_cl_khr_fp64} } {
89  vec_casts "d"
90}
91
92# Delete the OpenCL program source
93remote_file target delete ${clprogram}
94