]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/lib/opencl.exp
x86/Intel: warn about undue mnemonic suffixes
[thirdparty/binutils-gdb.git] / gdb / testsuite / lib / opencl.exp
CommitLineData
1d506c26 1# Copyright 2010-2024 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# Support library for testing OpenCL GDB features
19
20# Compile OpenCL programs using a generic host app.
21proc gdb_compile_opencl_hostapp {clsource executable options} {
22 global srcdir objdir subdir
23 set src "${srcdir}/lib/cl_util.c ${srcdir}/lib/opencl_hostapp.c"
aa480355 24 set binfile [standard_output_file ${executable}]
f4b8a18d
KW
25 set compile_flags [concat additional_flags=-I${srcdir}/lib/ additional_flags=-DCL_SOURCE=$clsource]
26 set options_opencl [concat {debug} $compile_flags $options [list libs=-lOpenCL]]
27 return [gdb_compile ${src} ${binfile} "executable" ${options_opencl}]
28}
29
afb75473 30# Run a test on the target to check if it supports OpenCL. Return 1 if so, 0 if
f4b8a18d 31# it does not.
b50420fd 32gdb_caching_proc allow_opencl_tests {} {
17e1c970 33 global srcdir objdir subdir gdb_prompt
fda326dd 34 global inferior_exited_re
f4b8a18d 35
afb75473 36 set me "allow_opencl_tests"
f4b8a18d
KW
37
38 # Set up, compile, and execute an OpenCL program. Include the current
39 # process ID in the file name of the executable to prevent conflicts with
40 # invocations for multiple testsuites.
91ffa03a 41 set clprogram [gdb_remote_download target ${srcdir}/lib/opencl_kernel.cl]
f4b8a18d
KW
42 set executable opencltest[pid].x
43
44 verbose "$me: compiling OpenCL test app" 2
45 set compile_flags {debug nowarnings quiet}
46
6da78614 47 if { [gdb_compile_opencl_hostapp "${clprogram}" "${executable}" "${compile_flags}" ] != "" } {
afb75473
TT
48 verbose "$me: compiling OpenCL binary failed, returning 0" 2
49 return 0
f4b8a18d
KW
50 }
51
52 # Compilation succeeded so now run it via gdb.
53 clean_restart "$executable"
54 gdb_run_cmd
55 gdb_expect 30 {
fda326dd 56 -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
f4b8a18d 57 verbose -log "\n$me: OpenCL support detected"
afb75473 58 set result 1
f4b8a18d 59 }
d2b584a5 60 -re ".*$inferior_exited_re with code.*${gdb_prompt} $" {
f4b8a18d 61 verbose -log "\n$me: OpenCL support not detected"
afb75473 62 set result 0
f4b8a18d
KW
63 }
64 default {
65 verbose -log "\n$me OpenCL support not detected (default case)"
afb75473 66 set result 0
f4b8a18d
KW
67 }
68 }
69 gdb_exit
70 remote_file build delete $executable
71
17e1c970
TT
72 verbose "$me: returning $result" 2
73 return $result
f4b8a18d 74}