Ignore:
Timestamp:
Mar 18, 2017, 1:20:50 AM (2 years ago)
Author:
nmedfort
Message:

Work on non carry collapsing mode. Beginning work on pablo-level phi nodes.

File:
1 edited

Legend:

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

    r5366 r5368  
    4545static cl::list<std::string> inputFiles(cl::Positional, cl::desc("<input file ...>"), cl::OneOrMore);
    4646
     47void generate(PabloKernel * kernel) {
     48
     49    PabloBuilder pb(kernel->getEntryBlock());
     50
     51    Var * input = kernel->getInputStreamVar("input");
     52
     53    PabloAST * basis[8];
     54    for (int i = 0; i < 8; ++i) {
     55        basis[i] = pb.createExtract(input, i);
     56    }
     57
     58    PabloAST * temp1 = pb.createOr(basis[0], basis[1], "temp1");
     59    PabloAST * temp2 = pb.createAnd(basis[2], pb.createNot(basis[3]), "temp2");
     60    PabloAST * temp3 = pb.createAnd(temp2, pb.createNot(temp1), "temp3");
     61    PabloAST * temp4 = pb.createAnd(basis[4], pb.createNot(basis[5]), "temp4");
     62    PabloAST * temp5 = pb.createOr(basis[6], basis[7], "temp5");
     63    PabloAST * temp6 = pb.createAnd(temp4, pb.createNot(temp5), "temp6");
     64    PabloAST * lparen = pb.createAnd(temp3, temp6, "lparens");
     65    PabloAST * temp7 = pb.createAnd(basis[7], pb.createNot(basis[6]), "temp7");
     66    PabloAST * temp8 = pb.createAnd(temp4, temp7, "temp8");
     67    PabloAST * rparen = pb.createAnd(temp3, temp8, "rparens");
     68    PabloAST * parens = pb.createOr(lparen, rparen, "parens");
     69
     70
     71    Var * const pending_lparen = pb.createVar("pending_lparen", lparen);
     72    Var * const all_closed = pb.createVar("all_closed", pb.createZeroes());
     73    Var * const accumulated_errors = pb.createVar("accumulated_errors", pb.createZeroes());
     74    Var * const in_play = pb.createVar("in_play", parens);
     75    Var * const index = pb.createVar("i", pb.getInteger(0));
     76
     77    Var * matches = kernel->getOutputStreamVar("matches");
     78
     79    PabloBuilder body = PabloBuilder::Create(pb);
     80
     81    pb.createWhile(pending_lparen, body);
     82
     83        PabloAST * adv_pending_lparen = body.createAdvance(pending_lparen, 1);
     84
     85        Var * pscan = body.createVar("pscan", pb.createZeroes());
     86
     87        PabloBuilder ifPScan = PabloBuilder::Create(body);
     88
     89        body.createIf(adv_pending_lparen, ifPScan); // <-- inefficient but tests whether we're probably calculating the summary later
     90
     91            ifPScan.createAssign(pscan, ifPScan.createScanTo(adv_pending_lparen, in_play));
     92
     93//        body.createAssign(pscan, body.createScanTo(adv_pending_lparen, in_play));
     94
     95        body.createAssign(pending_lparen, body.createAnd(pscan, lparen));
     96
     97        PabloAST * closed_rparen = body.createAnd(pscan, rparen, "closed_rparen");
     98
     99        body.createAssign(all_closed, body.createOr(all_closed, closed_rparen));
     100
     101        // Mark any opening paren without a matching closer as an error.
     102        PabloAST * unmatched_lparen = body.createAtEOF(pscan, "unmatched_lparen");
     103
     104        body.createAssign(accumulated_errors, body.createOr(accumulated_errors, unmatched_lparen));
     105
     106        PabloAST * pending_rparen = body.createAnd(rparen, body.createNot(all_closed, "open_rparen"), "pending_rparen");
     107
     108        body.createAssign(in_play, body.createOr(pending_lparen, pending_rparen));
     109
     110        body.createAssign(body.createExtract(matches, index), closed_rparen);
     111
     112        body.createAssign(index, body.createAdd(index, body.getInteger(1)));
     113
     114    // Mark any closing paren that was not actually used to close an opener as an error.
     115    PabloAST * const unmatched_rparen = pb.createAnd(rparen, pb.createNot(all_closed), "unmatched_rparen");
     116    pb.createAssign(kernel->getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
     117
     118}
     119
     120
    47121//void generate(PabloKernel * kernel) {
    48122
     
    78152
    79153//    PabloBuilder body = PabloBuilder::Create(pb);
    80 //    PabloBuilder ifPScan = PabloBuilder::Create(body);
    81154
    82155//    pb.createWhile(pending_lparen, body);
     
    85158
    86159//        Var * closed_rparen = body.createVar("closed_rparen", pb.createZeroes());
     160
     161//        PabloBuilder ifPScan = PabloBuilder::Create(body);
    87162
    88163//        body.createIf(adv_pending_lparen, ifPScan); // <-- inefficient but tests whether we're probably calculating the summary later
     
    98173//            // Mark any opening paren without a matching closer as an error.
    99174//            PabloAST * unmatched_lparen = ifPScan.createAtEOF(pscan, "unmatched_lparen");
     175
    100176//            ifPScan.createAssign(accumulated_errors, ifPScan.createOr(accumulated_errors, unmatched_lparen));
    101177
     
    113189
    114190//}
    115 
    116 void generate(PabloKernel * kernel) {
    117 
    118     PabloBuilder pb(kernel->getEntryBlock());
    119 
    120     Var * input = kernel->getInputStreamVar("input");
    121 
    122     PabloAST * basis[8];
    123     for (int i = 0; i < 8; ++i) {
    124         basis[i] = pb.createExtract(input, i);
    125     }
    126 
    127     PabloAST * temp1 = pb.createOr(basis[0], basis[1], "temp1");
    128     PabloAST * temp2 = pb.createAnd(basis[2], pb.createNot(basis[3]), "temp2");
    129     PabloAST * temp3 = pb.createAnd(temp2, pb.createNot(temp1), "temp3");
    130     PabloAST * temp4 = pb.createAnd(basis[4], pb.createNot(basis[5]), "temp4");
    131     PabloAST * temp5 = pb.createOr(basis[6], basis[7], "temp5");
    132     PabloAST * temp6 = pb.createAnd(temp4, pb.createNot(temp5), "temp6");
    133     PabloAST * lparen = pb.createAnd(temp3, temp6, "lparens");
    134     PabloAST * temp7 = pb.createAnd(basis[7], pb.createNot(basis[6]), "temp7");
    135     PabloAST * temp8 = pb.createAnd(temp4, temp7, "temp8");
    136     PabloAST * rparen = pb.createAnd(temp3, temp8, "rparens");
    137     PabloAST * parens = pb.createOr(lparen, rparen, "parens");
    138 
    139 
    140     Var * const pending_lparen = pb.createVar("pending_lparen", lparen);
    141     Var * const all_closed = pb.createVar("all_closed", pb.createZeroes());
    142     Var * const accumulated_errors = pb.createVar("accumulated_errors", pb.createZeroes());
    143     Var * const in_play = pb.createVar("in_play", parens);
    144     Var * const index = pb.createVar("i", pb.getInteger(0));
    145 
    146     Var * matches = kernel->getOutputStreamVar("matches");
    147 
    148     PabloBuilder body = PabloBuilder::Create(pb);
    149     PabloBuilder ifPScan = PabloBuilder::Create(body);
    150 
    151     pb.createWhile(pending_lparen, body);
    152 
    153         PabloAST * pscan = body.createAdvanceThenScanTo(pending_lparen, in_play, "pscan");
    154 
    155         Var * closed_rparen = body.createVar("closed_rparen", pb.createZeroes());
    156 
    157         body.createAssign(pending_lparen, body.createAnd(pscan, lparen));
    158 
    159         body.createIf(pscan, ifPScan);
    160 
    161             ifPScan.createAssign(closed_rparen, ifPScan.createAnd(pscan, rparen));
    162 
    163             ifPScan.createAssign(all_closed, ifPScan.createOr(all_closed, closed_rparen));
    164 
    165             // Mark any opening paren without a matching closer as an error.
    166             PabloAST * unmatched_lparen = ifPScan.createAtEOF(pscan, "unmatched_lparen");
    167             ifPScan.createAssign(accumulated_errors, ifPScan.createOr(accumulated_errors, unmatched_lparen));
    168 
    169             PabloAST * pending_rparen = ifPScan.createAnd(rparen, ifPScan.createNot(all_closed, "open_rparen"), "pending_rparen");
    170 
    171             ifPScan.createAssign(in_play, ifPScan.createOr(pending_lparen, pending_rparen));
    172 
    173             ifPScan.createAssign(ifPScan.createExtract(matches, index), closed_rparen);
    174 
    175         body.createAssign(index, body.createAdd(index, body.getInteger(1)));
    176 
    177     // Mark any closing paren that was not actually used to close an opener as an error.
    178     PabloAST * const unmatched_rparen = pb.createAnd(rparen, pb.createNot(all_closed), "unmatched_rparen");
    179     pb.createAssign(kernel->getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
    180 
    181 }
    182191
    183192//void generate(PabloKernel * kernel) {
     
    219228//        PabloAST * pscan = body.createAdvanceThenScanTo(pending_lparen, in_play, "pscan");
    220229
     230//        Var * closed_rparen = body.createVar("closed_rparen", pb.createZeroes());
     231
     232//        body.createAssign(pending_lparen, body.createAnd(pscan, lparen));
     233
     234//        PabloBuilder ifPScan = PabloBuilder::Create(body);
     235
     236//        body.createIf(pscan, ifPScan);
     237
     238//            ifPScan.createAssign(closed_rparen, ifPScan.createAnd(pscan, rparen));
     239
     240//            ifPScan.createAssign(all_closed, ifPScan.createOr(all_closed, closed_rparen));
     241
     242//            // Mark any opening paren without a matching closer as an error.
     243//            PabloAST * unmatched_lparen = ifPScan.createAtEOF(pscan, "unmatched_lparen");
     244//            ifPScan.createAssign(accumulated_errors, ifPScan.createOr(accumulated_errors, unmatched_lparen));
     245
     246//            PabloAST * pending_rparen = ifPScan.createAnd(rparen, ifPScan.createNot(all_closed, "open_rparen"), "pending_rparen");
     247
     248//            ifPScan.createAssign(in_play, ifPScan.createOr(pending_lparen, pending_rparen));
     249
     250//            ifPScan.createAssign(ifPScan.createExtract(matches, index), closed_rparen);
     251
     252//        body.createAssign(index, body.createAdd(index, body.getInteger(1)));
     253
     254//    // Mark any closing paren that was not actually used to close an opener as an error.
     255//    PabloAST * const unmatched_rparen = pb.createAnd(rparen, pb.createNot(all_closed), "unmatched_rparen");
     256//    pb.createAssign(kernel->getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
     257
     258//}
     259
     260//void generate(PabloKernel * kernel) {
     261
     262//    PabloBuilder pb(kernel->getEntryBlock());
     263
     264//    Var * input = kernel->getInputStreamVar("input");
     265
     266//    PabloAST * basis[8];
     267//    for (int i = 0; i < 8; ++i) {
     268//        basis[i] = pb.createExtract(input, i);
     269//    }
     270
     271//    PabloAST * temp1 = pb.createOr(basis[0], basis[1], "temp1");
     272//    PabloAST * temp2 = pb.createAnd(basis[2], pb.createNot(basis[3]), "temp2");
     273//    PabloAST * temp3 = pb.createAnd(temp2, pb.createNot(temp1), "temp3");
     274//    PabloAST * temp4 = pb.createAnd(basis[4], pb.createNot(basis[5]), "temp4");
     275//    PabloAST * temp5 = pb.createOr(basis[6], basis[7], "temp5");
     276//    PabloAST * temp6 = pb.createAnd(temp4, pb.createNot(temp5), "temp6");
     277//    PabloAST * lparen = pb.createAnd(temp3, temp6, "lparens");
     278//    PabloAST * temp7 = pb.createAnd(basis[7], pb.createNot(basis[6]), "temp7");
     279//    PabloAST * temp8 = pb.createAnd(temp4, temp7, "temp8");
     280//    PabloAST * rparen = pb.createAnd(temp3, temp8, "rparens");
     281//    PabloAST * parens = pb.createOr(lparen, rparen, "parens");
     282
     283
     284//    Var * const pending_lparen = pb.createVar("pending_lparen", lparen);
     285//    Var * const all_closed = pb.createVar("all_closed", pb.createZeroes());
     286//    Var * const accumulated_errors = pb.createVar("accumulated_errors", pb.createZeroes());
     287//    Var * const in_play = pb.createVar("in_play", parens);
     288//    Var * const index = pb.createVar("i", pb.getInteger(0));
     289
     290//    Var * matches = kernel->getOutputStreamVar("matches");
     291
     292//    PabloBuilder body = PabloBuilder::Create(pb);
     293
     294//    pb.createWhile(pending_lparen, body);
     295
     296//        PabloAST * pscan = body.createAdvanceThenScanTo(pending_lparen, in_play, "pscan");
     297
    221298//        PabloAST * closed_rparen = body.createAnd(pscan, rparen, "closed_rparen");
    222299//        body.createAssign(all_closed, body.createOr(all_closed, closed_rparen));
     
    273350
    274351    generate(&bm);
    275     pablo_function_passes(&bm);
     352//    pablo_function_passes(&bm);
     353
     354    bm.getEntryBlock()->print(errs());
    276355
    277356    ExpandableBuffer matches(iBuilder, iBuilder->getStreamSetTy(count), segmentSize * bufferSegments);
     
    289368    matches.allocateBuffer();
    290369    errors.allocateBuffer();
     370
     371//    generatePipeline(iBuilder, {&mmapK, &s2pk, &bm});
    291372
    292373    generatePipeline(iBuilder, {&mmapK, &s2pk, &bm, &printer});
Note: See TracChangeset for help on using the changeset viewer.