Skip to content

Commit d149148

Browse files
committed
WIP: Update coremark build scirpt and move executables to a different
folder Signed-off-by: Ádám László Kulcsár <[email protected]>
1 parent 0f40ad3 commit d149148

10 files changed

+110
-16
lines changed

test/programs/build_programs.py

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,124 @@
1616

1717
import argparse
1818
import os
19+
from subprocess import PIPE, Popen
1920

2021
from os.path import abspath, dirname, join
2122

2223
PROGRAMS_SOURCE_DIR = dirname(abspath(__file__))
2324

25+
PROGRAMS_EXECUTABLE_DIR = join(dirname(abspath(__file__)), "executables")
26+
27+
COREMARK_SOURCES = join(PROGRAMS_SOURCE_DIR, "coremark")
28+
29+
clang = False
30+
emcc = False
31+
clang_path = '/opt/wasi-sdk/bin/clang'
32+
emcc_path = '/usr/lib/emscripten/emcc'
33+
2434
def compile_coremark():
35+
global emcc, emcc_path, clang, clang_path
36+
37+
if clang:
38+
if os.system(clang_path + " --version >/dev/null") != 0:
39+
print("Could not find wasi-clang for building coremark.")
40+
exit(1)
41+
42+
proc = Popen([clang_path,
43+
'-O3',
44+
'-I'+COREMARK_SOURCES+'/posix', '-I'+COREMARK_SOURCES,
45+
'-DFLAGS_STR="-O3 -DPERFORMANCE_RUN=1"',
46+
'-Wl,--export=main',
47+
'-DITERATIONS=400000',
48+
'-DSEED_METHOD=SEED_VOLATILE',
49+
'-DPERFORMANCE_RUN=1',
50+
'-Wl,--allow-undefined',
51+
COREMARK_SOURCES + '/core_list_join.c',
52+
COREMARK_SOURCES + '/core_main.c',
53+
COREMARK_SOURCES + '/core_matrix.c',
54+
COREMARK_SOURCES + '/core_state.c',
55+
COREMARK_SOURCES + '/core_util.c',
56+
COREMARK_SOURCES + '/posix/core_portme.c',
57+
'-o'+ PROGRAMS_EXECUTABLE_DIR +'/coremark_clang.wasm'
58+
])
59+
60+
out, _ = proc.communicate()
61+
62+
if proc.returncode != 0:
63+
print("Error with clang compilation! Stopping.")
64+
exit(1)
65+
66+
67+
if emcc:
68+
if os.system(emcc_path + " --version >/dev/null") != 0:
69+
print("Could not find emcc for building coremark.")
70+
exit(1)
71+
72+
proc = Popen([emcc_path,
73+
'-O3',
74+
'-I'+COREMARK_SOURCES, '-I',COREMARK_SOURCES+'/posix',
75+
'-DFLAGS_STR="-O3 -DPERFORMANCE_RUN=1"',
76+
'-Wl,--allow-undefined',
77+
'-DITERATIONS=400000',
78+
'-DSEED_METHOD=SEED_VOLATILE',
79+
'-DPERFORMANCE_RUN=1',
80+
'-Wl,--export=main',
81+
'-sWASM=1',
82+
'-sEXPORTED_FUNCTIONS=_main',
83+
'-sEXPORTED_RUNTIME_METHODS=ccal,cwrap',
84+
COREMARK_SOURCES + '/core_list_join.c',
85+
COREMARK_SOURCES + '/core_main.c',
86+
COREMARK_SOURCES + '/core_matrix.c',
87+
COREMARK_SOURCES + '/core_state.c',
88+
COREMARK_SOURCES + '/core_util.c',
89+
COREMARK_SOURCES + '/posix/core_portme.c',
90+
'-o'+ PROGRAMS_EXECUTABLE_DIR +'/coremark_emcc.wasm'
91+
])
92+
93+
out, _ = proc.communicate()
94+
95+
if proc.returncode != 0:
96+
print("Error with emscripten compilation! Stopping.")
97+
exit(1)
98+
2599
return
26100

101+
27102
def parse_args():
103+
global emcc, emcc_path, clang, clang_path
104+
28105
parser = argparse.ArgumentParser()
29106
parser.add_argument("--all", help="compile all programs", action="store_true", default=True)
30107
parser.add_argument("--coremark", help="compile coremark", action="store_true")
31108
parser.add_argument("--summary", help="Generate summary", action="store_true", default=False)
109+
parser.add_argument("--emcc", help="Compile with emscripten. If there is no system emcc then follow the argument with a path to the emcc executeable.", nargs="?", default="")
110+
parser.add_argument("--clang", help="Compile with clang. If there is no system emcc then follow the argument with a path to the emcc executeable.", nargs="?", default="")
32111
args = parser.parse_args()
33112

34-
args.orig_results = args.results.copy()
113+
if args.emcc != "" and args.emcc is not None:
114+
emcc_path = args.emcc
115+
emcc = True
116+
elif args.emcc != "":
117+
emcc = True
118+
119+
if args.clang != "" and args.clang is not None:
120+
clang_path = args.clang
121+
clang = True
122+
elif args.clang != "":
123+
clang = True
124+
125+
if not clang and not emcc:
126+
print("Please define which compilers to use with --emcc, --clang!")
127+
exit(1)
128+
35129
return args
36130

37131
def main():
38132
args = parse_args()
39-
133+
40134
if args.all:
41135
compile_coremark()
42-
136+
43137
print("All programs compiled succesfully!")
44138
return
45139

133 KB
Binary file not shown.
26.1 KB
Binary file not shown.
26.1 KB
Binary file not shown.
157 KB
Binary file not shown.
128 KB
Binary file not shown.
127 KB
Binary file not shown.
127 KB
Binary file not shown.
32.3 KB
Binary file not shown.

tools/run-tests.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _run_wast_tests(engine, files, is_fail):
6565
fails = 0
6666
for file in files:
6767
if jit:
68-
filename = os.path.basename(file)
68+
filename = os.path.basename(file)
6969
if filename in JIT_EXCLUDE_FILES:
7070
continue
7171

@@ -185,18 +185,18 @@ def run_extended_tests(engine):
185185
continue
186186

187187
test_paths = sum(
188-
[glob(join(TEST_DIR, 'regression', f'issue-{id}', '*.wasm'), recursive=False) for id in test_case['ids']],
189-
[])
188+
[glob(join(TEST_DIR, 'regression', f'issue-{id}', '*.wasm'), recursive=False) for id in test_case['ids']],
189+
[])
190190

191191
if not test_paths:
192192
test_paths = sum(
193-
[glob(join(TEST_DIR, 'regression', f'issue-{id}', f"{test_case['file']}"), recursive=False) for id in
194-
test_case['ids']],
195-
[])
193+
[glob(join(TEST_DIR, 'regression', f'issue-{id}', f"{test_case['file']}"), recursive=False) for id in
194+
test_case['ids']],
195+
[])
196196

197197
if ('expected return' not in test_case and test_case['compile_options']['expected return']['ret code'] == 0) \
198198
or test_case['expected return']['ret code'] == 0:
199-
test_list_pass.extend(test_paths)
199+
test_list_pass.extend(test_paths)
200200
else:
201201
test_list_fail.extend(test_paths)
202202

@@ -268,12 +268,12 @@ def run_wamr_compiler_tests(engine):
268268
if fail_total > 0:
269269
raise Exception("other wamr-compiler tests failed")
270270

271-
@runner('dhrystone', default=True)
272-
def run_dhrystone_tests(engine):
273-
TEST_DIR = join(PROJECT_SOURCE_DIR, 'test', 'programs', 'dhrystone')
271+
@runner('programs', default=True)
272+
def run_program_tests(engine):
273+
TEST_DIR = join(PROJECT_SOURCE_DIR, 'test', 'programs', 'executables')
274274

275-
print('Running dhrystone tests:')
276-
xpass = glob(join(TEST_DIR, '**/*.wasm'), recursive=True)
275+
print('Running program tests:')
276+
xpass = glob(join(TEST_DIR, '*.wasm'), recursive=True)
277277
xpass_result = _run_wast_tests(engine, xpass, False)
278278

279279
tests_total = len(xpass)
@@ -283,7 +283,7 @@ def run_dhrystone_tests(engine):
283283
print('%sFAIL : %d%s' % (COLOR_RED, fail_total, COLOR_RESET))
284284

285285
if fail_total > 0:
286-
raise Exception("dhrystone tests failed")
286+
raise Exception("program tests failed")
287287

288288
def main():
289289
parser = ArgumentParser(description='Walrus Test Suite Runner')

0 commit comments

Comments
 (0)