Ignore:
Timestamp:
Mar 16, 2017, 4:57:11 PM (2 years ago)
Author:
nmedfort
Message:

Continued work on non-carry-collapsing mode support.

File:
1 edited

Legend:

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

    r5364 r5366  
    4545static cl::list<std::string> inputFiles(cl::Positional, cl::desc("<input file ...>"), cl::OneOrMore);
    4646
     47//void 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//    PabloBuilder ifPScan = PabloBuilder::Create(body);
     81
     82//    pb.createWhile(pending_lparen, body);
     83
     84//        PabloAST * adv_pending_lparen = body.createAdvance(pending_lparen, 1);
     85
     86//        Var * closed_rparen = body.createVar("closed_rparen", pb.createZeroes());
     87
     88//        body.createIf(adv_pending_lparen, ifPScan); // <-- inefficient but tests whether we're probably calculating the summary later
     89
     90//            PabloAST * pscan = ifPScan.createScanTo(adv_pending_lparen, in_play, "pscan");
     91
     92//            ifPScan.createAssign(pending_lparen, ifPScan.createAnd(pscan, lparen));
     93
     94//            ifPScan.createAssign(closed_rparen, ifPScan.createAnd(pscan, rparen));
     95
     96//            ifPScan.createAssign(all_closed, ifPScan.createOr(all_closed, closed_rparen));
     97
     98//            // Mark any opening paren without a matching closer as an error.
     99//            PabloAST * unmatched_lparen = ifPScan.createAtEOF(pscan, "unmatched_lparen");
     100//            ifPScan.createAssign(accumulated_errors, ifPScan.createOr(accumulated_errors, unmatched_lparen));
     101
     102//            PabloAST * pending_rparen = ifPScan.createAnd(rparen, ifPScan.createNot(all_closed, "open_rparen"), "pending_rparen");
     103
     104//            ifPScan.createAssign(in_play, ifPScan.createOr(pending_lparen, pending_rparen));
     105
     106//        body.createAssign(body.createExtract(matches, index), closed_rparen);
     107
     108//        body.createAssign(index, body.createAdd(index, body.getInteger(1)));
     109
     110//    // Mark any closing paren that was not actually used to close an opener as an error.
     111//    PabloAST * const unmatched_rparen = pb.createAnd(rparen, pb.createNot(all_closed), "unmatched_rparen");
     112//    pb.createAssign(kernel->getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
     113
     114//}
     115
    47116void generate(PabloKernel * kernel) {
    48117
     
    78147
    79148    PabloBuilder body = PabloBuilder::Create(pb);
     149    PabloBuilder ifPScan = PabloBuilder::Create(body);
    80150
    81151    pb.createWhile(pending_lparen, body);
     
    83153        PabloAST * pscan = body.createAdvanceThenScanTo(pending_lparen, in_play, "pscan");
    84154
    85         PabloAST * closed = body.createAnd(pscan, rparen, "closed_rparen");
    86         body.createAssign(all_closed, body.createOr(all_closed, closed));
     155        Var * closed_rparen = body.createVar("closed_rparen", pb.createZeroes());
    87156
    88157        body.createAssign(pending_lparen, body.createAnd(pscan, lparen));
    89         // Mark any opening paren without a matching closer as an error.
    90         PabloAST * unmatched_lparen = body.createAtEOF(pscan, "unmatched_lparen");
    91         body.createAssign(accumulated_errors, body.createOr(accumulated_errors, unmatched_lparen));
    92 
    93         body.createAssign(body.createExtract(matches, index), closed);
    94 
    95         PabloAST * pending_rparen = body.createAnd(rparen, body.createNot(all_closed, "open_rparen"), "pending_rparen");
    96         body.createAssign(in_play, body.createOr(pending_lparen, pending_rparen));
     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
    97175        body.createAssign(index, body.createAdd(index, body.getInteger(1)));
    98176
     
    102180
    103181}
     182
     183//void generate(PabloKernel * kernel) {
     184
     185//    PabloBuilder pb(kernel->getEntryBlock());
     186
     187//    Var * input = kernel->getInputStreamVar("input");
     188
     189//    PabloAST * basis[8];
     190//    for (int i = 0; i < 8; ++i) {
     191//        basis[i] = pb.createExtract(input, i);
     192//    }
     193
     194//    PabloAST * temp1 = pb.createOr(basis[0], basis[1], "temp1");
     195//    PabloAST * temp2 = pb.createAnd(basis[2], pb.createNot(basis[3]), "temp2");
     196//    PabloAST * temp3 = pb.createAnd(temp2, pb.createNot(temp1), "temp3");
     197//    PabloAST * temp4 = pb.createAnd(basis[4], pb.createNot(basis[5]), "temp4");
     198//    PabloAST * temp5 = pb.createOr(basis[6], basis[7], "temp5");
     199//    PabloAST * temp6 = pb.createAnd(temp4, pb.createNot(temp5), "temp6");
     200//    PabloAST * lparen = pb.createAnd(temp3, temp6, "lparens");
     201//    PabloAST * temp7 = pb.createAnd(basis[7], pb.createNot(basis[6]), "temp7");
     202//    PabloAST * temp8 = pb.createAnd(temp4, temp7, "temp8");
     203//    PabloAST * rparen = pb.createAnd(temp3, temp8, "rparens");
     204//    PabloAST * parens = pb.createOr(lparen, rparen, "parens");
     205
     206
     207//    Var * const pending_lparen = pb.createVar("pending_lparen", lparen);
     208//    Var * const all_closed = pb.createVar("all_closed", pb.createZeroes());
     209//    Var * const accumulated_errors = pb.createVar("accumulated_errors", pb.createZeroes());
     210//    Var * const in_play = pb.createVar("in_play", parens);
     211//    Var * const index = pb.createVar("i", pb.getInteger(0));
     212
     213//    Var * matches = kernel->getOutputStreamVar("matches");
     214
     215//    PabloBuilder body = PabloBuilder::Create(pb);
     216
     217//    pb.createWhile(pending_lparen, body);
     218
     219//        PabloAST * pscan = body.createAdvanceThenScanTo(pending_lparen, in_play, "pscan");
     220
     221//        PabloAST * closed_rparen = body.createAnd(pscan, rparen, "closed_rparen");
     222//        body.createAssign(all_closed, body.createOr(all_closed, closed_rparen));
     223
     224//        body.createAssign(pending_lparen, body.createAnd(pscan, lparen));
     225//        // Mark any opening paren without a matching closer as an error.
     226//        PabloAST * unmatched_lparen = body.createAtEOF(pscan, "unmatched_lparen");
     227//        body.createAssign(accumulated_errors, body.createOr(accumulated_errors, unmatched_lparen));
     228
     229//        body.createAssign(body.createExtract(matches, index), closed_rparen);
     230
     231//        PabloAST * pending_rparen = body.createAnd(rparen, body.createNot(all_closed, "open_rparen"), "pending_rparen");
     232//        body.createAssign(in_play, body.createOr(pending_lparen, pending_rparen));
     233//        body.createAssign(index, body.createAdd(index, body.getInteger(1)));
     234
     235//    // Mark any closing paren that was not actually used to close an opener as an error.
     236//    PabloAST * const unmatched_rparen = pb.createAnd(rparen, pb.createNot(all_closed), "unmatched_rparen");
     237//    pb.createAssign(kernel->getOutputStreamVar("errors"), pb.createOr(accumulated_errors, unmatched_rparen));
     238
     239//}
    104240
    105241Function * pipeline(IDISA::IDISA_Builder * iBuilder, const unsigned count) {
Note: See TracChangeset for help on using the changeset viewer.