In [12]:
!pwd


/home/christian/.virtualenvs/vpr-x64/src/thrust-timing/notebooks

In [1]:
nrows = 33
ncols = nrows

In [2]:
%load_ext cythonmagic
import pkg_resources

cythrust_root = pkg_resources.resource_filename('cythrust', '')

In [4]:
from cyplace_experiments.data import open_netlists_h5f
import cythrust.device_vector as dv
from cythrust import DeviceVectorCollection
import numpy as np


h5f = open_netlists_h5f()

arch = getattr(h5f.root.architectures.vpr__k4_n1, 'x%04d_by_y%04d' %
               (nrows, ncols))

arch_data = DeviceVectorCollection({'delays':
                                    np.empty(np.sum([np.prod(c.shape)
                                                     for c in arch]),
                                             dtype=np.float32)})

offset = 0

for name in ('fb_to_fb', 'fb_to_io', 'io_to_fb', 'io_to_io'):
    c = getattr(arch, name)
    c_size = np.prod(c.shape)
    arch_data.v['delays'][offset:offset + c_size] = c[:].ravel()
    offset += c_size
del arch
h5f.close()

In [5]:
arch_data.as_arrays()


Out[5]:
OrderedDict([('delays', array([  0.00000000e+00,   3.54973384e-10,   4.58360072e-10, ...,
         3.74201514e-09,  -1.00000000e+00,  -1.00000000e+00], dtype=float32))])

In [7]:
from IPython.display import display
from cyplace_experiments.data.connections_table import \
    get_simple_net_list, ConnectionsTable
from thrust_timing.sort_timing import (compute_arrival_times,
                                       compute_departure_times)
import numpy as np

connections_table, arrival_times, departure_times = \
    get_simple_net_list()
print '\n'.join(get_simple_net_list.__doc__.splitlines()[2:-3])

arrival_block_data, arrival_connections = \
    compute_arrival_times(connections_table)
departure_block_data, departure_connections = \
    compute_departure_times(connections_table)
    
np.testing.assert_array_equal(arrival_block_data['longest_paths']
                              .values, arrival_times)
np.testing.assert_array_equal(departure_block_data['longest_paths']
                              .values, departure_times)


           ┌───┐
           │ 0 │─┐
           └───┘ │
                 │   ┌───┐
        ┌────────┴───│ 3 │──┐
        │        ┌───└───┘  │
        │  ┌───┐ │          └──┌───┐
        │  │ 1 │─┼─────────────│ 5 │──┐
        │  └───┘ │             └───┘  │
        │        └────────────────┐   │  ╔═══╗
        └──────────┐              │   └──║ 6 ║──┐
                   │              └──────╚═══╝  │
           ┌───┐   └─╔═══╗                      └──┌───┐     ┌───┐
           │ 2 │─────║ 4 ║─────────────────────────│ 7 │─────│ 8 │
           └───┘     ╚═══╝                         └───┘     └───┘


In [24]:
from IPython.display import display
from cyplace_experiments.data.connections_table import ConnectionsTable
from thrust_timing.sort_timing import (compute_arrival_times,
                                       compute_departure_times)

connections_table = ConnectionsTable.from_net_list_name('tseng')

arrival_block_data, arrival_connections = \
    compute_arrival_times(connections_table)
departure_block_data, departure_connections = \
    compute_departure_times(connections_table)
    
display(arrival_block_data['longest_paths'].describe())
display(departure_block_data['longest_paths'].describe())


count    1220.000000
mean        2.901639
std         2.679824
min         0.000000
25%         1.000000
50%         2.000000
75%         3.000000
max        13.000000
Name: longest_paths, dtype: float64
count    1220.000000
mean        2.572951
std         2.731115
min         0.000000
25%         1.000000
50%         2.000000
75%         2.000000
max        13.000000
Name: longest_paths, dtype: float64

In [74]:
from cythrust import DeviceDataFrame


arrival_delay_connections = DeviceDataFrame(arrival_connections[0]
                                            .base()[
    ['source_key', 'target_key', 'delay', 'source_longest_path',
     'target_longest_path', 'max_target_longest_path', 'reduced_keys']])
arrival_delay_connections.add('delay_type', connections_table
                              .sink_connections().delay_type.values)
arrival_delay_connections.add('delta_x', dtype=np.int32)
arrival_delay_connections.add('delta_y', dtype=np.int32)

# Reorder columns to put `delta_x` and `delta_y` columns before `delay`.
new_column_order = arrival_delay_connections.columns
for c in new_column_order[-1:-4:-1]:
    new_column_order.insert(2, c)
del new_column_order[-3:]

arrival_delay_connections.reorder(new_column_order)
arrival_delay_connections.columns


Out[74]:
['source_key',
 'target_key',
 'delay_type',
 'delta_x',
 'delta_y',
 'delay',
 'source_longest_path',
 'target_longest_path',
 'max_target_longest_path',
 'reduced_keys']

In [79]:
arch_data['delays']


Out[79]:
array([  0.00000000e+00,   3.54973384e-10,   4.58360072e-10, ...,
         3.74201514e-09,  -1.00000000e+00,  -1.00000000e+00], dtype=float32)

In [75]:
connections_table.sink_connections().delay_type.values.shape


Out[75]:
(3604,)

In [76]:
arrival_delay_connections[:].delay_type.values.shape


Out[76]:
(3604,)

In [77]:
arrival_delay_connections[:][arrival_delay_connections[:]['delay_type'] > 0].T


Out[77]:
2935 2989 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008
source_key 743 1214 859 860 1215 727 507 46 823 848 750 633 824 816 751 750 775 348 758 376 ...
target_key 1215 657 658 658 658 660 660 660 670 670 670 670 689 689 689 689 701 701 701 701 ...
delay_type 20 20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
delta_x 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
delta_y 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
delay 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
source_longest_path 1 4 4 4 4 4 0 0 4 1 2 1 4 4 4 2 3 0 4 0 ...
target_longest_path 2 5 5 5 5 5 1 1 5 2 3 2 5 5 5 3 4 1 5 1 ...
max_target_longest_path 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
reduced_keys 1174 590 601 605 621 622 625 630 639 641 643 648 650 657 658 660 662 664 670 677 ...

10 rows × 567 columns