-
Notifications
You must be signed in to change notification settings - Fork 11
/
nvptx-none-run.exp
142 lines (119 loc) · 4.82 KB
/
nvptx-none-run.exp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# DejaGnu board file for nvptx-none.
# Copyright (C) 2015 Mentor Graphics
# Copyright (C) 2024 BayLibre
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nvptx-tools; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>. */
set_board_info target_install {nvptx-none}
load_generic_config "sim"
if { [info exists env(NVPTX_NONE_EXECUTION_LOCK_FILE)] } then {
set_board_info sim,execution_lock_file "$env(NVPTX_NONE_EXECUTION_LOCK_FILE)"
} else {
#TODO What's a good default filename?
set_board_info sim,execution_lock_file "/tmp/gpu.lock"
}
if { [info exists env(NVPTX_NONE_RUN)] } then {
set_board_info sim "$env(NVPTX_NONE_RUN)"
} else {
set_board_info sim "nvptx-none-run"
}
# This isn't a simulator, but rather a "launcher".
unset_board_info is_simulator
unset_board_info slow_simulator
process_multilib_options ""
set_board_info gcc,stack_size 8192
set_board_info gcc,no_trampolines 1
set_board_info gcc,no_label_values 1
set_board_info gcc,signal_suppress 1
set_board_info compiler "[find_gcc]"
set_board_info cflags "[newlib_include_flags]"
# Specify -mmainkernel to link in crt0.o.
set_board_info ldflags "[newlib_link_flags] -mmainkernel"
set_board_info ldscript ""
# Work around <http://mid.mail-archive.com/B457CE4A2BB446B7930A9BA1E38DBCCC@pleaset> 'ERROR: (DejaGnu) proc "::tcl::tm::UnknownHandler {::tcl::MacOSXPkgUnknown ::tclPkgUnknown} msgcat 1.4" does not exist.'...
# Otherwise, our use of 'clock format' may cause spurious errors such as:
# ERROR: gcc.c-torture/compile/pr44686.c -O0 : unknown dg option: ::tcl::tm::UnknownHandler ::tclPkgUnknown msgcat 1.4 for " dg-require-profiling 1 "-fprofile-generate" "
# ..., and all testing thus breaking apart.
set dummy [clock format [clock seconds]]
unset dummy
proc sim__open_lock_file { lock_file } {
# Try to open the lock file for reading, so that this also works if
# somebody else created the file.
if [catch {open $lock_file r} result] {
verbose -log "Couldn't open '$lock_file' for reading: $result"
# Try to create the lock file.
if [catch {open $lock_file a+} result] {
verbose -log "Couldn't create '$lock_file': $result"
# If this again failed, somebody else created it, concurrently. If
# in the following we're now not able to open it for reading, we've
# got a fundamental problem, and let it fail.
set result [open $lock_file r]
}
}
return $result
}
# The default 'sim_load' would eventually call into 'sim_spawn', 'sim_wait',
# but it's earlier here to just override the former one, and put safeguards
# into the latter two.
proc sim_spawn { dest cmdline args } {
perror "TODO 'sim_spawn'"
verbose -log "TODO 'sim_spawn'"
return -1
}
proc sim_wait { dest timeout } {
perror "TODO 'sim_wait'"
verbose -log "TODO 'sim_wait'"
return -1
}
proc sim_load { dest prog args } {
set inpfile ""
if { [llength $args] > 1 } {
if { [lindex $args 1] != "" } {
set inpfile "[lindex $args 1]"
}
}
# The launcher arguments are the program followed by the program arguments.
set pargs [lindex $args 0]
set largs [concat $prog $pargs]
set args [lreplace $args 0 0 $largs]
set launcher [board_info $dest sim]
# To support parallel testing ('make -j[...] check') in light of flaky test
# results for concurrent GPU usage, we'd like to serialize execution tests.
set lock_file [board_info $dest sim,execution_lock_file]
if { $lock_file != "" } {
set lock_fd [sim__open_lock_file $lock_file]
set lock_clock_begin [clock seconds]
exec flock 0 <@ $lock_fd
set lock_clock_end [clock seconds]
verbose -log "Got flock('$lock_file') at [clock format $lock_clock_end] after [expr $lock_clock_end - $lock_clock_begin] s" 2
}
# Note, not using 'remote_exec $dest' here.
set result [eval [list remote_exec host $launcher] $args $inpfile]
# We don't tell 'launcher' execution failure from 'prog' execution failure.
# Maybe we should, or maybe it doesn't matter. (When there's an error,
# there's an error.)
if { $lock_file != "" } {
# Unlock (implicit with 'close').
close $lock_fd
}
if { [lindex $result 0] == 0 } {
return [list "pass" [lindex $result 1]]
} else {
return [list "fail" [lindex $result 1]]
}
}
proc sim_exec { dest srcfile args } {
perror "TODO 'sim_exec'"
verbose -log "TODO 'sim_exec'"
return -1
}