source: proto/SymbolTable/wcd_pbgs_id_adv.py @ 4368

Last change on this file since 4368 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    temp32 = pablo.Advance32(temp)
74
75    # Group symbols of length 1
76    dictionary.Word_ends_1 = interpose32(temp, temp32, 1) & remaining_ends
77    remaining_ends = remaining_ends & ~dictionary.Word_ends_1
78
79    # Group symbols of length 2
80    dictionary.Word_ends_2 = interpose32(temp, temp32, 2) & remaining_ends
81    remaining_ends = remaining_ends & ~dictionary.Word_ends_2
82
83    # Group symbols of length 3
84    dictionary.Word_ends_3 = interpose32(temp, temp32, 3) & remaining_ends
85    remaining_ends = remaining_ends & ~dictionary.Word_ends_3
86
87    # Group symbols of length 4
88    dictionary.Word_ends_4 = interpose32(temp, temp32, 4) & remaining_ends
89    remaining_ends = remaining_ends & ~dictionary.Word_ends_4
90
91    # Group symbols of length 5
92    dictionary.Word_ends_5 = interpose32(temp, temp32, 5) & remaining_ends
93    remaining_ends = remaining_ends & ~dictionary.Word_ends_5
94
95    # Group symbols of length 6
96    dictionary.Word_ends_6 = interpose32(temp, temp32, 6) & remaining_ends
97    remaining_ends = remaining_ends & ~dictionary.Word_ends_6
98
99    # Group symbols of length 7
100    dictionary.Word_ends_7 = interpose32(temp, temp32, 7) & remaining_ends
101    remaining_ends = remaining_ends & ~dictionary.Word_ends_7
102
103    # Group symbols of length 8
104    dictionary.Word_ends_8 = interpose32(temp, temp32, 8) & remaining_ends
105    remaining_ends = remaining_ends & ~dictionary.Word_ends_8
106
107    # Group symbols of length 9
108    dictionary.Word_ends_9 = interpose32(temp, temp32, 9) & remaining_ends
109    remaining_ends = remaining_ends & ~dictionary.Word_ends_9
110
111    # Group symbols of length 10
112    dictionary.Word_ends_10 = interpose32(temp, temp32, 10) & remaining_ends
113    remaining_ends = remaining_ends & ~dictionary.Word_ends_10
114
115    # Group symbols of length 11
116    dictionary.Word_ends_11 = interpose32(temp, temp32, 11) & remaining_ends
117    remaining_ends = remaining_ends & ~dictionary.Word_ends_11
118
119    # Group symbols of length 12
120    dictionary.Word_ends_12 = interpose32(temp, temp32, 12) & remaining_ends
121    remaining_ends = remaining_ends & ~dictionary.Word_ends_12
122
123    # Group symbols of length 13
124    dictionary.Word_ends_13 = interpose32(temp, temp32, 13) & remaining_ends
125    remaining_ends = remaining_ends & ~dictionary.Word_ends_13
126
127    # Group symbols of length 14
128    dictionary.Word_ends_14 = interpose32(temp, temp32, 14) & remaining_ends
129    remaining_ends = remaining_ends & ~dictionary.Word_ends_14
130
131    # Group symbols of length 15
132    temp15 = interpose32(temp, temp32, 15)
133    dictionary.Word_ends_15 = temp15 & remaining_ends
134    remaining_ends = remaining_ends & ~dictionary.Word_ends_15
135
136    # Group symbols of length 16
137    temp = pablo.Advance(temp15)
138    dictionary.Word_ends_16 = temp & remaining_ends
139    remaining_ends = remaining_ends & ~dictionary.Word_ends_16
140
141    # Group symbols of length 17 and longer
142    dictionary.Word_ends_17_and_longer = remaining_ends
143
144def Compute_Hash_Value_Bitstream(hash_data, basis_bits):
145    hash_data.Hash_value = basis_bits.bit_2 ^ basis_bits.bit_4 ^ basis_bits.bit_6
146    #hash_data.Hash_value = basis_bits.bit_3 ^ basis_bits.bit_5 ^ basis_bits.bit_7
147
148def Main(basis_bits, dictionary, hash_data):
149    Classify_bytes(basis_bits, dictionary)
150
151    # These methods are needed to do Paralel Bitstream Based Length Sorting
152    Form_Length_Group_Bitstreams(dictionary)
153    Compute_Hash_Value_Bitstream(hash_data, basis_bits);
154               
Note: See TracBrowser for help on using the repository browser.