source: proto/s2k/trunk/framework/input/templates/cpplang/s2k_header.template @ 4056

Last change on this file since 4056 was 4056, checked in by ksherdy, 5 years ago

Updated s2k engine demo.

File size: 2.7 KB
Line 
1/*
2 * \s2k{} push model template.
3 *
4 * Template Attributes:
5 *
6 * The \s2k{} compiler and substitutes generated code fragments for
7 * the following predefined template attributes bracked with
8 * hashhashhashamp and hashhashash.
9 *
10 * @global                - Stream structure and filter definitions.
11 *
12 * @bind                  - Bind calls.
13 *
14 * @struct_decls          - Stream structure declarations.
15 *
16 * @filter_decls          - Stream filter declarations.
17 *
18 * @filter_do_block       - Stream filter `do_block()' calls.
19 *
20 * @filter_do_final_block - Stream filter `do_final_block()' calls.
21 *
22 * @filter_clear          - Stream filter `clear()' calls.
23 */
24 
25/*
26 * ###@warningComment ###
27 */
28 
29#define DEBUG 0
30
31// Runtime directives
32#define BASIS_BITS
33
34// Runtime libraries
35#include <simd-lib/bitblock.hpp>
36#include <simd-lib/bitblock_iterator.hpp>
37#include <simd-lib/runtime.hpp>
38#include <simd-lib/pabloSupport.hpp>
39#include <simd-lib/transpose.hpp>
40#include <simd-lib/mmalloc.hpp>
41
42// C/C++ libraries
43#include <stdio.h>
44#include <stdlib.h>
45#include <string>
46#include <iostream>
47#include <sys/stat.h>
48#include <sys/mman.h>
49#include <fcntl.h>
50using namespace std;
51
52// S2K Bind
53//### @bind ###
54char * buffer;
55BitBlock * line_starts;
56BitBlock * line_ends;
57BitBlock * match_follows;
58
59// S2K Generated
60###@global ###
61
62struct pipeline {
63 
64  public:
65 
66  pipeline() { }
67  ~pipeline() { }
68
69  void process()
70  {
71    int bytes_remaining = s2k::BUFFER_SIZE;
72    int block_index     = 0;
73     
74      // \s2k{} bind.
75      char * byte_data;
76
77      // Process blocks.
78      while (bytes_remaining >= BLOCK_SIZE) {
79       
80        // \s2k{} bind.
81        byte_data = &buffer[block_index * BLOCK_SIZE];
82       
83        // \s2k{} 'do_block()' calls.
84        ###@filter_do_block ###
85 
86        // \s2k{} write.
87        match_follows[block_index]  = output.match_follows;
88        line_starts[block_index]    = output.line_starts;
89        line_ends[block_index]      = output.line_ends;
90         
91        bytes_remaining -= BLOCK_SIZE;
92        block_index++;
93      }   
94
95      // Process a partial block.
96      BitBlock EOF_mask = bitblock::srl(simd<1>::constant<1>(),
97                                        convert(BLOCK_SIZE - bytes_remaining));
98
99      // \s2k{} bind.
100      byte_data = &buffer[block_index * BLOCK_SIZE];
101         
102      // \s2k{} 'do_final_block()' calls.
103      ###@filter_do_final_block ###
104     
105      // \s2k{} write.
106      match_follows[block_index]  = output.match_follows & EOF_mask;
107      line_starts[block_index]    = output.line_starts & EOF_mask;
108      line_ends[block_index]      = output.line_ends & EOF_mask;
109  }
110 
111  private:
112
113// S2K Generated
114###@struct_decls ###
115
116// S2K Generated
117###@filter_decls ###   
118
119};
Note: See TracBrowser for help on using the repository browser.