source: proto/s2k/trunk/framework/input/templates/cpplang/s2k_json_header.template @ 4113

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

Added JSON template.

File size: 2.2 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      bytes_remaining -= BLOCK_SIZE;
86      block_index++;
87    }   
88
89    // Process a partial block.
90    BitBlock EOF_mask = bitblock::srl(simd<1>::constant<1>(),
91                                        convert(BLOCK_SIZE - bytes_remaining));
92
93    // s2k bind.
94    byte_data = &buffer[block_index * BLOCK_SIZE];
95         
96    // s2k 'do_final_block()' calls.
97    ###@filter_do_final_block ###
98   
99  }
100 
101  private:
102
103// s2k Generated
104###@struct_decls ###
105
106// s2k Generated
107###@filter_decls ###   
108
109};
Note: See TracBrowser for help on using the repository browser.