source: proto/SymbolTable/wcd_pbgs_log.py @ 4948

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

SymbolTable?: renaming dictionary prefixed files into wcd

File size: 3.5 KB
RevLine 
[1666]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_to_4 = 0
34    Word_ends_5_to_8 = 0
35    Word_ends_9_to_16 = 0
36    Word_ends_17_and_longer = 0
37
38class Hash_data():
39    Hash_value = 0
40
41def Classify_bytes(basis_bits, dictionary):
42    temp1 = (basis_bits.bit_6 & basis_bits.bit_7)
43    temp2 = (basis_bits.bit_5 | temp1)
44    temp3 = (basis_bits.bit_4 & temp2)
45    temp4 = (~temp3)
46    temp5 = (basis_bits.bit_4 | basis_bits.bit_5)
47    temp6 = (basis_bits.bit_6 | basis_bits.bit_7)
48    temp7 = (temp5 | temp6)
49    temp8 = ((basis_bits.bit_3 & temp4)|(~(basis_bits.bit_3) & temp7))
50    temp9 = (basis_bits.bit_1 &~ basis_bits.bit_0)
[1686]51    dictionary.Words = (temp8 & temp9)
[1666]52
53    temp = pablo.Advance(dictionary.Words) ^ dictionary.Words
54    dictionary.Word_starts = temp & dictionary.Words
55    dictionary.Word_ends = temp & ~dictionary.Words
56
57def Form_Length_Group_Bitstreams(dictionary):
58
59    starts = dictionary.Word_starts
60    remaining_ends = dictionary.Word_ends
61
62    # Group symbols of length 1
63    starts_1 = pablo.Advance(starts)
64    dictionary.Word_ends_1 = starts_1 & remaining_ends
65    remaining_ends = remaining_ends & ~dictionary.Word_ends_1
66
67    # Group symbols of length 2
68    starts_2 = pablo.Advance(starts_1)
69    dictionary.Word_ends_2 = starts_2 & remaining_ends
70    remaining_ends = remaining_ends & ~dictionary.Word_ends_2
71
72    # Group symbols of length 3_to_4
73    temp = starts_1 | starts_2
74    temp32 = pablo.Advance32(temp)
75    #starts_3_to_4 = pablo.Advance(pablo.Advance(temp))
76    starts_3_to_4 = interpose32 (temp, temp32, 2)
77    dictionary.Word_ends_3_to_4 = starts_3_to_4 & remaining_ends
78    remaining_ends = remaining_ends & ~dictionary.Word_ends_3_to_4
79
80    # Group symbols of length 5_to_8
81    temp = temp | starts_3_to_4
82    temp32 = pablo.Advance32(temp)
83    #starts_5_to_8 = pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(temp))))
84    starts_5_to_8 = interpose32 (temp, temp32, 4)
85    dictionary.Word_ends_5_to_8 = starts_5_to_8 & remaining_ends
86    remaining_ends = remaining_ends & ~dictionary.Word_ends_5_to_8
87
88    # Group symbols of length 9_to_16
89    temp = temp | starts_5_to_8
90    temp32 = pablo.Advance32 (temp)
91    #starts_9_to_16 = pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(pablo.Advance(temp))))))))
92    starts_9_to_16 = interpose32 (temp, temp32, 8)
93    dictionary.Word_ends_9_to_16 = starts_9_to_16 & remaining_ends
94    remaining_ends = remaining_ends & ~dictionary.Word_ends_9_to_16
95
96    # Group symbols of length 17 and longer
97    dictionary.Word_ends_17_and_longer = remaining_ends
98
99def Compute_Hash_Value_Bitstream(hash_data, basis_bits):
100    hash_data.Hash_value = basis_bits.bit_2 ^ basis_bits.bit_4 ^ basis_bits.bit_6
101    #hash_data.Hash_value = basis_bits.bit_3 ^ basis_bits.bit_5 ^ basis_bits.bit_7
102
103def Main(basis_bits, dictionary, hash_data):
104    Classify_bytes(basis_bits, dictionary)
105
106    # These methods are needed to do Paralel Bitstream Based Length Sorting
107    Form_Length_Group_Bitstreams(dictionary)
108    Compute_Hash_Value_Bitstream(hash_data, basis_bits);
109               
Note: See TracBrowser for help on using the repository browser.