source: icGREP/icgrep-devel/icgrep/kernels/deletion.cpp @ 4981

Last change on this file since 4981 was 4981, checked in by cameron, 3 years ago

Initial check-in for parallel prefix deletion

File size: 1.3 KB
Line 
1/*
2 *  Copyright (c) 2016 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 */
5
6
7std::vector<Value *> parallel_prefix_deletion_masks(IDISA::IDISA_Builder * iBuilder, unsigned fw, Value * del_mask) {
8    Value * m = iBuilder->simd_not(del_mask);
9    Value * mk = iBuilder->simd_slli(fw, del_mask, 1);
10    std::vector<Value *> move_masks;
11    for (unsigned shift = 1; shift < fw; shift *= 2) {
12        Value * mp = mk;
13        for (unsigned lookright = 1; lookright < fw; lookright *= 2) {
14            mp = iBuilder->simd_xor(mp, iBuilder->simd_slli(fw, mp, lookright));
15        }
16        Value * mv = iBuilder->simd_and(mp, m);
17        m = iBuilder->simd_or(iBuilder->simd_xor(m, mv), iBuilder->simd_srli(fw, mv, shift));
18        mk = iBuilder->simd_and(mk, iBuilder->simd_not(mp));
19        move_masks.push_back(mv);
20    }
21    return move_masks;
22}
23
24Value * apply_parallel_prefix_deletion(IDISA::IDISA_Builder * iBuilder, unsigned fw, Value * del_mask, std::vector<Value *> mv, Value * strm) {
25    Value * s = iBuilder->simd_and(strm, iBuilder->simd_not(del_mask));
26    for (unsigned i = 0; i < mv.size(); i++) {
27        unsigned shift = 1 << i;
28        Value * t = iBuilder->simd_and(s, mv[i]);
29        s = iBuilder->simd_or(iBuilder->simd_xor(s, t), iBuilder->simd_srli(fw, t, shift));
30    }
31    return s;
32}
33
34
Note: See TracBrowser for help on using the repository browser.