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

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

Updates to grep s2k.

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