Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.opencl / callfuncs.exp
CommitLineData
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
20load_lib opencl.exp
21
22if { [skip_opencl_tests] } {
163df4df 23 unsupported "OpenCL support not detected"
54fcddd0
UW
24 return 0
25}
26
27set testfile "callfuncs"
28set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
29
30# Compile the generic OpenCL host app
31if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
5b362f04 32 untested "failed to compile"
54fcddd0
UW
33 return -1
34}
35
36gdb_exit
37gdb_start
38
39# Load the OpenCL app
40gdb_reinitialize_dir $srcdir/$subdir
41gdb_load ${objdir}/${subdir}/${testfile}
42
43# Set breakpoint at the OpenCL kernel
44gdb_test "tbreak testkernel" \
45 "" \
46 "Set pending breakpoint" \
47 ".*Function \"testkernel\" not defined.*Make breakpoint pending.*y or \\\[n\\\]. $" \
48 "y"
49
50gdb_run_cmd
51gdb_test "" ".*reakpoint.*1.*testkernel.*" "run"
52
53# Continue to the marker
54gdb_breakpoint [gdb_get_line_number "marker" "${clprogram}"]
55gdb_continue_to_breakpoint "marker"
56
57# Check if the language was switched to opencl
58gdb_test "show language" "The current source language is \"auto; currently opencl\"\."
59
60# Prevent multi-threaded execution during inferior calls
61gdb_test_no_output "set scheduler-locking on"
62
63# Retrieve some information about the OpenCL version and the availability of extensions
64set opencl_version [get_integer_valueof "opencl_version" 0]
65set have_cl_khr_fp64 [get_integer_valueof "have_cl_khr_fp64" 0]
66set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
67
68# Check function call / return sequence
69proc 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
82call_test "char" "c"
83call_test "uchar" "uc"
84call_test "short" "s"
85call_test "ushort" "us"
86call_test "int" "i"
87call_test "uint" "ui"
88call_test "long" "l"
89call_test "ulong" "ul"
90if { ${have_cl_khr_fp16} } {
91 call_test "half" "h"
92}
93call_test "float" "f"
94if { ${have_cl_khr_fp64} } {
95 call_test "double" "d"
96}
97
98# Delete the OpenCL program source
99remote_file target delete ${clprogram}
This page took 1.366321 seconds and 4 git commands to generate.