Skip to content

Commit

Permalink
Merge pull request #12 from jeromekelleher/pythran
Browse files Browse the repository at this point in the history
Pythran
  • Loading branch information
jeromekelleher authored Aug 27, 2021
2 parents faf15ce + 5b6425c commit 6a953d7
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 102 deletions.
170 changes: 98 additions & 72 deletions data/tree-performance.csv
Original file line number Diff line number Diff line change
@@ -1,73 +1,99 @@
,order,implementation,sample_size,time_mean,time_var
0,msprime,py_numba,10,2.8540134662762286e-05,4.0138743538487945e-12
1,msprime,py_tskit,10,1.4611827791668475e-05,5.454016455301305e-12
2,msprime,c_lib,10,4.32e-07,0.0
3,msprime,c_recursive,10,4.11e-07,0.0
4,msprime,c_struct_contiguous,10,4.34e-07,0.0
5,msprime,c_struct_fragmented,10,3.89e-07,0.0
6,preorder,py_numba,10,2.8566209017299115e-05,2.459800961376813e-11
7,preorder,py_tskit,10,1.3768869219347835e-05,3.178959404084067e-12
8,preorder,c_lib,10,4.28e-07,0.0
9,preorder,c_recursive,10,3.97e-07,0.0
10,preorder,c_struct_contiguous,10,4.2e-07,0.0
11,preorder,c_struct_fragmented,10,3.99e-07,0.0
12,msprime,py_numba,100,7.674175605643541e-05,3.482266007416305e-10
13,msprime,py_tskit,100,1.6620315029285847e-05,7.567011308450897e-12
14,msprime,c_lib,100,2.726e-06,0.0
15,msprime,c_recursive,100,2.945e-06,0.0
16,msprime,c_struct_contiguous,100,2.865e-06,0.0
17,msprime,c_struct_fragmented,100,2.74e-06,0.0
18,preorder,py_numba,100,7.531476335134357e-05,7.18849128501038e-11
19,preorder,py_tskit,100,1.646423095371574e-05,4.734347490920951e-12
20,preorder,c_lib,100,2.744e-06,0.0
21,preorder,c_recursive,100,2.885e-06,0.0
22,preorder,c_struct_contiguous,100,2.808e-06,0.0
23,preorder,c_struct_fragmented,100,2.777e-06,0.0
24,msprime,py_numba,1000,0.000539161802851595,7.013503718161112e-10
25,msprime,py_tskit,1000,4.834113118704409e-05,4.6100322678013504e-11
26,msprime,c_lib,1000,3.1756e-05,0.0
27,msprime,c_recursive,1000,3.3263e-05,0.0
28,msprime,c_struct_contiguous,1000,3.2627e-05,0.0
29,msprime,c_struct_fragmented,1000,3.164e-05,0.0
30,preorder,py_numba,1000,0.0005330153827089817,5.343880201340534e-10
31,preorder,py_tskit,1000,4.7103321296162906e-05,3.558357414956268e-11
32,preorder,c_lib,1000,3.1155e-05,0.0
33,preorder,c_recursive,1000,3.3384e-05,0.0
34,preorder,c_struct_contiguous,1000,3.1308e-05,0.0
35,preorder,c_struct_fragmented,1000,3.1941e-05,0.0
36,msprime,py_numba,10000,0.00532087329775095,2.950362855263974e-08
37,msprime,py_tskit,10000,0.000503669191733934,3.260384184696477e-10
38,msprime,c_lib,10000,0.000505534,0.0
39,msprime,c_recursive,10000,0.000420235,0.0
40,msprime,c_struct_contiguous,10000,0.000432408,0.0
41,msprime,c_struct_fragmented,10000,0.000338762,0.0
42,preorder,py_numba,10000,0.005214149096980691,3.3317304310811266e-08
43,preorder,py_tskit,10000,0.00033959061093628406,1.7320717704898776e-10
44,preorder,c_lib,10000,0.000306742,0.0
45,preorder,c_recursive,10000,0.000337701,0.0
46,preorder,c_struct_contiguous,10000,0.000327341,0.0
47,preorder,c_struct_fragmented,10000,0.000337227,0.0
48,msprime,py_numba,100000,0.05427524673100561,2.4139536645272405e-06
49,msprime,py_tskit,100000,0.007691314306342975,5.548524184113716e-07
50,msprime,c_lib,100000,0.00780866,0.0
51,msprime,c_recursive,100000,0.00716185,0.0
52,msprime,c_struct_contiguous,100000,0.0067306,0.0
53,msprime,c_struct_fragmented,100000,0.00429481,0.0
54,preorder,py_numba,100000,0.051102137439884246,6.899616658855656e-07
55,preorder,py_tskit,100000,0.003263211432960816,1.3465280043040993e-08
56,preorder,c_lib,100000,0.0034373,0.0
57,preorder,c_recursive,100000,0.00361534,0.0
58,preorder,c_struct_contiguous,100000,0.00380468,0.0
59,preorder,c_struct_fragmented,100000,0.00390367,0.0
60,msprime,py_numba,1000000,0.7595824899966829,0.00021048295748450066
61,msprime,py_tskit,1000000,0.27509022200247274,6.702407744002218e-06
62,msprime,c_lib,1000000,0.270316,0.0
63,msprime,c_recursive,1000000,0.207154,0.0
64,msprime,c_struct_contiguous,1000000,0.193365,0.0
65,msprime,c_struct_fragmented,1000000,0.0448324,0.0
66,preorder,py_numba,1000000,0.5094039363902994,9.985812567576443e-07
67,preorder,py_tskit,1000000,0.04093705428531393,3.841080667539008e-07
68,preorder,c_lib,1000000,0.0383174,0.0
69,preorder,c_recursive,1000000,0.0388503,0.0
70,preorder,c_struct_contiguous,1000000,0.0410454,0.0
71,preorder,c_struct_fragmented,1000000,0.0397279,0.0
0,msprime,py_pythran,10,2.5583696900866925e-05,7.809983926760048e-12
1,msprime,py_numba,10,2.836359350476414e-05,1.7359376706916727e-11
2,msprime,py_tskit,10,1.3589535839855671e-05,9.184828871558387e-12
3,msprime,c_lib,10,4.43e-07,0.0
4,msprime,c_recursive,10,4.11e-07,0.0
5,msprime,c_struct_contiguous,10,4.18e-07,0.0
6,msprime,c_struct_fragmented,10,3.91e-07,0.0
7,preorder,py_pythran,10,2.590082585811615e-05,3.030955428906024e-11
8,preorder,py_numba,10,2.825020393356681e-05,1.539864884413577e-11
9,preorder,py_tskit,10,1.3512573204934596e-05,7.730593907037545e-12
10,preorder,c_lib,10,4.49e-07,0.0
11,preorder,c_recursive,10,4.59e-07,0.0
12,preorder,c_struct_contiguous,10,4.34e-07,0.0
13,preorder,c_struct_fragmented,10,4.03e-07,0.0
14,msprime,py_pythran,100,5.167797859758139e-05,6.429221542121828e-11
15,msprime,py_numba,100,7.471199857536703e-05,4.285108452093363e-11
16,msprime,py_tskit,100,1.6066455864347517e-05,5.76997232335103e-12
17,msprime,c_lib,100,2.705e-06,0.0
18,msprime,c_recursive,100,2.99e-06,0.0
19,msprime,c_struct_contiguous,100,2.877e-06,0.0
20,msprime,c_struct_fragmented,100,2.808e-06,0.0
21,preorder,py_pythran,100,5.117504834197462e-05,4.769600366560993e-11
22,preorder,py_numba,100,7.487921428401023e-05,7.214357494266344e-11
23,preorder,py_tskit,100,1.6021172399632633e-05,9.526227517346357e-12
24,preorder,c_lib,100,2.715e-06,0.0
25,preorder,c_recursive,100,2.926e-06,0.0
26,preorder,c_struct_contiguous,100,2.876e-06,0.0
27,preorder,c_struct_fragmented,100,2.76e-06,0.0
28,msprime,py_pythran,1000,0.0003081394217442721,3.145327963317433e-10
29,msprime,py_numba,1000,0.0005472428781213239,5.127235068371507e-10
30,msprime,py_tskit,1000,4.7597346594557164e-05,5.6991689453188005e-11
31,msprime,c_lib,1000,3.2224e-05,0.0
32,msprime,c_recursive,1000,3.3759e-05,0.0
33,msprime,c_struct_contiguous,1000,3.2924e-05,0.0
34,msprime,c_struct_fragmented,1000,3.2055e-05,0.0
35,preorder,py_pythran,1000,0.0003074059736682102,3.0694768360113097e-10
36,preorder,py_numba,1000,0.0005346568721579387,2.1227533897813347e-10
37,preorder,py_tskit,1000,4.589068912900984e-05,1.2172149457959373e-11
38,preorder,c_lib,1000,3.0893e-05,0.0
39,preorder,c_recursive,1000,3.3279e-05,0.0
40,preorder,c_struct_contiguous,1000,3.1057e-05,0.0
41,preorder,c_struct_fragmented,1000,3.1633e-05,0.0
42,msprime,py_pythran,10000,0.0029379673992516475,6.2762750953491905e-09
43,msprime,py_numba,10000,0.0051710225654533135,1.524685222496294e-08
44,msprime,py_tskit,10000,0.0004982919344911352,8.841957693966572e-10
45,msprime,c_lib,10000,0.000486727,0.0
46,msprime,c_recursive,10000,0.000402896,0.0
47,msprime,c_struct_contiguous,10000,0.000431504,0.0
48,msprime,c_struct_fragmented,10000,0.000339091,0.0
49,preorder,py_pythran,10000,0.0028233553573954852,1.3426214560934356e-09
50,preorder,py_numba,10000,0.005058508399641141,2.422371675065888e-09
51,preorder,py_tskit,10000,0.0003375611142255366,1.216721460301983e-10
52,preorder,c_lib,10000,0.000305847,0.0
53,preorder,c_recursive,10000,0.000336043,0.0
54,preorder,c_struct_contiguous,10000,0.000325554,0.0
55,preorder,c_struct_fragmented,10000,0.000335297,0.0
56,msprime,py_pythran,100000,0.03365420203434769,2.3322594997706654e-05
57,msprime,py_numba,100000,0.054033959006192164,2.67945655799003e-06
58,msprime,py_tskit,100000,0.007538950289250351,3.5949492946489047e-07
59,msprime,c_lib,100000,0.00751888,0.0
60,msprime,c_recursive,100000,0.00692209,0.0
61,msprime,c_struct_contiguous,100000,0.00633943,0.0
62,msprime,c_struct_fragmented,100000,0.00424398,0.0
63,preorder,py_pythran,100000,0.02893548096390441,4.3292710987952544e-07
64,preorder,py_numba,100000,0.05132964390935376,5.868534453378092e-07
65,preorder,py_tskit,100000,0.0034820095631293954,1.0937169630520294e-07
66,preorder,c_lib,100000,0.00344897,0.0
67,preorder,c_recursive,100000,0.00363671,0.0
68,preorder,c_struct_contiguous,100000,0.00387891,0.0
69,preorder,c_struct_fragmented,100000,0.00391498,0.0
70,msprime,py_pythran,1000000,0.49991502292687073,5.48326295686209e-05
71,msprime,py_numba,1000000,0.7700307431048714,0.00010178847386899849
72,msprime,py_tskit,1000000,0.27924976880894975,1.3112941214562399e-05
73,msprime,c_lib,1000000,0.279332,0.0
74,msprime,c_recursive,1000000,0.214285,0.0
75,msprime,c_struct_contiguous,1000000,0.198957,0.0
76,msprime,c_struct_fragmented,1000000,0.0459972,0.0
77,preorder,py_pythran,1000000,0.28591151580912993,3.0705415181927243e-06
78,preorder,py_numba,1000000,0.5129637230769731,1.7103412821326635e-05
79,preorder,py_tskit,1000000,0.04187946917954832,6.223032514941855e-07
80,preorder,c_lib,1000000,0.0405432,0.0
81,preorder,c_recursive,1000000,0.0396973,0.0
82,preorder,c_struct_contiguous,1000000,0.0419802,0.0
83,preorder,c_struct_fragmented,1000000,0.0405991,0.0
84,msprime,py_pythran,10000000,7.074751639994792,0.0005614327797677364
85,msprime,py_numba,10000000,10.0817625684198,0.002755264054662895
86,msprime,py_tskit,10000000,4.04270198950544,0.0014427176057664867
87,msprime,c_lib,10000000,4.09035,0.0
88,msprime,c_recursive,10000000,3.66669,0.0
89,msprime,c_struct_contiguous,10000000,2.93677,0.0
90,msprime,c_struct_fragmented,10000000,1.15941,0.0
91,preorder,py_pythran,10000000,2.962819242104888,0.0010798510649896842
92,preorder,py_numba,10000000,5.11672681128839,0.0012743940016086866
93,preorder,py_tskit,10000000,0.4149351096013561,6.0432335819378294e-05
94,preorder,c_lib,10000000,0.395052,0.0
95,preorder,c_recursive,10000000,0.398717,0.0
96,preorder,c_struct_contiguous,10000000,0.425057,0.0
97,preorder,c_struct_fragmented,10000000,0.41109,0.0
11 changes: 7 additions & 4 deletions plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ def save(name):
def tree_performance():

df = pd.read_csv("data/tree-performance.csv")
df = df[df.sample_size >= 1000]
fig, ax = plt.subplots(1, 1)
implementations = sorted(set(df.implementation))
dfo = df[df.order == "msprime"]
line_map = {}
for implementation in set(df.implementation):
for implementation in implementations:
dfi = dfo[dfo.implementation == implementation]
(line,) = ax.loglog(dfi.sample_size, dfi.time_mean, "-o", label=implementation)
line_map[implementation] = line

dfo = df[df.order == "preorder"]
for implementation in set(df.implementation):
for implementation in implementations:
dfi = dfo[dfo.implementation == implementation]
(line,) = ax.loglog(
dfi.sample_size,
Expand All @@ -54,13 +56,14 @@ def tree_performance_relative():
fig, axes = plt.subplots(1, 2, figsize=(8, 4), sharey=True)

dfo = df[df.order == "msprime"]
implementations = sorted(set(df.implementation))
print(dfo)
norm = np.array(dfo[dfo.implementation == "c_lib"].time_mean)
print(norm)
line_map = {}
ax = axes[0]
ax.set_title("Node order = msprime")
for implementation in set(df.implementation):
for implementation in implementations:
if "py" not in implementation:
dfi = dfo[dfo.implementation == implementation]
(line,) = ax.plot(
Expand All @@ -72,7 +75,7 @@ def tree_performance_relative():
ax.set_title("Node order = preorder")
dfo = df[df.order == "preorder"]
norm = np.array(dfo[dfo.implementation == "c_lib"].time_mean)
for implementation in set(df.implementation):
for implementation in implementations:
if "py" not in implementation:
dfi = dfo[dfo.implementation == implementation]
ax.plot(
Expand Down
6 changes: 5 additions & 1 deletion tree_performance/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TARGETS=c_implementation cpp_implementation
PYTHRAN_SO=pythran_implementation.cpython-38-x86_64-linux-gnu.so
TARGETS=c_implementation cpp_implementation ${PYTHRAN_SO}
TSK_OBJECTS=kastore.o tskit_tables.o tskit_core.o tskit_trees.o \
tskit_stats.o tskit_genotypes.o tskit_convert.o
CFLAGS += -g -Wall -Ikastore/c -I tskit/c -O3 -march=native
Expand All @@ -12,6 +13,9 @@ c_implementation: c_implementation.c libtskit.a
cpp_implementation: cpp_implementation.cc libtskit.a
${CXX} ${CXXFLAGS} $^ -o $@ -lm

${PYTHRAN_SO}: pythran_implementation.py
pythran pythran_implementation.py

libtskit.a: ${TSK_OBJECTS}
${AR} rcs $@ ${TSK_OBJECTS}

Expand Down
Loading

0 comments on commit 6a953d7

Please sign in to comment.