Skip to content

Commit f059bdc

Browse files
authored
Merge pull request #5 from ARM-software/master
Sync with upstream before checking in new workloads
2 parents e3c70f2 + 22cad9f commit f059bdc

File tree

7 files changed

+187
-103
lines changed

7 files changed

+187
-103
lines changed

benchmarks/lockhammer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CFLAGS=-g -O2 -I. -I./include -I../../ext/mysql/include -I../../ext/linux/include -I../../ext/tbb/include
1+
override CFLAGS += -g -O3 -I. -I./include -I../../ext/mysql/include -I../../ext/linux/include -I../../ext/tbb/include
22

33
ifneq ($(DEBUG_LEVEL),)
44
ifeq ($(shell test $(DEBUG_LEVEL) -gt 0; echo $$?),0)

benchmarks/lockhammer/scripts/lh_test_cfg.yaml renamed to benchmarks/lockhammer/scripts/lh_sweeptest_cfg.yaml

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ globalcfg:
3737
execdir: ../build
3838
logfile: lockhammer.csv
3939

40+
4041
## Sweep Test Settings
4142
#
4243
# Common assumptions for sweeptest:
@@ -50,7 +51,7 @@ globalcfg:
5051
#
5152
##
5253
sweeptest:
53-
enabled: False
54+
enabled: True
5455
safemode: False
5556
cmd:
5657
- lh_cas_event_mutex
@@ -89,56 +90,3 @@ sweeptest:
8990
c: 1000ns
9091
p: 5000ns
9192
o: lstopo
92-
93-
## Unittest Settings
94-
#
95-
# Common assumptions for unittest:
96-
# Only cover functional correctness, use as least time as possible
97-
# Normal runtime should be around 1 minute
98-
# t=0 means maximum core count
99-
#
100-
##
101-
unittest:
102-
enabled: True
103-
safemode: True
104-
testcase:
105-
- cmd:
106-
- lh_cas_event_mutex
107-
- lh_cas_lockref
108-
- lh_cas_rw_lock
109-
- lh_empty
110-
- lh_event_mutex
111-
- lh_incdec_refcount
112-
- lh_jvm_objectmonitor
113-
- lh_osq_lock
114-
- lh_queued_spinlock
115-
- lh_swap_mutex
116-
- lh_tbb_spin_rw_mutex
117-
- lh_ticket_spinlock
118-
cmd_aarch64: [lh_hybrid_spinlock, lh_hybrid_spinlock_fastdequeue]
119-
cmd_x86_64:
120-
t: [1, 0]
121-
a: 100
122-
c: [0ns, 50ns]
123-
p: [0ns, 50ns]
124-
125-
- cmd: lh_osq_lock
126-
t: [1, 0]
127-
a: 100
128-
c: 50ns
129-
p: 0ns
130-
o: lstopo
131-
extra:
132-
u: 10
133-
s: 2
134-
135-
- cmd: lh_tbb_spin_rw_mutex
136-
t: [1, 0]
137-
a: 100
138-
c: 50ns
139-
p: 0ns
140-
i: 1
141-
o: '0,1,2,3'
142-
extra:
143-
r: 4
144-
m: 1
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Copyright (c) 2018, ARM Limited. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
#
8+
# Redistributions of source code must retain the above copyright notice, this
9+
# list of conditions and the following disclaimer.
10+
#
11+
# Redistributions in binary form must reproduce the above copyright notice, this
12+
# list of conditions and the following disclaimer in the documentation and/or
13+
# other materials provided with the distribution.
14+
#
15+
# Neither the name of ARM Limited nor the names of its contributors may be used
16+
# to endorse or promote products derived from this software without specific
17+
# prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27+
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
#
30+
# The views and conclusions contained in the software and documentation are those
31+
# of the authors and should not be interpreted as representing official policies,
32+
# either expressed or implied, of this project.
33+
34+
35+
## Global Settings
36+
globalcfg:
37+
execdir: ../build
38+
logfile: lockhammer.csv
39+
40+
41+
## Unittest Settings
42+
#
43+
# Common assumptions for unittest:
44+
# Only cover functional correctness, use as least time as possible
45+
# Normal runtime should be around 1 minute
46+
# t=0 means maximum core count
47+
# o=lstopo means using lstopo output as preferred thread pinning order
48+
#
49+
##
50+
unittest:
51+
enabled: True
52+
safemode: True
53+
testcase:
54+
- cmd:
55+
- lh_cas_event_mutex
56+
- lh_cas_lockref
57+
- lh_cas_rw_lock
58+
- lh_empty
59+
- lh_event_mutex
60+
- lh_incdec_refcount
61+
- lh_jvm_objectmonitor
62+
- lh_osq_lock
63+
- lh_queued_spinlock
64+
- lh_swap_mutex
65+
- lh_tbb_spin_rw_mutex
66+
- lh_ticket_spinlock
67+
cmd_aarch64: [lh_hybrid_spinlock, lh_hybrid_spinlock_fastdequeue]
68+
cmd_x86_64:
69+
t: [1, 0]
70+
a: 100
71+
c: [0ns, 50ns]
72+
p: [0ns, 50ns]
73+
74+
- cmd: lh_osq_lock
75+
t: [1, 0]
76+
a: 100
77+
c: 50ns
78+
p: 0ns
79+
o: lstopo
80+
extra:
81+
u: 10
82+
s: 2
83+
84+
- cmd: lh_tbb_spin_rw_mutex
85+
t: [1, 0]
86+
a: 100
87+
c: 50ns
88+
p: 0ns
89+
i: 1
90+
o: '0:1:2:3'
91+
extra:
92+
r: 4
93+
m: 1

benchmarks/lockhammer/scripts/runall.sh

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,4 @@
2727
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
2828
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929

30-
./sweep.sh incdec_refcount 0 0 > incdec_refcount_0_0_$HOSTNAME.csv
31-
./sweep.sh cas_lockref 0 0 > cas_lockref_0_0_$HOSTNAME.csv
32-
./sweep.sh cas_lockref 2000 1000 > cas_lockref_2000_1000_$HOSTNAME.csv
33-
./sweep.sh ticket_spinlock 0 0 > ticket_spinlock_0_0_$HOSTNAME.csv
34-
./sweep.sh ticket_spinlock 1000 5000 > ticket_spinlock_1000_5000_$HOSTNAME.csv
35-
./sweep.sh queued_spinlock 0 0 > queued_spinlock_0_0_$HOSTNAME.csv
36-
./sweep.sh queued_spinlock 1000 5000 > queued_spinlock_1000_5000_$HOSTNAME.csv
37-
./sweep.sh event_mutex 0 0 > event_mutex_0_0_$HOSTNAME.csv
38-
./sweep.sh event_mutex 1000 5000 > event_mutex_1000_5000_$HOSTNAME.csv
39-
./sweep.sh cas_event_mutex 0 0 > cas_event_mutex_0_0_$HOSTNAME.csv
40-
./sweep.sh cas_event_mutex 1000 5000 > cas_event_mutex_1000_5000_$HOSTNAME.csv
41-
./sweep.sh cas_rw_lock 0 0 > cas_rw_lock_0_0_$HOSTNAME.csv
42-
./sweep.sh cas_rw_lock 2000 1000 > cas_rw_lock_2000_1000_$HOSTNAME.csv
43-
./sweep.sh hybrid_spinlock 0 0 > hybrid_spinlock_0_0_$HOSTNAME.csv
44-
./sweep.sh hybrid_spinlock 1000 5000 > hybrid_spinlock_1000_5000_$HOSTNAME.csv
45-
./sweep.sh hybrid_spinlock_fastdequeue 0 0 > hybrid_spinlock_fastdequeue_0_0_$HOSTNAME.csv
46-
./sweep.sh hybrid_spinlock_fastdequeue 1000 5000 > hybrid_spinlock_fastdequeue_1000_5000_$HOSTNAME.csv
47-
./sweep.sh empty 0 0 > empty_0_0_$HOSTNAME.csv
48-
./sweep.sh jvm_objectmonitor 0 0 > jvm_objectmonitor_0_0_$HOSTNAME.csv
49-
./sweep.sh jvm_objectmonitor 1000 5000 > jvm_objectmonitor_1000_5000_$HOSTNAME.csv
50-
./sweep.sh swap_mutex 0 0 > swap_mutex_0_0_$HOSTNAME.csv
51-
./sweep.sh swap_mutex 1000 5000 > swap_mutex_1000_5000_$HOSTNAME.csv
52-
./sweep.sh spin_rw_mutex 0 0 > spin_rw_mutex_0_0_$HOSTNAME.csv
53-
./sweep.sh spin_rw_mutex 1000 5000 > spin_rw_mutex_1000_5000_$HOSTNAME.csv
30+
nohup sudo ./test_lockhammer.py lh_sweeptest_cfg.yaml &
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) 2017, The Linux Foundation. All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are
7+
# met:
8+
# * Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
# * Redistributions in binary form must reproduce the above
11+
# copyright notice, this list of conditions and the following
12+
# disclaimer in the documentation and/or other materials provided
13+
# with the distribution.
14+
# * Neither the name of The Linux Foundation nor the names of its
15+
# contributors may be used to endorse or promote products derived
16+
# from this software without specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
19+
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
21+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
25+
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27+
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28+
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
./sweep.sh incdec_refcount 0 0 > incdec_refcount_0_0_$HOSTNAME.csv
31+
./sweep.sh cas_lockref 0 0 > cas_lockref_0_0_$HOSTNAME.csv
32+
./sweep.sh cas_lockref 2000 1000 > cas_lockref_2000_1000_$HOSTNAME.csv
33+
./sweep.sh ticket_spinlock 0 0 > ticket_spinlock_0_0_$HOSTNAME.csv
34+
./sweep.sh ticket_spinlock 1000 5000 > ticket_spinlock_1000_5000_$HOSTNAME.csv
35+
./sweep.sh queued_spinlock 0 0 > queued_spinlock_0_0_$HOSTNAME.csv
36+
./sweep.sh queued_spinlock 1000 5000 > queued_spinlock_1000_5000_$HOSTNAME.csv
37+
./sweep.sh event_mutex 0 0 > event_mutex_0_0_$HOSTNAME.csv
38+
./sweep.sh event_mutex 1000 5000 > event_mutex_1000_5000_$HOSTNAME.csv
39+
./sweep.sh cas_event_mutex 0 0 > cas_event_mutex_0_0_$HOSTNAME.csv
40+
./sweep.sh cas_event_mutex 1000 5000 > cas_event_mutex_1000_5000_$HOSTNAME.csv
41+
./sweep.sh cas_rw_lock 0 0 > cas_rw_lock_0_0_$HOSTNAME.csv
42+
./sweep.sh cas_rw_lock 2000 1000 > cas_rw_lock_2000_1000_$HOSTNAME.csv
43+
./sweep.sh hybrid_spinlock 0 0 > hybrid_spinlock_0_0_$HOSTNAME.csv
44+
./sweep.sh hybrid_spinlock 1000 5000 > hybrid_spinlock_1000_5000_$HOSTNAME.csv
45+
./sweep.sh hybrid_spinlock_fastdequeue 0 0 > hybrid_spinlock_fastdequeue_0_0_$HOSTNAME.csv
46+
./sweep.sh hybrid_spinlock_fastdequeue 1000 5000 > hybrid_spinlock_fastdequeue_1000_5000_$HOSTNAME.csv
47+
./sweep.sh empty 0 0 > empty_0_0_$HOSTNAME.csv
48+
./sweep.sh jvm_objectmonitor 0 0 > jvm_objectmonitor_0_0_$HOSTNAME.csv
49+
./sweep.sh jvm_objectmonitor 1000 5000 > jvm_objectmonitor_1000_5000_$HOSTNAME.csv
50+
./sweep.sh swap_mutex 0 0 > swap_mutex_0_0_$HOSTNAME.csv
51+
./sweep.sh swap_mutex 1000 5000 > swap_mutex_1000_5000_$HOSTNAME.csv
52+
./sweep.sh spin_rw_mutex 0 0 > spin_rw_mutex_0_0_$HOSTNAME.csv
53+
./sweep.sh spin_rw_mutex 1000 5000 > spin_rw_mutex_1000_5000_$HOSTNAME.csv

benchmarks/lockhammer/scripts/test_lockhammer.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@
4949

5050

5151
# config file should be in the same directory of this script
52-
LH_CFG = "lh_test_cfg.yaml"
52+
LH_CFG = "lh_unittest_cfg.yaml"
5353
# lockhammer.c has these parameters
5454
LH_ARGU_LIST = ['t', 'a', 'c', 'p', 'i', 'o']
55-
55+
# sh _timeout in seconds, default half an hour
56+
LH_TMOUT = 1800
5657

5758
# python unittest framework container class
5859
@unittest.skipUnless(sys.platform.startswith('linux'), "require Linux")
@@ -75,7 +76,7 @@ def write_output(stdOut, logFile, paramList):
7576
def construct_func(fullCmd, fullArg, logFile):
7677
def test(self):
7778
cmdObj = sh.Command(fullCmd)
78-
stdOut = str(cmdObj(fullArg))
79+
stdOut = str(cmdObj(fullArg, _timeout=LH_TMOUT))
7980
write_output(stdOut, logFile, [str(datetime.datetime.now()), socket.getfqdn(), fullCmd] + fullArg)
8081
regEx = "[0-9]*, [0-9]*\.?[0-9]*, [0-9]*\.?[0-9]*, [0-9]*\.?[0-9]*, [0-9]*\.?[0-9]*"
8182
self.assertRegex(stdOut, regEx, "This program has not run to completion.")
@@ -144,9 +145,9 @@ def parse_lstopo():
144145
for line in out.splitlines():
145146
match = re.search("P#(\d+)", line.strip())
146147
if match:
147-
result += (match.group(1) + ',')
148+
result += (match.group(1) + ':')
148149
finally:
149-
if result[-1] == ',':
150+
if result[-1] == ':':
150151
result = result[:-1]
151152

152153
# sample output for single-socket EPYC 7601 server:
@@ -272,7 +273,9 @@ def generate_unittest(className, lhCfg, testCfg):
272273
logFile = default_value(globalCfg, 'logfile', None)
273274
safeMode = default_value(unitCfg, 'safemode', True)
274275

275-
prepare_logfile(logFile)
276+
if logFile:
277+
logFile = socket.gethostname() + '_' + logFile
278+
prepare_logfile(logFile)
276279

277280
allCmd = []
278281
if isinstance(testCfg['cmd'], list):
@@ -326,7 +329,10 @@ def generate_sweeptest(className, lhCfg):
326329
lhCommand = default_value(sweepCfg, 'cmd', [])
327330
lhArgument = default_value(sweepCfg, 'argulist', [{}])
328331

329-
prepare_logfile(logFile)
332+
if logFile:
333+
logFile = socket.gethostname() + '_' + logFile
334+
prepare_logfile(logFile)
335+
330336
sweepList = calc_sweep_list(arguMax, skipSince, skipStep)
331337
append_arch_cmd(sweepCfg, lhCommand)
332338

@@ -357,10 +363,14 @@ def build_sweep_test(lhCfg):
357363
sys.exit(2)
358364

359365

360-
# main function
366+
# test_lockhammer.py [local_yaml_config_filename]
361367
if __name__ == "__main__":
362-
lhConfig = read_config(os.path.join(os.path.dirname(os.path.abspath(__file__)), LH_CFG))
368+
if len(sys.argv) == 2:
369+
lhConfigFullPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), sys.argv[1])
370+
else:
371+
lhConfigFullPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), LH_CFG)
372+
lhConfig = read_config(lhConfigFullPath)
363373
pprint.pprint(lhConfig)
364374
build_unit_test(lhConfig)
365375
build_sweep_test(lhConfig)
366-
unittest.main(verbosity=2)
376+
unittest.main(argv=['first-arg-is-ignored'], verbosity=2)

benchmarks/lockhammer/src/lockhammer.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,17 @@ void* hmr(void *);
5656

5757
void print_usage (char *invoc) {
5858
fprintf(stderr,
59-
"Usage: %s\n\t[-t threads]\n\t[-a acquires per thread]\n\t"
59+
"Usage: %s\n\t[-t <#> threads]\n\t[-a <#> acquires per thread]\n\t"
6060
"[-c <#>[ns | in] critical iterations measured in ns or (in)structions, "
6161
"if no suffix, assumes instructions]\n\t"
6262
"[-p <#>[ns | in] parallelizable iterations measured in ns or (in)structions, "
6363
"if no suffix, assumes (in)structions]\n\t"
64-
"[-s safe-mode operation for running as non-root\n\t"
65-
"[-i interleave value for thread pinning order, for example, 1 means "
66-
"sequential increasing, 2 means pinning hyperthread of the same core first "
67-
"before the next core.]\n\t"
68-
"[-o arbitrary core pinning order separated by comma without space, command "
69-
"lstopo can be used to deduce the correct order.]\n\t"
70-
"[-- <test specific arguments>]\n", invoc);
64+
"[-s safe-mode operation for running as non-root by reducing priority]\n\t"
65+
"[-i <#> interleave value for SMT pinning, e.g. 1: core pinning / no SMT, "
66+
"2: 2-way SMT pinning, 4: 4-way SMT pinning, may not work for multisocket]\n\t"
67+
"[-o <#:#:#:#> arbitrary pinning order separated by colon without space, "
68+
"command lstopo can be used to deduce the correct order]\n\t"
69+
"[-- <more workload specific arguments>]\n", invoc);
7170
}
7271

7372
int main(int argc, char** argv)
@@ -109,6 +108,9 @@ int main(int argc, char** argv)
109108
fprintf(stderr, "ERROR: thread count must be positive.\n");
110109
return 1;
111110
}
111+
else if (optval == 0) {
112+
optval = num_cores;
113+
}
112114
else if (optval <= num_cores) {
113115
args.nthrds = optval;
114116
}
@@ -175,19 +177,20 @@ int main(int argc, char** argv)
175177
case 'o':
176178
args.pinorder = calloc(num_cores, sizeof(int));
177179
if (args.pinorder == NULL) {
178-
fprintf(stderr, "ERROR: Cannot allocate enough memory for pinorder structure.\n");
180+
fprintf(stderr, "ERROR: cannot allocate enough memory for pinorder structure.\n");
179181
return 1;
180182
}
181-
csv = strtok(optarg, ",");
183+
/* support both comma and colon as delimiter */
184+
csv = strtok(optarg, ",:");
182185
for (int i = 0; i < num_cores && csv != NULL; ++i)
183186
{
184187
optval = strtol(csv, (char **) NULL, 10);
185-
if (optval >= 0 && optval < num_cores) {
186-
args.pinorder[i] = optval;
187-
} else {
188+
/* Some Arm systems may have core number larger than total cores number */
189+
args.pinorder[i] = optval;
190+
if (optval < 0 || optval > num_cores) {
188191
fprintf(stderr, "WARNING: core number %ld is out of range.\n", optval);
189192
}
190-
csv = strtok(NULL, ",");
193+
csv = strtok(NULL, ",:");
191194
}
192195
break;
193196
case 's':

0 commit comments

Comments
 (0)