0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

expandの逆をします。

これだけマスクの扱いが特殊ですね。マスクと対応する入力を拾ってきて、出力には下から詰めます。

#include <immintrin.h>
#include <stdio.h>

unsigned int in[16] = {100,101,102,103,
                       104,105,106,107,
                       108,109,110,111,
                       112,113,114,115
};

unsigned int out[16];

void test(__mmask16 mask)
{
    for (int i=0; i<16; i++) {
        out[i] = -1;
    }

    __m512i v = _mm512_loadu_si512(in);

    _mm512_mask_compressstoreu_epi32(out, mask, v);

    printf("0x%04x: ", mask);
    for (int i=0; i<16; i++) {
        printf("%3d, ", out[15-i]);
    }
    puts("");
}

int
main()
{
    printf("      | ");
    for (int i=0; i<16; i++) {
        printf("%3d, ", 15-i);
    }
    puts("\n---------------------------------------------------------------------------------------");

    test(1);
    test(0xaaaa);
    test(0x8888);
    test(0x0303);
    test(0x0462);
    test(0xffff);
}
      |  15,  14,  13,  12,  11,  10,   9,   8,   7,   6,   5,   4,   3,   2,   1,   0, 
---------------------------------------------------------------------------------------
0x0001:  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 100, 
0xaaaa:  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 115, 113, 111, 109, 107, 105, 103, 101, 
0x8888:  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 115, 111, 107, 103, 
0x0303:  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 109, 108, 101, 100, 
0x0462:  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 110, 106, 105, 101, 
0xffff: 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 

明日は @tanakmura が vpscatterdd について書きます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?