Skip to content

Commit 9fd0fbe

Browse files
Yangzheng BaiYangzheng Bai
authored andcommitted
Change -o core separator from comma to colon
Because we use comma separated value file format for the output, it's better to use colon instead of comma to separate -o arguments. We also split lh_test_cfg.yaml into two config file: sweeptest and unittest, because these two tests normally don't run together. We also modified runall.sh to use test_lockhammer.py instead of plain bash script.
1 parent e3c70f2 commit 9fd0fbe

File tree

6 files changed

+170
-89
lines changed

6 files changed

+170
-89
lines changed

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: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
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']
5555

@@ -144,9 +144,9 @@ def parse_lstopo():
144144
for line in out.splitlines():
145145
match = re.search("P#(\d+)", line.strip())
146146
if match:
147-
result += (match.group(1) + ',')
147+
result += (match.group(1) + ':')
148148
finally:
149-
if result[-1] == ',':
149+
if result[-1] == ':':
150150
result = result[:-1]
151151

152152
# sample output for single-socket EPYC 7601 server:
@@ -272,7 +272,9 @@ def generate_unittest(className, lhCfg, testCfg):
272272
logFile = default_value(globalCfg, 'logfile', None)
273273
safeMode = default_value(unitCfg, 'safemode', True)
274274

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

277279
allCmd = []
278280
if isinstance(testCfg['cmd'], list):
@@ -326,7 +328,10 @@ def generate_sweeptest(className, lhCfg):
326328
lhCommand = default_value(sweepCfg, 'cmd', [])
327329
lhArgument = default_value(sweepCfg, 'argulist', [{}])
328330

329-
prepare_logfile(logFile)
331+
if logFile:
332+
logFile = socket.gethostname() + '_' + logFile
333+
prepare_logfile(logFile)
334+
330335
sweepList = calc_sweep_list(arguMax, skipSince, skipStep)
331336
append_arch_cmd(sweepCfg, lhCommand)
332337

@@ -357,10 +362,14 @@ def build_sweep_test(lhCfg):
357362
sys.exit(2)
358363

359364

360-
# main function
365+
# test_lockhammer.py [local_yaml_config_file_without_extension]
361366
if __name__ == "__main__":
362-
lhConfig = read_config(os.path.join(os.path.dirname(os.path.abspath(__file__)), LH_CFG))
367+
if len(sys.argv) == 2:
368+
lhConfigFullPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), sys.argv[1])
369+
else:
370+
lhConfigFullPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), LH_CFG)
371+
lhConfig = read_config(lhConfigFullPath)
363372
pprint.pprint(lhConfig)
364373
build_unit_test(lhConfig)
365374
build_sweep_test(lhConfig)
366-
unittest.main(verbosity=2)
375+
unittest.main(argv=['first-arg-is-ignored'], verbosity=2)

benchmarks/lockhammer/src/lockhammer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,11 @@ int main(int argc, char** argv)
175175
case 'o':
176176
args.pinorder = calloc(num_cores, sizeof(int));
177177
if (args.pinorder == NULL) {
178-
fprintf(stderr, "ERROR: Cannot allocate enough memory for pinorder structure.\n");
178+
fprintf(stderr, "ERROR: cannot allocate enough memory for pinorder structure.\n");
179179
return 1;
180180
}
181-
csv = strtok(optarg, ",");
181+
/* colon is better than comma because lockhammer output uses csv format */
182+
csv = strtok(optarg, ":");
182183
for (int i = 0; i < num_cores && csv != NULL; ++i)
183184
{
184185
optval = strtol(csv, (char **) NULL, 10);
@@ -187,7 +188,7 @@ int main(int argc, char** argv)
187188
} else {
188189
fprintf(stderr, "WARNING: core number %ld is out of range.\n", optval);
189190
}
190-
csv = strtok(NULL, ",");
191+
csv = strtok(NULL, ":");
191192
}
192193
break;
193194
case 's':

0 commit comments

Comments
 (0)