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