Ignore:
Timestamp:
Jun 9, 2016, 3:34:07 PM (3 years ago)
Author:
xuedongx
Message:

Support over UTF-16 representation of Unicode

File:
1 edited

Legend:

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

    r4986 r5045  
    2828}
    2929
    30 inline void s2p(IDISA::IDISA_Builder * iBuilder, Value * input, Value * output[]) {
     30void s2p(IDISA::IDISA_Builder * iBuilder, Value * input[], Value * output[]) {
    3131    Value * bit00224466[4];
    3232    Value * bit11335577[4];
    3333
    3434    for (unsigned i = 0; i < 4; i++) {
    35         Value * s0 = iBuilder->CreateBlockAlignedLoad(input, {iBuilder->getInt32(0), iBuilder->getInt32(2 * i)});
    36         Value * s1 = iBuilder->CreateBlockAlignedLoad(input, {iBuilder->getInt32(0), iBuilder->getInt32(2 * i + 1)});
     35        Value * s0 = input[2 * i];
     36        Value * s1 = input[2 * i + 1];
    3737        s2p_step(iBuilder, s0, s1, iBuilder->simd_himask(2), 1, bit00224466[i], bit11335577[i]);
    3838    }
     
    5151    s2p_step(iBuilder, bit22226666[0], bit22226666[1], iBuilder->simd_himask(8), 4, output[2], output[6]);
    5252    s2p_step(iBuilder, bit33337777[0], bit33337777[1], iBuilder->simd_himask(8), 4, output[3], output[7]);
     53}
     54
     55void s2p(IDISA::IDISA_Builder * iBuilder, Value * input, Value * output[]) {
     56    Value * bit[8];
     57    for (unsigned i = 0; i < 8; i++) {
     58        bit[i] = iBuilder->CreateBlockAlignedLoad(input, {iBuilder->getInt32(0), iBuilder->getInt32(i)});
     59    }
     60    s2p(iBuilder, bit, output);
    5361}
    5462
     
    7179}
    7280
     81void generateS2P_16Kernel(Module *, IDISA::IDISA_Builder * iBuilder, KernelBuilder * kBuilder) {
     82        kBuilder->addInputStream(16, "unit_pack");
     83        for(unsigned i = 0; i < 16; i++) {
     84                kBuilder->addOutputStream(1);
     85        }
     86        kBuilder->prepareFunction();
     87
     88    Value * ptr = kBuilder->getInputStream(0);
     89
     90    Value * lo[8];
     91    Value * hi[8];
     92    for (unsigned i = 0; i < 8; i++) {
     93        Value * s0 = iBuilder->CreateBlockAlignedLoad(ptr, {iBuilder->getInt32(0), iBuilder->getInt32(2 * i)});
     94        Value * s1 = iBuilder->CreateBlockAlignedLoad(ptr, {iBuilder->getInt32(0), iBuilder->getInt32(2 * i + 1)});
     95        lo[i] = iBuilder->hsimd_packl(16, s0, s1);
     96        hi[i] = iBuilder->hsimd_packh(16, s0, s1);
     97    }
     98
     99    Value * output[16];
     100    s2p(iBuilder, lo, output);
     101    s2p(iBuilder, hi, output + 8);
     102    for (unsigned j = 0; j < 16; j++) {
     103        iBuilder->CreateBlockAlignedStore(output[j], kBuilder->getOutputStream(j));
     104    }
     105    kBuilder->finalize();
     106}
     107       
    73108void generateS2P_idealKernel(Module *, IDISA::IDISA_Builder * iBuilder, KernelBuilder * kBuilder) {
    74109    kBuilder->addInputStream(8, "byte_pack");
Note: See TracChangeset for help on using the changeset viewer.