source: icGREP/icgrep-devel/icgrep/u8u16.cpp @ 5306

Last change on this file since 5306 was 5306, checked in by cameron, 2 years ago

Modify u8u16 to use FileSink? for output

File size: 19.7 KB
Line 
1/*
2 *  Copyright (c) 2016 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include <IR_Gen/idisa_builder.h>                  // for IDISA_Builder
8#include <IR_Gen/idisa_target.h>                   // for GetIDISA_Builder
9#include <cc/cc_compiler.h>                        // for CC_Compiler
10#include <kernels/deletion.h>                      // for DeletionKernel
11#include <kernels/mmap_kernel.h>                   // for MMapSourceKernel
12#include <kernels/p2s_kernel.h>                    // for P2S16KernelWithCom...
13#include <kernels/s2p_kernel.h>                    // for S2PKernel
14#include <kernels/stdout_kernel.h>                 // for StdOutKernel
15#include <llvm/ExecutionEngine/ExecutionEngine.h>  // for ExecutionEngine
16#include <llvm/IR/Function.h>                      // for Function, Function...
17#include <llvm/IR/Module.h>                        // for Module
18#include <llvm/IR/Verifier.h>                      // for verifyModule
19#include <llvm/Support/CommandLine.h>              // for ParseCommandLineOp...
20#include <llvm/Support/Debug.h>                    // for dbgs
21#include <pablo/pablo_kernel.h>                    // for PabloKernel
22#include <pablo/pablo_toolchain.h>                 // for pablo_function_passes
23#include <pablo/pe_zeroes.h>
24#include <toolchain.h>                             // for JIT_to_ExecutionEn...
25#include <boost/iostreams/device/mapped_file.hpp>  // for mapped_file_source
26#include <boost/filesystem.hpp>
27#include <boost/interprocess/anonymous_shared_memory.hpp>
28#include "kernels/streamset.h"                     // for CircularBuffer
29#include <kernels/pipeline.h>
30#include "llvm/ADT/StringRef.h"                    // for StringRef
31#include "llvm/IR/CallingConv.h"                   // for ::C
32#include "llvm/IR/DerivedTypes.h"                  // for ArrayType, Pointer...
33#include "llvm/IR/LLVMContext.h"                   // for LLVMContext
34#include "llvm/IR/Value.h"                         // for Value
35#include "llvm/Support/Compiler.h"                 // for LLVM_UNLIKELY
36#include <pablo/builder.hpp>                       // for PabloBuilder
37#include <iostream>
38
39using namespace pablo;
40using namespace kernel;
41using namespace parabix;
42using namespace llvm;
43
44static cl::OptionCategory u8u16Options("u8u16 Options", "Transcoding control options.");
45static cl::opt<std::string> inputFile(cl::Positional, cl::desc("<input file>"), cl::Required, cl::cat(u8u16Options));
46static cl::opt<std::string> outputFile(cl::Positional, cl::desc("<output file>"),  cl::Required, cl::cat(u8u16Options));
47static cl::opt<bool> segmentPipelineParallel("enable-segment-pipeline-parallel", cl::desc("Enable multithreading with segment pipeline parallelism."), cl::cat(u8u16Options));
48static cl::opt<bool> mMapBuffering("mmap-buffering", cl::desc("Enable mmap buffering."), cl::cat(u8u16Options));
49static cl::opt<bool> memAlignBuffering("memalign-buffering", cl::desc("Enable posix_memalign buffering."), cl::cat(u8u16Options));
50
51
52void u8u16_pablo(PabloKernel * kernel) {
53    //  input: 8 basis bit streams
54   
55    const auto u8bitSet = kernel->getInputSet("u8bit");
56   
57    //  output: 16 u8-indexed streams, + delmask stream + error stream
58   
59    cc::CC_Compiler ccc(kernel, u8bitSet);
60   
61    PabloBuilder & main = ccc.getBuilder();
62    const auto u8_bits = ccc.getBasisBits();
63   
64    Zeroes * zeroes = main.createZeroes();
65
66    // Outputs
67    Var * u16_hi[8];
68    for (int i = 0; i < 8; ++i) {
69        u16_hi[i] = main.createVar("u16_hi" + std::to_string(i), zeroes);
70    }
71    Var * u16_lo[8];
72    for (int i = 0; i < 8; ++i) {
73        u16_lo[i] = main.createVar("u16_lo" + std::to_string(i), zeroes);
74    }
75    Var * delmask = main.createVar("delmask", zeroes);
76    Var * error_mask = main.createVar("error_mask", zeroes);
77
78    // The logic for processing non-ASCII bytes will be embedded within an if-hierarchy.
79    PabloAST * nonASCII = ccc.compileCC(re::makeCC(0x80, 0xFF));
80   
81    // Builder for the if statement handling all non-ASCII logic
82    PabloBuilder nAb = PabloBuilder::Create(main);
83    // Bits 3 through 7 of a 2-byte prefix are data bits, needed to
84    // produce the UTF-16 code unit data ...,
85    PabloAST * bit3a1 = nAb.createAdvance(u8_bits[3], 1);
86    PabloAST * bit4a1 = nAb.createAdvance(u8_bits[4], 1);
87    PabloAST * bit5a1 = nAb.createAdvance(u8_bits[5], 1);
88    PabloAST * bit6a1 = nAb.createAdvance(u8_bits[6], 1);
89    PabloAST * bit7a1 = nAb.createAdvance(u8_bits[7], 1);
90   
91    // Entry condition for 3 or 4 byte sequences: we have a prefix byte in the range 0xE0-0xFF.
92    PabloAST * pfx34 = ccc.compileCC(re::makeCC(0xE0, 0xFF), nAb);
93    // Builder for the if statement handling all logic for 3- and 4-byte sequences.
94    PabloBuilder p34b = PabloBuilder::Create(nAb);
95    // Bits 4 through 7 of a 3-byte prefix are data bits.  They must be moved
96    // to the final position of the 3-byte sequence.
97    PabloAST * bit2a1 = p34b.createAdvance(u8_bits[2], 1);
98    PabloAST * bit4a2 = p34b.createAdvance(bit4a1, 1);
99    PabloAST * bit5a2 = p34b.createAdvance(bit5a1, 1);
100    PabloAST * bit6a2 = p34b.createAdvance(bit6a1, 1);
101    PabloAST * bit7a2 = p34b.createAdvance(bit7a1, 1);
102
103
104    Var * const u8scope32 = nAb.createVar("u8scope32", zeroes);
105    Var * const u8scope33 = nAb.createVar("u8scope33", zeroes);
106    Var * const u8scope44 = nAb.createVar("u8scope44", zeroes);
107
108    //
109    // Logic for 4-byte UTF-8 sequences
110    //
111    // Entry condition  or 4 byte sequences: we have a prefix byte in the range 0xF0-0xFF.
112    PabloAST * pfx4 = ccc.compileCC(re::makeCC(0xF0, 0xFF), p34b);
113    // Builder for the if statement handling all logic for 4-byte sequences only.
114    PabloBuilder p4b = PabloBuilder::Create(p34b);
115    // Illegal 4-byte sequences
116    PabloAST * F0 = ccc.compileCC(re::makeCC(0xF0), p4b);
117    PabloAST * F4 = ccc.compileCC(re::makeCC(0xF4), p4b);
118    PabloAST * F0_err = p4b.createAnd(p4b.createAdvance(F0, 1), ccc.compileCC(re::makeCC(0x80, 0x8F), p4b));
119    PabloAST * F4_err = p4b.createAnd(p4b.createAdvance(F4, 1), ccc.compileCC(re::makeCC(0x90, 0xBF), p4b));
120    PabloAST * F5_FF = ccc.compileCC(re::makeCC(0xF5, 0xFF), p4b);
121
122    Var * FX_err = p34b.createVar("FX_err", zeroes);
123    p4b.createAssign(FX_err, p4b.createOr(F5_FF, p4b.createOr(F0_err, F4_err)));
124    //
125    // 4-byte prefixes have a scope that extends over the next 3 bytes.
126
127    Var * u8scope42 = p34b.createVar("u8scope42", zeroes);
128    Var * u8scope43 = p34b.createVar("u8scope43", zeroes);
129
130    p4b.createAssign(u8scope42, p4b.createAdvance(pfx4, 1));
131    p4b.createAssign(u8scope43, p4b.createAdvance(u8scope42, 1));
132    p4b.createAssign(u8scope44, p4b.createAdvance(u8scope43, 1));
133    //
134   
135    //  From the 4-byte sequence 11110abc 10defghi 10jklmno 10pqrstu,
136    //  we must calculate the value abcde - 1 to produce the bit values
137    //  for u16_hi6, hi7, lo0, lo1 at the scope43 position.
138    Var * s43_lo0 = nAb.createVar("scope43_lo0", zeroes);
139    Var * s43_lo1 = nAb.createVar("scope43_lo1", zeroes);
140    Var * s43_hi6 = nAb.createVar("scope43_hi6", zeroes);
141    Var * s43_hi7 = nAb.createVar("scope43_hi7", zeroes);
142
143    Var * s43_lo2 = main.createVar("scope43_lo2", zeroes);
144    Var * s43_lo3 = main.createVar("scope43_lo3", zeroes);
145    Var * s43_lo4 = main.createVar("scope43_lo4", zeroes);
146    Var * s43_lo5 = main.createVar("scope43_lo5", zeroes);
147    Var * s43_lo6 = main.createVar("scope43_lo6", zeroes);
148    Var * s43_lo7 = main.createVar("scope43_lo7", zeroes);
149
150    p4b.createAssign(s43_lo1, p4b.createAnd(u8scope43, p4b.createNot(bit3a1)));           // e - 1
151    p4b.createAssign(s43_lo0, p4b.createAnd(u8scope43, p4b.createXor(bit2a1, s43_lo1)));  // d - borrow
152    PabloAST * brw1 = p4b.createAnd(s43_lo1, p4b.createNot(bit2a1));
153    p4b.createAssign(s43_hi7, p4b.createAnd(u8scope43, p4b.createXor(bit7a2, brw1)));     // c - borrow
154    PabloAST * brw2 = p4b.createAnd(brw1, p4b.createNot(bit7a2));
155    p4b.createAssign(s43_hi6, p4b.createAnd(u8scope43, p4b.createXor(bit6a2, brw2)));     // b - borrow
156    //
157    p4b.createAssign(s43_lo2, p4b.createAnd(u8scope43, bit4a1));
158    p4b.createAssign(s43_lo3, p4b.createAnd(u8scope43, bit5a1));
159    p4b.createAssign(s43_lo4, p4b.createAnd(u8scope43, bit6a1));
160    p4b.createAssign(s43_lo5, p4b.createAnd(u8scope43, bit7a1));
161    p4b.createAssign(s43_lo6, p4b.createAnd(u8scope43, u8_bits[2]));
162    p4b.createAssign(s43_lo7, p4b.createAnd(u8scope43, u8_bits[3]));
163    //
164    //
165    p34b.createIf(pfx4, p4b);
166    //
167    // Combined logic for 3 and 4 byte sequences
168    //
169    PabloAST * pfx3 = ccc.compileCC(re::makeCC(0xE0, 0xEF), p34b);
170
171    p34b.createAssign(u8scope32, p34b.createAdvance(pfx3, 1));
172    p34b.createAssign(u8scope33, p34b.createAdvance(u8scope32, 1));
173
174    // Illegal 3-byte sequences
175    PabloAST * E0 = ccc.compileCC(re::makeCC(0xE0), p34b);
176    PabloAST * ED = ccc.compileCC(re::makeCC(0xED), p34b);
177    PabloAST * E0_err = p34b.createAnd(p34b.createAdvance(E0, 1), ccc.compileCC(re::makeCC(0x80, 0x9F), p34b));
178    PabloAST * ED_err = p34b.createAnd(p34b.createAdvance(ED, 1), ccc.compileCC(re::makeCC(0xA0, 0xBF), p34b));
179    Var * EX_FX_err = nAb.createVar("EX_FX_err", zeroes);
180
181    p34b.createAssign(EX_FX_err, p34b.createOr(p34b.createOr(E0_err, ED_err), FX_err));
182    // Two surrogate UTF-16 units are computed at the 3rd and 4th positions of 4-byte sequences.
183    PabloAST * surrogate = p34b.createOr(u8scope43, u8scope44);
184   
185    Var * p34del = nAb.createVar("p34del", zeroes);
186    p34b.createAssign(p34del, p34b.createOr(u8scope32, u8scope42));
187
188
189    // The high 5 bits of the UTF-16 code unit are only nonzero for 3 and 4-byte
190    // UTF-8 sequences.
191    p34b.createAssign(u16_hi[0], p34b.createOr(p34b.createAnd(u8scope33, bit4a2), surrogate));
192    p34b.createAssign(u16_hi[1], p34b.createOr(p34b.createAnd(u8scope33, bit5a2), surrogate));
193    p34b.createAssign(u16_hi[2], p34b.createAnd(u8scope33, bit6a2));
194    p34b.createAssign(u16_hi[3], p34b.createOr(p34b.createAnd(u8scope33, bit7a2), surrogate));
195    p34b.createAssign(u16_hi[4], p34b.createOr(p34b.createAnd(u8scope33, bit2a1), surrogate));
196   
197    //
198    nAb.createIf(pfx34, p34b);
199    //
200    // Combined logic for 2, 3 and 4 byte sequences
201    //
202
203    Var * u8lastscope = main.createVar("u8lastscope", zeroes);
204
205    PabloAST * pfx2 = ccc.compileCC(re::makeCC(0xC0, 0xDF), nAb);
206    PabloAST * u8scope22 = nAb.createAdvance(pfx2, 1);
207    nAb.createAssign(u8lastscope, nAb.createOr(u8scope22, nAb.createOr(u8scope33, u8scope44)));
208    PabloAST * u8anyscope = nAb.createOr(u8lastscope, p34del);
209
210    PabloAST * C0_C1_err = ccc.compileCC(re::makeCC(0xC0, 0xC1), nAb);
211    PabloAST * scope_suffix_mismatch = nAb.createXor(u8anyscope, ccc.compileCC(re::makeCC(0x80, 0xBF), nAb));
212    nAb.createAssign(error_mask, nAb.createOr(scope_suffix_mismatch, nAb.createOr(C0_C1_err, EX_FX_err)));
213    nAb.createAssign(delmask, nAb.createOr(p34del, ccc.compileCC(re::makeCC(0xC0, 0xFF), nAb)));
214   
215    // The low 3 bits of the high byte of the UTF-16 code unit as well as the high bit of the
216    // low byte are only nonzero for 2, 3 and 4 byte sequences.
217    nAb.createAssign(u16_hi[5], nAb.createOr(nAb.createAnd(u8lastscope, bit3a1), u8scope44));
218    nAb.createAssign(u16_hi[6], nAb.createOr(nAb.createAnd(u8lastscope, bit4a1), s43_hi6));
219    nAb.createAssign(u16_hi[7], nAb.createOr(nAb.createAnd(u8lastscope, bit5a1), s43_hi7));
220    nAb.createAssign(u16_lo[0], nAb.createOr(nAb.createAnd(u8lastscope, bit6a1), s43_lo0));
221
222    Var * p234_lo1 = main.createVar("p234_lo1", zeroes);
223
224    nAb.createAssign(p234_lo1, nAb.createOr(nAb.createAnd(u8lastscope, bit7a1), s43_lo1));
225
226    main.createIf(nonASCII, nAb);
227    //
228    //
229    PabloAST * ASCII = ccc.compileCC(re::makeCC(0x0, 0x7F));
230    PabloAST * last_byte = main.createOr(ASCII, u8lastscope);
231    main.createAssign(u16_lo[1], main.createOr(main.createAnd(ASCII, u8_bits[1]), p234_lo1));
232    main.createAssign(u16_lo[2], main.createOr(main.createAnd(last_byte, u8_bits[2]), s43_lo2));
233    main.createAssign(u16_lo[3], main.createOr(main.createAnd(last_byte, u8_bits[3]), s43_lo3));
234    main.createAssign(u16_lo[4], main.createOr(main.createAnd(last_byte, u8_bits[4]), s43_lo4));
235    main.createAssign(u16_lo[5], main.createOr(main.createAnd(last_byte, u8_bits[5]), s43_lo5));
236    main.createAssign(u16_lo[6], main.createOr(main.createAnd(last_byte, u8_bits[6]), s43_lo6));
237    main.createAssign(u16_lo[7], main.createOr(main.createAnd(last_byte, u8_bits[7]), s43_lo7));
238   
239    Var * output = kernel->getOutputSet("u16bit");
240    Var * delmask_out = kernel->getOutputSet("delMask");
241    Var * error_mask_out = kernel->getOutputSet("errMask");
242   
243    for (unsigned i = 0; i < 8; i++) {
244        main.createAssign(main.createExtract(output, i), u16_hi[i]);
245    }
246    for (unsigned i = 0; i < 8; i++) {
247        main.createAssign(main.createExtract(output, i + 8), u16_lo[i]);
248    }
249    main.createAssign(main.createExtract(delmask_out, main.getInteger(0)), delmask);
250    main.createAssign(main.createExtract(error_mask_out,  main.getInteger(0)), error_mask);
251
252    pablo_function_passes(kernel);
253}
254
255Function * u8u16Pipeline(Module * mod, IDISA::IDISA_Builder * iBuilder) {
256
257    const unsigned segmentSize = codegen::SegmentSize;
258    const unsigned bufferSegments = codegen::ThreadNum+1;
259   
260    assert (iBuilder);
261
262    Type * const size_ty = iBuilder->getSizeTy();
263    Type * const voidTy = iBuilder->getVoidTy();
264    Type * const bitBlockType = iBuilder->getBitBlockType();
265    Type * const inputType = ArrayType::get(ArrayType::get(bitBlockType, 8), 1)->getPointerTo();
266    Type * const outputType = ArrayType::get(ArrayType::get(bitBlockType, 16), 1)->getPointerTo();
267   
268    Function * const main = cast<Function>(mod->getOrInsertFunction("Main", voidTy, inputType, outputType, size_ty, nullptr));
269    main->setCallingConv(CallingConv::C);
270    Function::arg_iterator args = main->arg_begin();
271   
272    Value * const inputStream = &*(args++);
273    inputStream->setName("inputStream");
274    Value * const outputStream = &*(args++);
275    outputStream->setName("outputStream");
276    Value * const fileSize = &*(args++);
277    fileSize->setName("fileSize");
278
279    ExternalFileBuffer ByteStream(iBuilder, iBuilder->getStreamSetTy(1, 8));
280
281    CircularBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8), segmentSize * bufferSegments);
282
283    CircularBuffer U8u16Bits(iBuilder, iBuilder->getStreamSetTy(16), segmentSize * bufferSegments);
284    CircularBuffer DelMask(iBuilder, iBuilder->getStreamSetTy(), segmentSize * bufferSegments);
285    CircularBuffer ErrorMask(iBuilder, iBuilder->getStreamSetTy(), segmentSize * bufferSegments);
286
287    CircularBuffer U16Bits(iBuilder, iBuilder->getStreamSetTy(16), segmentSize * bufferSegments);
288   
289    CircularBuffer DeletionCounts(iBuilder, iBuilder->getStreamSetTy(), segmentSize * bufferSegments);
290
291    // Different choices for the output buffer depending on chosen option.
292    ExternalFileBuffer U16external(iBuilder, iBuilder->getStreamSetTy(1, 16));
293    CircularCopybackBuffer U16out(iBuilder, iBuilder->getStreamSetTy(1, 16), segmentSize * bufferSegments, 1 /*overflow block*/);
294
295    MMapSourceKernel mmapK(iBuilder, segmentSize); 
296    mmapK.generateKernel({}, {&ByteStream});
297    mmapK.setInitialArguments({fileSize});
298   
299    S2PKernel s2pk(iBuilder);
300
301    s2pk.generateKernel({&ByteStream}, {&BasisBits});
302
303    PabloKernel u8u16k(iBuilder, "u8u16",
304                       {Binding{iBuilder->getStreamSetTy(8, 1), "u8bit"}},
305                       {Binding{iBuilder->getStreamSetTy(16, 1), "u16bit"},
306                        Binding{iBuilder->getStreamSetTy(1, 1), "delMask"},
307                        Binding{iBuilder->getStreamSetTy(1, 1), "errMask"}}, {});
308
309    u8u16_pablo(&u8u16k);
310
311    u8u16k.generateKernel({&BasisBits}, {&U8u16Bits, &DelMask, &ErrorMask});
312
313    DeletionKernel delK(iBuilder, iBuilder->getBitBlockWidth()/16, 16);
314    delK.generateKernel({&U8u16Bits, &DelMask}, {&U16Bits, &DeletionCounts});
315
316    P2S16KernelWithCompressedOutput p2sk(iBuilder);
317
318    FileSink outK(iBuilder, 16);
319    if (mMapBuffering || memAlignBuffering) {
320        p2sk.generateKernel({&U16Bits, &DeletionCounts}, {&U16external});
321        outK.generateKernel({&U16external}, {});
322    } else {
323        p2sk.generateKernel({&U16Bits, &DeletionCounts}, {&U16out});
324        outK.generateKernel({&U16out}, {});
325    }
326    iBuilder->SetInsertPoint(BasicBlock::Create(mod->getContext(), "entry", main,0));
327
328    ByteStream.setStreamSetBuffer(inputStream, fileSize);
329    BasisBits.allocateBuffer();
330    U8u16Bits.allocateBuffer();
331    DelMask.allocateBuffer();
332    ErrorMask.allocateBuffer();
333    U16Bits.allocateBuffer();
334    DeletionCounts.allocateBuffer();
335    if (mMapBuffering || memAlignBuffering) {
336        U16external.setEmptyBuffer(outputStream);
337    } else {
338        U16out.allocateBuffer();
339    }
340    Value * fName = iBuilder->CreatePointerCast(iBuilder->CreateGlobalString(outputFile.c_str()), iBuilder->getInt8PtrTy());
341    outK.setInitialArguments({fName});
342
343    if (segmentPipelineParallel){
344        generateSegmentParallelPipeline(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &p2sk, &outK});
345    } else {
346        generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &u8u16k, &delK, &p2sk, &outK});
347    }
348
349    iBuilder->CreateRetVoid();
350    return main;
351}
352
353
354
355
356
357typedef void (*u8u16FunctionType)(char * byte_data, char * output_data, size_t filesize);
358
359static ExecutionEngine * u8u16Engine = nullptr;
360
361u8u16FunctionType u8u16CodeGen(void) {
362    LLVMContext TheContext;                           
363    Module * M = new Module("u8u16", TheContext);
364    IDISA::IDISA_Builder * idb = IDISA::GetIDISA_Builder(M);
365
366    llvm::Function * main_IR = u8u16Pipeline(M, idb);
367   
368    verifyModule(*M, &dbgs());
369    u8u16Engine = JIT_to_ExecutionEngine(M);   
370    u8u16Engine->finalizeObject();
371
372    delete idb;
373    return reinterpret_cast<u8u16FunctionType>(u8u16Engine->getPointerToFunction(main_IR));
374}
375
376void u8u16(u8u16FunctionType fn_ptr, const std::string & fileName) {
377    std::string mFileName = fileName;
378    size_t fileSize;
379    char * fileBuffer;
380   
381    const boost::filesystem::path file(mFileName);
382    if (exists(file)) {
383        if (is_directory(file)) {
384            return;
385        }
386    } else {
387        std::cerr << "Error: cannot open " << mFileName << " for processing. Skipped.\n";
388        return;
389    }
390   
391    fileSize = file_size(file);
392    boost::iostreams::mapped_file_source mFile;
393    if (fileSize == 0) {
394        fileBuffer = nullptr;
395    }
396    else {
397        try {
398            mFile.open(mFileName);
399        } catch (std::exception &e) {
400            std::cerr << "Error: Boost mmap of " << mFileName << ": " << e.what() << std::endl;
401            return;
402        }
403        fileBuffer = const_cast<char *>(mFile.data());
404    }
405
406    if (mMapBuffering) {
407        boost::interprocess::mapped_region outputBuffer(boost::interprocess::anonymous_shared_memory(2*fileSize));
408        outputBuffer.advise(boost::interprocess::mapped_region::advice_willneed);
409        outputBuffer.advise(boost::interprocess::mapped_region::advice_sequential);
410        fn_ptr(fileBuffer, static_cast<char*>(outputBuffer.get_address()), fileSize);
411    }
412    else if (memAlignBuffering) {
413        char * outputBuffer;
414        const auto r = posix_memalign(reinterpret_cast<void **>(&outputBuffer), 32, 2*fileSize);
415        if (LLVM_UNLIKELY(r != 0)) {
416            throw std::runtime_error("posix_memalign failed with return code " + std::to_string(r));
417        }
418        fn_ptr(fileBuffer, outputBuffer, fileSize);
419        free(reinterpret_cast<void *>(outputBuffer));
420    }
421    else {
422        /* No external output buffer */
423        fn_ptr(fileBuffer, nullptr, fileSize);
424    }
425    mFile.close();
426   
427}
428
429
430int main(int argc, char *argv[]) {
431    cl::HideUnrelatedOptions(ArrayRef<const cl::OptionCategory *>{&u8u16Options, pablo::pablo_toolchain_flags(), codegen::codegen_flags()});
432    cl::ParseCommandLineOptions(argc, argv);
433
434    u8u16FunctionType fn_ptr = u8u16CodeGen();
435
436    u8u16(fn_ptr, inputFile);
437
438    return 0;
439}
440
441                       
Note: See TracBrowser for help on using the repository browser.