Ignore:
Timestamp:
Jul 21, 2014, 6:12:48 PM (5 years ago)
Author:
linmengl
Message:

adding more unittests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib_ir/test_pack.cpp

    r3918 r3919  
    77int main(int argc, char **argv)
    88{
    9   SIMD_type a, b, c, d;
     9  SIMD_type a, b, c, d, e;
    1010
    1111  //Test packh_16
     
    1818    cout << Store2String(c,1) << endl;
    1919    cout << Store2String(d,1) << endl;
    20     cout << "Matching faild." << endl;
     20    cout << "packh_16 faild." << endl;
    2121    return 1;
    2222  }
     
    3131    cout << Store2String(c,1) << endl;
    3232    cout << Store2String(d,1) << endl;
    33     cout << "Matching faild." << endl;
     33    cout << "packl_16 faild." << endl;
    3434    return 1;
    3535  }
     36
     37  //Test ifh_1
     38  a = mvmd<32>::fill((int)rand() % 10000);
     39  b = mvmd<32>::fill((int)rand() % 1000);
     40  c = mvmd<32>::fill((int)rand() % 1000);
     41  d = ifh_1(a, b, c);
     42  e = simd<1>::ifh(a, b, c);
     43  if (Store2String(d,1) != Store2String(e,1)) {
     44    cout << "ifh_1 faild." << endl;
     45    return 1;
     46  }
     47
     48  //Test srli_16
     49  a = mvmd<32>::fill((int)rand() % 10000);
     50  b = mvmd<16>::fill(1);
     51  c = simd<16>::srli<1>(a);
     52  d = srli_16(a, b);
     53  if (Store2String(d,1) != Store2String(c,1)) {
     54    cout << "srli_16 faild." << endl;
     55    return 1;
     56  }
     57  a = mvmd<32>::fill((int)rand() % 10000);
     58  b = mvmd<16>::fill(2);
     59  c = simd<16>::srli<2>(a);
     60  d = srli_16(a, b);
     61  if (Store2String(d,1) != Store2String(c,1)) {
     62    cout << "srli_16 faild." << endl;
     63    return 1;
     64  }
     65
     66  //Test slli_16
     67  a = mvmd<32>::fill((int)rand() % 10000);
     68  b = mvmd<16>::fill(1);
     69  c = simd<16>::slli<1>(a);
     70  d = slli_16(a, b);
     71  if (Store2String(d,1) != Store2String(c,1)) {
     72    cout << "slli_16 faild." << endl;
     73    return 1;
     74  }
     75  a = mvmd<32>::fill((int)rand() % 10000);
     76  b = mvmd<16>::fill(2);
     77  c = simd<16>::slli<2>(a);
     78  d = slli_16(a, b);
     79  if (Store2String(d,1) != Store2String(c,1)) {
     80    cout << "slli_16 faild." << endl;
     81    return 1;
     82  }
     83
    3684
    3785  cout << "Test passed." << endl;
Note: See TracChangeset for help on using the changeset viewer.