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