-
Notifications
You must be signed in to change notification settings - Fork 11
/
perftests
executable file
·102 lines (94 loc) · 3.39 KB
/
perftests
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
#!./bin/ebb
-- The MIT License (MIT)
--
-- Copyright (c) 2015 Stanford University.
-- All rights reserved.
--
-- Permission is hereby granted, free of charge, to any person obtaining a
-- copy of this software and associated documentation files (the "Software"),
-- to deal in the Software without restriction, including without limitation
-- the rights to use, copy, modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included
-- in all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
local ffi = require "ffi"
local USE_GPU = false
local ONE_LINE_ERR = false
if #arg > 0 then
for i=1,#arg do
if arg[i] == '-gpu' or arg[i] == '--gpu' then
USE_GPU = true
end
if arg[i] == '-h' or arg[i] == '--help' then
print("Usage : run_tests [options]")
print("Options:")
print(" -h, --help show this help message and exit")
print(" -gpu, --gpu run tests on the GPU")
os.exit(0)
end
end
end
local lscmd = "find examples/performance_tests/"
local passed = {}
local bad_passed = {}
local failed = {}
local disabled = {}
local disable_str = '--DISABLE-TEST'
local function str_starts_with(str, prefix)
return string.sub(str,1,#prefix) == prefix
end
local function is_disabled (filename)
local h = io.open(filename, "r")
local line = h:read()
io.close(h)
local disabled_test = false
if line then
disabled_test = disabled_test or str_starts_with(line, disable_str)
end
return disabled_test
end
print("===============================")
print("= Running performance tests...")
print("===============================")
for line in io.popen(lscmd):lines() do
local file = line:match("^(examples/performance_tests/.*%.t)$")
if file then
local stats = file:gsub("/(.-)%.t$", "/%1.stats")
if is_disabled(file) then
table.insert(disabled, file)
else
print(file)
local cpu_time = 0
local gpu_time = 0
print("Executing on CPU ...")
local start_time = terralib.currenttimeinseconds()
os.execute("./liszt " .. file)
local end_time = terralib.currenttimeinseconds()
cpu_time = end_time - start_time
if USE_GPU then
print("Executing on GPU ...")
local start_time = terralib.currenttimeinseconds()
os.execute("./liszt --gpu " .. file)
local end_time = terralib.currenttimeinseconds()
gpu_time = end_time - start_time
end
print("Current execution time (seconds)")
local curr_time = ""
curr_time = curr_time .. string.format("cpu : %3i", cpu_time)
curr_time = curr_time .. string.format(" , gpu : %3i", gpu_time)
print(curr_time)
print("Expected execution time (seconds)")
os.execute("cat " .. stats)
end
end
end