Changeset 5004


Ignore:
Timestamp:
Apr 7, 2016, 2:30:49 PM (18 months ago)
Author:
cameron
Message:

Add deletion kernel

File:
1 edited

Legend:

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

    r4981 r5004  
    44 */
    55
     6#include <kernels/kernel.h>
     7#include <kernels/deletion.h>
     8#include <IDISA/idisa_builder.h>
     9#include <llvm/IR/Value.h>
     10
     11namespace kernel {
    612
    713std::vector<Value *> parallel_prefix_deletion_masks(IDISA::IDISA_Builder * iBuilder, unsigned fw, Value * del_mask) {
     
    3238}
    3339
    34 
     40// Apply deletion to a set of stream_count input streams to produce a set of output streams.
     41// Kernel inputs: stream_count data streams plus one del_mask stream
     42void generateDeletionKernel(Module * m, IDISA::IDISA_Builder * iBuilder, unsigned fw, unsigned stream_count, KernelBuilder * kBuilder) {
     43   
     44    for(unsigned i = 0; i < stream_count; ++i) {
     45        kBuilder->addInputStream(1);
     46        kBuilder->addOutputStream(1);
     47    }
     48    kBuilder->addInputStream(1, "del_mask");
     49    kBuilder->prepareFunction();
     50   
     51    Value * del_mask = iBuilder->CreateBlockAlignedLoad(kBuilder->getInputStream(stream_count));
     52   
     53    std::vector<Value *> move_masks = parallel_prefix_deletion_masks(iBuilder, fw, del_mask);
     54    for (unsigned j = 0; j < stream_count; ++j) {
     55        Value * input = iBuilder->CreateBlockAlignedLoad(kBuilder->getInputStream(j));
     56        Value * output = apply_parallel_prefix_deletion(iBuilder, fw, del_mask, move_masks, input);
     57        iBuilder->CreateBlockAlignedStore(output, kBuilder->getOutputStream(j));
     58    }
     59    kBuilder->finalize();
     60}
     61}
Note: See TracChangeset for help on using the changeset viewer.