Ignore:
Timestamp:
Mar 16, 2016, 8:58:33 AM (3 years ago)
Author:
cameron
Message:

Experimental s2p implementation using the s2p_ideal algorithm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/s2p_kernel.cpp

    r4974 r4976  
    6666}
    6767
     68void generateS2P_idealKernel(Module *, IDISA::IDISA_Builder * iBuilder, KernelBuilder * kBuilder) {
     69    kBuilder->addInputStream(8, "byte_pack");
     70    for(unsigned i = 0; i < 8; ++i) {
     71        kBuilder->addOutputStream(1);
     72    }
     73    kBuilder->prepareFunction();
     74    Value * input = kBuilder->getInputStream(0);
     75    Value * output[8];
     76    Value * hi_nybble[4];
     77    Value * lo_nybble[4];
     78    for (unsigned i = 0; i<4; i++) {
     79        Value * s0 = iBuilder->CreateBlockAlignedLoad(input, {iBuilder->getInt32(0), iBuilder->getInt32(2 * i)});
     80        Value * s1 = iBuilder->CreateBlockAlignedLoad(input, {iBuilder->getInt32(0), iBuilder->getInt32(2 * i + 1)});
     81        hi_nybble[i] = iBuilder->hsimd_packh(8, s0, s1);
     82        lo_nybble[i] = iBuilder->hsimd_packl(8, s0, s1);
     83    }
     84    Value * pair01[2];
     85    Value * pair23[2];
     86    Value * pair45[2];
     87    Value * pair67[2];
     88    for (unsigned i = 0; i<2; i++) {
     89        pair01[i] = iBuilder->hsimd_packh(4, hi_nybble[2*i], hi_nybble[2*i+1]);
     90        pair23[i] = iBuilder->hsimd_packl(4, hi_nybble[2*i], hi_nybble[2*i+1]);
     91        pair45[i] = iBuilder->hsimd_packh(4, lo_nybble[2*i], lo_nybble[2*i+1]);
     92        pair67[i] = iBuilder->hsimd_packl(4, lo_nybble[2*i], lo_nybble[2*i+1]);
     93    }
     94    output[0] = iBuilder->hsimd_packh(2, pair01[0], pair01[1]);
     95    output[1] = iBuilder->hsimd_packl(2, pair01[0], pair01[1]);
     96    output[2] = iBuilder->hsimd_packh(2, pair23[0], pair23[1]);
     97    output[3] = iBuilder->hsimd_packl(2, pair23[0], pair23[1]);
     98    output[4] = iBuilder->hsimd_packh(2, pair45[0], pair45[1]);
     99    output[5] = iBuilder->hsimd_packl(2, pair45[0], pair45[1]);
     100    output[6] = iBuilder->hsimd_packh(2, pair67[0], pair67[1]);
     101    output[7] = iBuilder->hsimd_packl(2, pair67[0], pair67[1]);
     102
     103    s2p(iBuilder, kBuilder->getInputStream(0), output);
     104    for (unsigned j = 0; j < 8; ++j) {
     105        iBuilder->CreateBlockAlignedStore(output[j], kBuilder->getOutputStream(j));
     106    }
     107    kBuilder->finalize();
    68108}
     109   
     110   
     111   
     112}
Note: See TracChangeset for help on using the changeset viewer.