Skip to content

Commit

Permalink
Vector bitwise Tril tests
Browse files Browse the repository at this point in the history
This commit adds Tril test-cases for the vector bitwise operations in
VectorTest. Following operations are covered-
- Vector And
- Vector Or
- Vector Exclusive Or
- Vector Negation
- Vector Not

Signed-off-by: Md. Alvee Noor <mnoor@unb.ca>
  • Loading branch information
alvee-unb committed May 12, 2021
1 parent 7a37777 commit 9d8c4a2
Showing 1 changed file with 305 additions and 0 deletions.
305 changes: 305 additions & 0 deletions fvtest/compilertriltest/VectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,3 +542,308 @@ TEST_F(VectorTest, VDoubleDiv) {
EXPECT_DOUBLE_EQ(inputA[0] / inputB[0], output[0]); // Epsilon = 4ULP -- is this necessary?
EXPECT_DOUBLE_EQ(inputA[1] / inputB[1], output[1]); // Epsilon = 4ULP -- is this necessary?
}

TEST_F(VectorTest, VInt8And) {

auto inputTrees = "(method return= NoType args=[Address,Address,Address] "
" (block "
" (vstorei type=VectorInt8 offset=0 "
" (aload parm=0) "
" (vand "
" (vloadi type=VectorInt8 (aload parm=1)) "
" (vloadi type=VectorInt8 (aload parm=2)))) "
" (return))) ";

auto trees = parseString(inputTrees);

ASSERT_NOTNULL(trees);
//TODO: Re-enable this test on S390 after issue #1843 is resolved.
SKIP_ON_S390(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_S390X(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_RISCV(MissingImplementation);
SKIP_ON_POWER(MissingImplementation);
SKIP_ON_X86(MissingImplementation);
SKIP_ON_HAMMER(MissingImplementation);

Tril::DefaultCompiler compiler(trees);
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;


auto entry_point = compiler.getEntryPoint<void (*)(int8_t[],int8_t[],int8_t[])>();
// This test currently assumes 128bit SIMD

int8_t output[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int8_t inputA[] = {7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, 7};
int8_t inputB[] = {-14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, -14, 1};

entry_point(output,inputA,inputB);

for (int i = 0; i < (sizeof(output) / sizeof(*output)); i++) {
EXPECT_EQ(inputA[i] & inputB[i], output[i]);
}
}

TEST_F(VectorTest, VInt8Or) {

auto inputTrees = "(method return= NoType args=[Address,Address,Address] "
" (block "
" (vstorei type=VectorInt8 offset=0 "
" (aload parm=0) "
" (vor "
" (vloadi type=VectorInt8 (aload parm=1)) "
" (vloadi type=VectorInt8 (aload parm=2)))) "
" (return))) ";

auto trees = parseString(inputTrees);

ASSERT_NOTNULL(trees);
//TODO: Re-enable this test on S390 after issue #1843 is resolved.
SKIP_ON_S390(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_S390X(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_RISCV(MissingImplementation);
SKIP_ON_POWER(MissingImplementation);
SKIP_ON_X86(MissingImplementation);
SKIP_ON_HAMMER(MissingImplementation);

Tril::DefaultCompiler compiler(trees);
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;


auto entry_point = compiler.getEntryPoint<void (*)(int8_t[],int8_t[],int8_t[])>();
// This test currently assumes 128bit SIMD

int8_t output[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int8_t inputA[] = {7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, 7};
int8_t inputB[] = {-14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, -14, 1};

entry_point(output,inputA,inputB);

for (int i = 0; i < (sizeof(output) / sizeof(*output)); i++) {
EXPECT_EQ(inputA[i] | inputB[i], output[i]);
}
}

TEST_F(VectorTest, VInt8Xor) {

auto inputTrees = "(method return= NoType args=[Address,Address,Address] "
" (block "
" (vstorei type=VectorInt8 offset=0 "
" (aload parm=0) "
" (vxor "
" (vloadi type=VectorInt8 (aload parm=1)) "
" (vloadi type=VectorInt8 (aload parm=2)))) "
" (return))) ";

auto trees = parseString(inputTrees);

ASSERT_NOTNULL(trees);
//TODO: Re-enable this test on S390 after issue #1843 is resolved.
SKIP_ON_S390(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_S390X(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_RISCV(MissingImplementation);
SKIP_ON_POWER(MissingImplementation);
SKIP_ON_X86(MissingImplementation);
SKIP_ON_HAMMER(MissingImplementation);

Tril::DefaultCompiler compiler(trees);
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;


auto entry_point = compiler.getEntryPoint<void (*)(int8_t[],int8_t[],int8_t[])>();
// This test currently assumes 128bit SIMD

int8_t output[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int8_t inputA[] = {7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, 7};
int8_t inputB[] = {-14, -12, -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 12, -14, 1};

entry_point(output,inputA,inputB);

for (int i = 0; i < (sizeof(output) / sizeof(*output)); i++) {
EXPECT_EQ(inputA[i] ^ inputB[i], output[i]);
}
}

TEST_F(VectorTest, VInt8Neg) {

auto inputTrees = "(method return= NoType args=[Address,Address] "
" (block "
" (vstorei type=VectorInt8 offset=0 "
" (aload parm=0) "
" (vneg "
" (vloadi type=VectorInt8 (aload parm=1)))) "
" (return))) ";

auto trees = parseString(inputTrees);

ASSERT_NOTNULL(trees);
//TODO: Re-enable this test on S390 after issue #1843 is resolved.
SKIP_ON_S390(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_S390X(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_RISCV(MissingImplementation);
SKIP_ON_POWER(MissingImplementation);
SKIP_ON_X86(MissingImplementation);
SKIP_ON_HAMMER(MissingImplementation);

Tril::DefaultCompiler compiler(trees);
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;


auto entry_point = compiler.getEntryPoint<void (*)(int8_t[],int8_t[])>();
// This test currently assumes 128bit SIMD

int8_t output[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int8_t inputA[] = {7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, 7};

entry_point(output,inputA);

for (int i = 0; i < (sizeof(output) / sizeof(*output)); i++) {
EXPECT_EQ((-1) * inputA[i], output[i]);
}
}

TEST_F(VectorTest, VInt16Neg) {

auto inputTrees = "(method return= NoType args=[Address,Address] "
" (block "
" (vstorei type=VectorInt16 offset=0 "
" (aload parm=0) "
" (vneg "
" (vloadi type=VectorInt16 (aload parm=1)))) "
" (return))) ";

auto trees = parseString(inputTrees);

ASSERT_NOTNULL(trees);
//TODO: Re-enable this test on S390 after issue #1843 is resolved.
SKIP_ON_S390(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_S390X(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_RISCV(MissingImplementation);
SKIP_ON_POWER(MissingImplementation);
SKIP_ON_X86(MissingImplementation);
SKIP_ON_HAMMER(MissingImplementation);

Tril::DefaultCompiler compiler(trees);
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;


auto entry_point = compiler.getEntryPoint<void (*)(int16_t[],int16_t[])>();
// This test currently assumes 128bit SIMD

int16_t output[] = {0, 0, 0, 0, 0, 0, 0, 0};
int16_t inputA[] = {60, 45, 30, 0, -3, -2, -1, 2};

entry_point(output,inputA);

for (int i = 0; i < (sizeof(output) / sizeof(*output)); i++) {
EXPECT_EQ((-1) * inputA[i], output[i]);
}
}

TEST_F(VectorTest, VFloatNeg) {

auto inputTrees = "(method return= NoType args=[Address,Address] "
" (block "
" (vstorei type=VectorFloat offset=0 "
" (aload parm=0) "
" (vneg "
" (vloadi type=VectorFloat (aload parm=1)))) "
" (return))) ";

auto trees = parseString(inputTrees);

ASSERT_NOTNULL(trees);
//TODO: Re-enable this test on S390 after issue #1843 is resolved.
SKIP_ON_S390(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_S390X(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_RISCV(MissingImplementation);
SKIP_ON_X86(MissingImplementation);
SKIP_ON_HAMMER(MissingImplementation);

Tril::DefaultCompiler compiler(trees);
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;


auto entry_point = compiler.getEntryPoint<void (*)(float[],float[])>();
// This test currently assumes 128bit SIMD

float output[] = {0.0f, 0.0f, 0.0f, 0.0f};
float inputA[] = {6.0f, 0.0f, -9.0f, 0.6f};

entry_point(output,inputA);

for (int i = 0; i < (sizeof(output) / sizeof(*output)); i++) {
EXPECT_EQ((-1) * inputA[i], output[i]);
}
}

TEST_F(VectorTest, VDoubleNeg) {

auto inputTrees = "(method return= NoType args=[Address,Address] "
" (block "
" (vstorei type=VectorDouble offset=0 "
" (aload parm=0) "
" (vneg "
" (vloadi type=VectorDouble (aload parm=1)))) "
" (return))) ";

auto trees = parseString(inputTrees);

ASSERT_NOTNULL(trees);
//TODO: Re-enable this test on S390 after issue #1843 is resolved.
SKIP_ON_S390(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_S390X(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_RISCV(MissingImplementation);
SKIP_ON_X86(MissingImplementation);
SKIP_ON_HAMMER(MissingImplementation);

Tril::DefaultCompiler compiler(trees);
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;


auto entry_point = compiler.getEntryPoint<void (*)(double[],double[])>();
// This test currently assumes 128bit SIMD

double output[] = {0.0, 0.0};
double inputA[] = {12.0, -1.5};

entry_point(output,inputA);
EXPECT_DOUBLE_EQ((-1) * inputA[0], output[0]); // Epsilon = 4ULP -- is this necessary?
EXPECT_DOUBLE_EQ((-1) * inputA[1], output[1]); // Epsilon = 4ULP -- is this necessary?
}

TEST_F(VectorTest, VInt8Not) {

auto inputTrees = "(method return= NoType args=[Address,Address] "
" (block "
" (vstorei type=VectorInt8 offset=0 "
" (aload parm=0) "
" (vnot "
" (vloadi type=VectorInt8 (aload parm=1)))) "
" (return))) ";

auto trees = parseString(inputTrees);

ASSERT_NOTNULL(trees);
//TODO: Re-enable this test on S390 after issue #1843 is resolved.
SKIP_ON_S390(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_S390X(KnownBug) << "This test is currently disabled on Z platforms because not all Z platforms have vector support (issue #1843)";
SKIP_ON_RISCV(MissingImplementation);
SKIP_ON_X86(MissingImplementation);
SKIP_ON_HAMMER(MissingImplementation);

Tril::DefaultCompiler compiler(trees);
ASSERT_EQ(0, compiler.compile()) << "Compilation failed unexpectedly\n" << "Input trees: " << inputTrees;


auto entry_point = compiler.getEntryPoint<void (*)(int8_t[],int8_t[])>();
// This test currently assumes 128bit SIMD

int8_t output[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int8_t inputA[] = {7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, 7};

entry_point(output,inputA);

for (int i = 0; i < (sizeof(output) / sizeof(*output)); i++) {
EXPECT_EQ(~inputA[i], output[i]);
}
}

0 comments on commit 9d8c4a2

Please sign in to comment.