Skip to content

Commit 6bf0a98

Browse files
committed
Implement nosync baseline version for test-cdeque (+ tests and plot)
1 parent e4ef4d2 commit 6bf0a98

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

libworkstream_df/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ WSTREAM_DEPS+= cdeque-native.c.h cdeque-c11.c.h cdeque-native.h cdeque-c11.h
99

1010
TEST_DESTDIR= tests
1111

12-
TEST_KINDS= -c11 -dumbc11 -llscopt -nolwcas -nofences
12+
TEST_KINDS= -c11 -dumbc11 -llscopt -nolwcas -nofences -nosync
1313
TEST_EXP= $(TEST_DESTDIR)/__TEST__
1414
TEST_EXP+= $(foreach K,$(TEST_KINDS),$(TEST_DESTDIR)/__TEST__$(K))
1515
TEST_PROGS.cdeque= $(subst __TEST__,test-cdeque,$(TEST_EXP))
@@ -36,6 +36,7 @@ $(TEST_DESTDIR)/test-%-dumbc11: WSTREAM_CFLAGS+=-DUSE_SEQ_CST_STDATOMIC=1
3636
$(TEST_DESTDIR)/test-%-llscopt: WSTREAM_CFLAGS+=-DLLSC_OPTIMIZATION=1
3737
$(TEST_DESTDIR)/test-%-nolwcas: WSTREAM_CFLAGS+=-DNO_LIGHTWEIGHT_CAS=1
3838
$(TEST_DESTDIR)/test-%-nofences: WSTREAM_CFLAGS+=-DNO_FENCES=1
39+
$(TEST_DESTDIR)/test-%-nosync: WSTREAM_CFLAGS+=-DNO_FENCES=1 -DNO_SYNC=1
3940

4041
$(TEST_DESTDIR)/test-%: error.c $(WSTREAM_DEPS) $(TEST_DEPS)
4142
mkdir -p $(TEST_DESTDIR)

libworkstream_df/benchmark-cdeque.sh

+11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ BEGIN {
3636
}
3737
' >rand.$$
3838

39+
t=test-cdeque-nosync
40+
echo $t prerun >&2
41+
for i in $(seq 1 10); do
42+
[ $dry ] || ./$t $testargs -f 0 | tail -n 1 >/dev/null
43+
done
44+
log=$t.$nthread.$b.$d.log
45+
for i in $(seq 1 30); do
46+
echo $t $testargs -f 0 >&2 \>\> $log
47+
[ $dry ] || ./$t $testargs -f 0 | tail -n 1 >$log
48+
done
49+
3950
for t in $tests; do
4051
echo $t prerun >&2
4152
for i in $(seq 1 10); do

libworkstream_df/plot-benchmark-cdeque.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@ if [ -n "$(find . -maxdepth 1 -name "test-*.$n.$b.$d.log")" ]; then
7070
sort -n >tput_eff_tput.$t.$n.$b.$d.data
7171
done
7272
plot tput_eff_tput.test-cdeque points \
73+
'Critical path throughput' \
74+
'effective steal throughput (s⁻¹)' \
75+
'push/take throughput (s⁻¹)'
76+
norm=$(awk '{x+=2*$(NF-3)/$1;++n} END{print x/n}' \
77+
test-cdeque-nosync.$n.$b.$d.log)
78+
for t in $tests; do
79+
awk -v norm=$norm '{print $NF/$1, 2*$(NF-3)/$1/norm}' \
80+
$t.$n.$b.$d.log |
81+
sort -n >norm_tput_eff_tput.$t.$n.$b.$d.data
82+
done
83+
plot norm_tput_eff_tput.test-cdeque points \
7384
'Critical path throughput' \
7485
'effective steal throughput (s⁻¹)' \
75-
'push/take throughput (s⁻¹)'
86+
'normalized push/take throughput'
7687
fi

libworkstream_df/wstream_df.h

+14
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ store_conditional (volatile size_t *ptr, size_t value)
107107
static inline bool
108108
compare_and_swap (volatile size_t *ptr, size_t oldval, size_t newval)
109109
{
110+
#if !NO_FENCES || !NO_SYNC
110111
#if !NO_LIGHTWEIGHT_CAS && defined(__arm__)
111112
int status = 1;
112113
__asm__ __volatile__ ("0: ldrex r0, [%1]\n\t"
@@ -123,11 +124,21 @@ compare_and_swap (volatile size_t *ptr, size_t oldval, size_t newval)
123124
#else
124125
return __sync_bool_compare_and_swap (ptr, oldval, newval);
125126
#endif
127+
#else
128+
if (*ptr == oldval)
129+
{
130+
*ptr = newval;
131+
return true;
132+
}
133+
else
134+
return false;
135+
#endif
126136
}
127137

128138
static inline bool
129139
weak_compare_and_swap (volatile size_t *ptr, size_t oldval, size_t newval)
130140
{
141+
#if !NO_FENCES || !NO_SYNC
131142
#if !NO_LIGHTWEIGHT_CAS && defined(__arm__)
132143
int status = 1;
133144
__asm__ __volatile__ ("ldrex r0, [%1]\n\t"
@@ -140,6 +151,9 @@ weak_compare_and_swap (volatile size_t *ptr, size_t oldval, size_t newval)
140151
#else
141152
return __sync_bool_compare_and_swap (ptr, oldval, newval);
142153
#endif
154+
#else
155+
return compare_and_swap (ptr, oldval, newval);
156+
#endif
143157
}
144158

145159

0 commit comments

Comments
 (0)