Skip to content

Commit 4fbf5e0

Browse files
gmlueckvladimirlaz
authored andcommitted
[SYCL] Check exit status get_device_count_by_type
Change the LIT infrastructure to check the exit status after spawning the "get_device_count_by_type" utility function. This avoids silent errors if that utility unexpectedly crashes. Signed-off-by: Greg Lueck <[email protected]>
1 parent d9b178f commit 4fbf5e0

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

sycl/test/lit.cfg.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,26 @@ def getDeviceCount(device_type):
9898
stdout=subprocess.PIPE)
9999
(output, err) = process.communicate()
100100
exit_code = process.wait()
101-
if exit_code == 0:
102-
result = output.decode().replace('\n', '').split(':', 1)
103-
try:
104-
value = int(result[0])
105-
except ValueError:
106-
value = 0
107-
print("getDeviceCount {TYPE}:Cannot get value from output.".format(
108-
TYPE=device_type))
109-
if len(result) > 1 and len(result[1]):
110-
print("getDeviceCount {TYPE}:{MSG}".format(
111-
TYPE=device_type, MSG=result[1]))
112-
if re.match(r".*cuda", result[1]):
113-
is_cuda = True;
114-
if err:
115-
print("getDeviceCount {TYPE}:{ERR}".format(
116-
TYPE=device_type, ERR=err))
117-
return [value,is_cuda]
118-
return 0
101+
if exit_code != 0:
102+
print("getDeviceCount {TYPE}:Non-zero exit code {CODE}".format(
103+
TYPE=device_type, CODE=exit_code))
104+
return [0,False]
105+
result = output.decode().replace('\n', '').split(':', 1)
106+
try:
107+
value = int(result[0])
108+
except ValueError:
109+
value = 0
110+
print("getDeviceCount {TYPE}:Cannot get value from output.".format(
111+
TYPE=device_type))
112+
if len(result) > 1 and len(result[1]):
113+
print("getDeviceCount {TYPE}:{MSG}".format(
114+
TYPE=device_type, MSG=result[1]))
115+
if re.match(r".*cuda", result[1]):
116+
is_cuda = True;
117+
if err:
118+
print("getDeviceCount {TYPE}:{ERR}".format(
119+
TYPE=device_type, ERR=err))
120+
return [value,is_cuda]
119121

120122
# Every SYCL implementation provides a host implementation.
121123
config.available_features.add('host')

0 commit comments

Comments
 (0)