Ignore:
Timestamp:
Feb 15, 2017, 4:08:37 PM (2 years ago)
Author:
nmedfort
Message:

memcpy/memset support for 32-bit systems; more error messages/handling; bug fix for ParabixCharacterClassKernelBuilder?. continued work on parenthesis matching + expandable buffers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/array-test.cpp

    r5316 r5320  
    1818#include <llvm/Support/raw_ostream.h>              // for errs
    1919#include <pablo/pablo_kernel.h>                    // for PabloKernel
     20#include <pablo/pe_zeroes.h>
    2021#include <toolchain.h>                             // for JIT_to_ExecutionEn...
    2122#include <pablo/builder.hpp>                       // for PabloBuilder
     
    3132namespace llvm { class Type; }
    3233namespace pablo { class Integer; }
    33 namespace pablo { class PabloAST; }
    3434namespace pablo { class Var; }
    3535
     
    6464    PabloAST * rparen = pb.createAnd(temp3, temp8, "rparens");
    6565    PabloAST * parens = pb.createOr(lparen, rparen);
    66 
    6766    PabloAST * pscan = pb.createScanTo(pb.createAdvance(lparen, 1), parens, "pscan");
    68 
    6967    PabloAST * closed = pb.createAnd(pscan, rparen, "closed");
    7068
    7169    pb.createAssign(pb.createExtract(matches, 0), closed);
    7270
    73     Var * all_closed = pb.createVar("all_closed", closed);
    74     Var * pending_lparen = pb.createVar("pending_lparen", pb.createAnd(pscan, lparen));
    75     Var * unmatched_rparen = pb.createVar("unmatched_rparen", pb.createAnd(rparen, pb.createNot(closed)));
    76     Var * in_play = pb.createVar("in_play", pb.createOr(pending_lparen, unmatched_rparen));
    77 
    78 
    79     Integer * one = pb.getInteger(1);
    80 
    81     Var * index = pb.createVar("i", one);
     71    Var * const all_closed = pb.createVar("all_closed", closed);
     72    Var * const pending_lparen = pb.createVar("pending_lparen", pb.createAnd(pscan, lparen));
     73    PabloAST * unmatched_rparen = pb.createAnd(rparen, pb.createNot(closed));
     74    Var * const in_play = pb.createVar("in_play", pb.createOr(pending_lparen, unmatched_rparen));
     75    Var * const errors = pb.createVar("errors", pb.createZeroes());
     76
     77    Integer * const one = pb.getInteger(1);
     78    Var * const index = pb.createVar("i", one);
    8279
    8380    PabloBuilder body = PabloBuilder::Create(pb);
     
    8885        closed = body.createAnd(pscan, rparen);
    8986        body.createAssign(body.createExtract(matches, index), closed);
     87        body.createAssign(all_closed, body.createOr(all_closed, closed));
     88        body.createAssign(errors, body.createOr(errors, body.createAtEOF(pscan)));
     89
    9090        body.createAssign(pending_lparen, body.createAnd(pscan, lparen));
    91         body.createAssign(all_closed, body.createOr(all_closed, closed));
    92         body.createAssign(unmatched_rparen, body.createAnd(rparen, body.createNot(all_closed)));
     91
     92        unmatched_rparen = body.createAnd(rparen, body.createNot(all_closed));
    9393        body.createAssign(in_play, body.createOr(pending_lparen, unmatched_rparen));
    9494        body.createAssign(index, body.createAdd(index, one));
    9595
    9696
     97    pb.createAssign(errors, pb.createOr(errors, pb.createAnd(rparen, pb.createNot(all_closed))));
     98    pb.createAssign(kernel->getOutputStreamVar("errors"), errors);
     99
    97100    pb.print(errs());
    98101
    99102}
     103
     104//42    def Match_Parens(lex, matches):
     105//43            parens = lex.LParen | lex.RParen
     106//44            i = 0
     107//45            pscan = pablo.AdvanceThenScanTo(lex.LParen, parens)
     108//46            matches.closed[0] = pscan & lex.RParen
     109//47            all_closed = matches.closed[0]
     110//48            matches.error = pablo.atEOF(pscan)
     111//49            # Not matched, still pending.
     112//50            pending_LParen = pscan & lex.LParen
     113//51            RParen_unmatched = lex.RParen &~ matches.closed[0]
     114//52            inPlay = pending_LParen | RParen_unmatched
     115//53            while pending_LParen:
     116//54                    i += 1
     117//55                    pscan = pablo.AdvanceThenScanTo(pending_LParen, inPlay)
     118//56                    matches.closed[i] = pscan & lex.RParen
     119//57                    all_closed |= matches.closed[i]
     120//58                    matches.error |= pablo.atEOF(pscan)
     121//59                    pending_LParen = pscan & lex.LParen
     122//60                    RParen_unmatched = lex.RParen &~ all_closed
     123//61                    inPlay = pending_LParen | RParen_unmatched
     124//62            #
     125//63            # Any closing paren that was not actually used to close
     126//64            # an opener is in error.
     127//65            matches.error |= lex.RParen &~ all_closed
    100128
    101129Function * pipeline(IDISA::IDISA_Builder * iBuilder, const unsigned count) {
     
    117145    SingleBlockBuffer BasisBits(iBuilder, iBuilder->getStreamSetTy(8, 1));
    118146    ExpandableBuffer matches(iBuilder, iBuilder->getStreamSetTy(count, 1), 2);
     147    SingleBlockBuffer errors(iBuilder, iBuilder->getStreamTy());
    119148
    120149    MMapSourceKernel mmapK(iBuilder);
     
    122151    mmapK.setInitialArguments({fileSize});
    123152   
    124     S2PKernel  s2pk(iBuilder);
     153    S2PKernel s2pk(iBuilder);
    125154    s2pk.generateKernel({&ByteStream}, {&BasisBits});
    126155
    127156    PabloKernel bm(iBuilder, "MatchParens",
    128157        {Binding{iBuilder->getStreamSetTy(8), "input"}},
    129         {Binding{iBuilder->getStreamSetTy(count), "matches"}});
     158        {Binding{iBuilder->getStreamSetTy(count), "matches"}, Binding{iBuilder->getStreamTy(), "errors"}});
    130159
    131160    generate(&bm);
    132161
    133     bm.generateKernel({&BasisBits}, {&matches});
     162    bm.generateKernel({&BasisBits}, {&matches, &errors});
    134163
    135164    iBuilder->SetInsertPoint(BasicBlock::Create(mod->getContext(), "entry", main, 0));
     
    138167    BasisBits.allocateBuffer();
    139168    matches.allocateBuffer();
     169    errors.allocateBuffer();
    140170
    141171    generatePipelineLoop(iBuilder, {&mmapK, &s2pk, &bm});
Note: See TracChangeset for help on using the changeset viewer.