]>
Commit | Line | Data |
---|---|---|
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 |
20 | load_lib opencl.exp |
21 | ||
afb75473 | 22 | require allow_opencl_tests |
54fcddd0 UW |
23 | |
24 | set testfile "callfuncs" | |
25 | set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl] | |
26 | ||
27 | # Compile the generic OpenCL host app | |
28 | if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } { | |
5b362f04 | 29 | untested "failed to compile" |
54fcddd0 UW |
30 | return -1 |
31 | } | |
32 | ||
49e118b6 | 33 | clean_restart [standard_testfile $testfile] |
54fcddd0 UW |
34 | |
35 | # Set breakpoint at the OpenCL kernel | |
36 | gdb_test "tbreak testkernel" \ | |
37 | "" \ | |
38 | "Set pending breakpoint" \ | |
39 | ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" \ | |
40 | "y" | |
41 | ||
42 | gdb_run_cmd | |
43 | gdb_test "" ".*reakpoint.*1.*testkernel.*" "run" | |
44 | ||
45 | # Continue to the marker | |
46 | gdb_breakpoint [gdb_get_line_number "marker" "${clprogram}"] | |
47 | gdb_continue_to_breakpoint "marker" | |
48 | ||
49 | # Check if the language was switched to opencl | |
50 | gdb_test "show language" "The current source language is \"auto; currently opencl\"\." | |
51 | ||
52 | # Prevent multi-threaded execution during inferior calls | |
53 | gdb_test_no_output "set scheduler-locking on" | |
54 | ||
55 | # Retrieve some information about the OpenCL version and the availability of extensions | |
56 | set opencl_version [get_integer_valueof "opencl_version" 0] | |
57 | set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0] | |
58 | set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0] | |
59 | ||
60 | # Check function call / return sequence | |
61 | proc 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 | ||
74 | call_test "char" "c" | |
75 | call_test "uchar" "uc" | |
76 | call_test "short" "s" | |
77 | call_test "ushort" "us" | |
78 | call_test "int" "i" | |
79 | call_test "uint" "ui" | |
80 | call_test "long" "l" | |
81 | call_test "ulong" "ul" | |
82 | if { ${have_cl_khr_fp16} } { | |
83 | call_test "half" "h" | |
84 | } | |
85 | call_test "float" "f" | |
86 | if { ${have_cl_khr_fp64} } { | |
87 | call_test "double" "d" | |
88 | } | |
89 | ||
90 | # Delete the OpenCL program source | |
91 | remote_file target delete ${clprogram} |