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