1 # Copyright
2010-2019 Free Software Foundation
, Inc.
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.
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.
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
/>.
16 # Contributed by Ken Werner
<ken.werner@de.ibm.com
>.
18 # Support library
for testing OpenCL GDB features
20 #
Compile OpenCL programs using a generic host app.
21 proc 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"
24 set binfile
[standard_output_file $
{executable
}]
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}]
30 # Run a test
on the target to check
if it supports OpenCL.
Return 0 if so
, 1 if
32 gdb_caching_proc skip_opencl_tests
{
33 global srcdir objdir subdir gdb_prompt
34 global inferior_exited_re
36 set me
"skip_opencl_tests"
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.
41 set clprogram
[remote_download target $
{srcdir
}/lib
/opencl_kernel.cl
]
42 set executable opencltest
[pid
].x
44 verbose
"$me: compiling OpenCL test app" 2
45 set compile_flags
{debug nowarnings quiet
}
47 if { [gdb_compile_opencl_hostapp
"${clprogram}" "${executable}" "${compile_flags}" ] != "" } {
48 remote_file target
delete $
{clprogram
}
49 verbose
"$me: compiling OpenCL binary failed, returning 1" 2
53 # Compilation succeeded so now run it via gdb.
54 clean_restart
"$executable"
57 -re
".*$inferior_exited_re normally.*${gdb_prompt} $" {
58 verbose
-log "\n$me: OpenCL support detected"
61 -re
".*$inferior_exited_re with code.*${gdb_prompt} $" {
62 verbose
-log "\n$me: OpenCL support not detected"
66 verbose
-log "\n$me OpenCL support not detected (default case)"
71 remote_file build
delete $executable
73 #
Delete the OpenCL
program source file.
74 remote_file target
delete $
{clprogram
}
76 verbose
"$me: returning $result" 2