Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 2011-2019 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 |
20 | load_lib opencl.exp |
21 | ||
22 | if { [skip_opencl_tests] } { | |
23 | return 0 | |
24 | } | |
25 | ||
26 | set testfile "callfuncs" | |
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}" "" ] != "" } { | |
5b362f04 | 31 | untested "failed to compile" |
54fcddd0 UW |
32 | return -1 |
33 | } | |
34 | ||
35 | gdb_exit | |
36 | gdb_start | |
37 | ||
38 | # Load the OpenCL app | |
39 | gdb_reinitialize_dir $srcdir/$subdir | |
40 | gdb_load ${objdir}/${subdir}/${testfile} | |
41 | ||
42 | # Set breakpoint at the OpenCL kernel | |
43 | gdb_test "tbreak testkernel" \ | |
44 | "" \ | |
45 | "Set pending breakpoint" \ | |
46 | ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" \ | |
47 | "y" | |
48 | ||
49 | gdb_run_cmd | |
50 | gdb_test "" ".*reakpoint.*1.*testkernel.*" "run" | |
51 | ||
52 | # Continue to the marker | |
53 | gdb_breakpoint [gdb_get_line_number "marker" "${clprogram}"] | |
54 | gdb_continue_to_breakpoint "marker" | |
55 | ||
56 | # Check if the language was switched to opencl | |
57 | gdb_test "show language" "The current source language is \"auto; currently opencl\"\." | |
58 | ||
59 | # Prevent multi-threaded execution during inferior calls | |
60 | gdb_test_no_output "set scheduler-locking on" | |
61 | ||
62 | # Retrieve some information about the OpenCL version and the availability of extensions | |
63 | set opencl_version [get_integer_valueof "opencl_version" 0] | |
64 | set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0] | |
65 | set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0] | |
66 | ||
67 | # Check function call / return sequence | |
68 | proc call_test { type var } { | |
69 | global opencl_version | |
70 | ||
71 | gdb_test "print/d call_${type} (${var}, ${var})" " = 2" | |
72 | gdb_test "print/d call_${type}2 (${var}2, ${var}2)" " = \\{2, 4\\}" | |
73 | if { ${opencl_version} >= 110 } { | |
74 | gdb_test "print/d call_${type}3 (${var}3, ${var}3)" " = \\{2, 4, 6\\}" | |
75 | } | |
76 | gdb_test "print/d call_${type}4 (${var}4, ${var}4)" " = \\{2, 4, 6, 8\\}" | |
77 | gdb_test "print/d call_${type}8 (${var}8, ${var}8)" " = \\{2, 4, 6, 8, 10, 12, 14, 16\\}" | |
78 | 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\\}" | |
79 | } | |
80 | ||
81 | call_test "char" "c" | |
82 | call_test "uchar" "uc" | |
83 | call_test "short" "s" | |
84 | call_test "ushort" "us" | |
85 | call_test "int" "i" | |
86 | call_test "uint" "ui" | |
87 | call_test "long" "l" | |
88 | call_test "ulong" "ul" | |
89 | if { ${have_cl_khr_fp16} } { | |
90 | call_test "half" "h" | |
91 | } | |
92 | call_test "float" "f" | |
93 | if { ${have_cl_khr_fp64} } { | |
94 | call_test "double" "d" | |
95 | } | |
96 | ||
97 | # Delete the OpenCL program source | |
98 | remote_file target delete ${clprogram} |