source: proto/SymbolTable/wcd_pbgs_id.py @ 1795

Last change on this file since 1795 was 1688, checked in by vla24, 8 years ago

SymbolTable?: renaming dictionary prefixed files into wcd

File size: 5.0 KB
Line 
1# -*- coding: utf-8 -*-
2#
3# parabix2_compilable.py
4#
5# Parallel XML Parsing with Bitstream Addition
6#
7# - Complete prototype for all bitstream computations in Parabix2
8# - Optimized for compilation
9# - Separate compilation
10
11# Robert D. Cameron
12# July 29, 2010
13#
14
15#import bitutil
16
17class Basis_bits():
18    bit_0 = 0
19    bit_1 = 0
20    bit_2 = 0
21    bit_3 = 0
22    bit_4 = 0
23    bit_5 = 0
24    bit_6 = 0
25    bit_7 = 0
26
27class Dictionary ():
28    Words = 0
29    Word_starts = 0
30    Word_ends = 0
31    Word_ends_1 = 0
32    Word_ends_2 = 0
33    Word_ends_3 = 0
34    Word_ends_4 = 0
35    Word_ends_5 = 0
36    Word_ends_6 = 0
37    Word_ends_7 = 0
38    Word_ends_8 = 0
39    Word_ends_9 = 0
40    Word_ends_10 = 0
41    Word_ends_11 = 0
42    Word_ends_12 = 0
43    Word_ends_13 = 0
44    Word_ends_14 = 0
45    Word_ends_15 = 0
46    Word_ends_16 = 0
47    Word_ends_17_and_longer = 0
48
49class Hash_data():
50    Hash_value = 0
51
52def Classify_bytes(basis_bits, dictionary):
53    temp1 = (basis_bits.bit_6 & basis_bits.bit_7)
54    temp2 = (basis_bits.bit_5 | temp1)
55    temp3 = (basis_bits.bit_4 & temp2)
56    temp4 = (~temp3)
57    temp5 = (basis_bits.bit_4 | basis_bits.bit_5)
58    temp6 = (basis_bits.bit_6 | basis_bits.bit_7)
59    temp7 = (temp5 | temp6)
60    temp8 = ((basis_bits.bit_3 & temp4)|(~(basis_bits.bit_3) & temp7))
61    temp9 = (basis_bits.bit_1 &~ basis_bits.bit_0)
62    dictionary.Words = (temp8 & temp9)
63
64    temp = pablo.Advance(dictionary.Words) ^ dictionary.Words
65    dictionary.Word_starts = temp & dictionary.Words
66    dictionary.Word_ends = temp & ~dictionary.Words
67
68def Form_Length_Group_Bitstreams(dictionary):
69
70    remaining_starts = dictionary.Word_starts
71    remaining_ends = dictionary.Word_ends
72    temp = dictionary.Word_starts
73
74    # Group symbols of length 1
75    temp = pablo.Advance(temp)
76    dictionary.Word_ends_1 = temp & remaining_ends
77    remaining_ends = remaining_ends & ~dictionary.Word_ends_1
78
79    # Group symbols of length 2
80    temp = pablo.Advance(temp)
81    dictionary.Word_ends_2 = temp & remaining_ends
82    remaining_ends = remaining_ends & ~dictionary.Word_ends_2
83
84    # Group symbols of length 3
85    temp = pablo.Advance(temp)
86    dictionary.Word_ends_3 = temp & remaining_ends
87    remaining_ends = remaining_ends & ~dictionary.Word_ends_3
88
89    # Group symbols of length 4
90    temp = pablo.Advance(temp)
91    dictionary.Word_ends_4 = temp & remaining_ends
92    remaining_ends = remaining_ends & ~dictionary.Word_ends_4
93
94    # Group symbols of length 5
95    temp = pablo.Advance(temp)
96    dictionary.Word_ends_5 = temp & remaining_ends
97    remaining_ends = remaining_ends & ~dictionary.Word_ends_5
98
99    # Group symbols of length 6
100    temp = pablo.Advance(temp)
101    dictionary.Word_ends_6 = temp & remaining_ends
102    remaining_ends = remaining_ends & ~dictionary.Word_ends_6
103
104    # Group symbols of length 7
105    temp = pablo.Advance(temp)
106    dictionary.Word_ends_7 = temp & remaining_ends
107    remaining_ends = remaining_ends & ~dictionary.Word_ends_7
108
109    # Group symbols of length 8
110    temp = pablo.Advance(temp)
111    dictionary.Word_ends_8 = temp & remaining_ends
112    remaining_ends = remaining_ends & ~dictionary.Word_ends_8
113
114    # Group symbols of length 9
115    temp = pablo.Advance(temp)
116    dictionary.Word_ends_9 = temp & remaining_ends
117    remaining_ends = remaining_ends & ~dictionary.Word_ends_9
118
119    # Group symbols of length 10
120    temp = pablo.Advance(temp)
121    dictionary.Word_ends_10 = temp & remaining_ends
122    remaining_ends = remaining_ends & ~dictionary.Word_ends_10
123
124    # Group symbols of length 11
125    temp = pablo.Advance(temp)
126    dictionary.Word_ends_11 = temp & remaining_ends
127    remaining_ends = remaining_ends & ~dictionary.Word_ends_11
128
129    # Group symbols of length 12
130    temp = pablo.Advance(temp)
131    dictionary.Word_ends_12 = temp & remaining_ends
132    remaining_ends = remaining_ends & ~dictionary.Word_ends_12
133
134    # Group symbols of length 13
135    temp = pablo.Advance(temp)
136    dictionary.Word_ends_13 = temp & remaining_ends
137    remaining_ends = remaining_ends & ~dictionary.Word_ends_13
138
139    # Group symbols of length 14
140    temp = pablo.Advance(temp)
141    dictionary.Word_ends_14 = temp & remaining_ends
142    remaining_ends = remaining_ends & ~dictionary.Word_ends_14
143
144    # Group symbols of length 15
145    temp = pablo.Advance(temp)
146    dictionary.Word_ends_15 = temp & remaining_ends
147    remaining_ends = remaining_ends & ~dictionary.Word_ends_15
148
149    # Group symbols of length 16
150    temp = pablo.Advance(temp)
151    dictionary.Word_ends_16 = temp & remaining_ends
152    remaining_ends = remaining_ends & ~dictionary.Word_ends_16
153
154    # Group symbols of length 17 and longer
155    dictionary.Word_ends_17_and_longer = remaining_ends
156
157def Compute_Hash_Value_Bitstream(hash_data, basis_bits):
158    hash_data.Hash_value = basis_bits.bit_2 ^ basis_bits.bit_4 ^ basis_bits.bit_6
159    #hash_data.Hash_value = basis_bits.bit_3 ^ basis_bits.bit_5 ^ basis_bits.bit_7
160
161def Main(basis_bits, dictionary, hash_data):
162    Classify_bytes(basis_bits, dictionary)
163
164    # These methods are needed to do Paralel Bitstream Based Length Sorting
165    Form_Length_Group_Bitstreams(dictionary)
166    Compute_Hash_Value_Bitstream(hash_data, basis_bits);
167               
Note: See TracBrowser for help on using the repository browser.