Changeset 4050


Ignore:
Timestamp:
Aug 19, 2014, 8:09:59 PM (4 years ago)
Author:
linmengl
Message:

add p2s.ll file, p2s_step works now

Location:
trunk/lib_ir
Files:
4 added
1 deleted
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/lib_ir/CMakeLists.txt

    r4044 r4050  
    1818set(CMAKE_CXX_FLAGS "${CXX_SSE_FLAGS} -std=c++11 ")
    1919
     20set(LL_SOURCE_FILES s2p.ll p2s.ll)
     21if (USE_AVX2)
     22  #append s2p_ideal.ll to source list
     23  set(LL_SOURCE_FILES {LL_SOURCE_FILES} s2p_ideal.ll)
     24endif (USE_AVX2)
     25
    2026set(LLVM_OPT "opt-svn")
    2127set(LLVM_LLC "llc-svn")
     28set(LLVM_LINK "llvm-link")
    2229
    23 set(LLVM_LLC_FLAGS )#-x86-experimental-vector-shuffle-lowering)
    24 
    25 add_executable(test_s2p test_s2p.cpp s2p_optimized.o)
    26 add_executable(test_link test_link.cpp s2p_optimized.o)
    27 add_executable(test_pack test_pack.cpp s2p_optimized.o)
     30add_executable(test_s2p test_s2p.cpp ir_impl.o)
     31add_executable(test_link test_link.cpp ir_impl.o)
     32add_executable(test_pack test_pack.cpp ir_impl.o)
    2833
    2934# gen/ is used to test llc backend.
     
    3237# test packh_2,4,8 only on avx2
    3338if (USE_AVX2)
    34     add_executable(test_pack_avx2 test_pack_avx2.cpp s2p_optimized.o)
     39    add_executable(test_pack_avx2 test_pack_avx2.cpp ir_impl.o)
    3540    add_test(
    3641      NAME ctest_pack_avx2
     
    3944
    4045include_directories("xmlwf/util" "xmlwf/lib")
    41 add_executable(xmlwf xmlwf/src/xmlwf.cpp s2p_optimized.o)
     46add_executable(xmlwf xmlwf/src/xmlwf.cpp ir_impl.o)
    4247
    4348# xmlwf_perf compiles with additional flags and is only used for the perf_xmlwf
    4449# targets below.
    45 add_executable(xmlwf_perf xmlwf/src/xmlwf.cpp s2p_optimized.o)
     50add_executable(xmlwf_perf xmlwf/src/xmlwf.cpp ir_impl.o)
    4651set_target_properties(xmlwf_perf
    4752  PROPERTIES
     
    4954  )
    5055
    51 add_executable(u8u16 u8u16/src/u8u16.cpp s2p_optimized.o)
     56add_executable(u8u16 u8u16/src/u8u16.cpp ir_impl.o)
    5257
    53 add_custom_target(asm_s2p
    54   COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} s2p_optimized.bc
    55   DEPENDS s2p_optimized.bc)
     58add_custom_target(asm
     59  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} ir_impl_opt.bc
     60  DEPENDS ir_impl_opt.bc)
    5661
    57 # a little bit tricky here, on USE_AVX2, we need to append s2p_ideal.ll to s2p.ll
    58 # in order to have function s2p_ideal
    59 if (USE_AVX2)
    60   message("---- Concat s2p.ll with s2p_ideal.ll")
    61   add_custom_command(
    62     OUTPUT s2p.ll
    63     COMMAND cp ${PROJECT_SOURCE_DIR}/s2p.ll .
    64     COMMAND cat ${PROJECT_SOURCE_DIR}/s2p_ideal.ll >> s2p.ll
    65     DEPENDS ${PROJECT_SOURCE_DIR}/s2p.ll ${PROJECT_SOURCE_DIR}/s2p_ideal.ll)
     62# link ll source files together into ir_impl.bc
     63message("---- Link ${LL_SOURCE_FILES} ----")
     64add_custom_command(
     65  OUTPUT  ir_impl.bc
     66  COMMAND ${LLVM_LINK} ${LL_SOURCE_FILES} -o ${CMAKE_BINARY_DIR}/ir_impl.bc
     67  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
     68  DEPENDS ${LL_SOURCE_FILES})
    6669
    67 else (USE_AVX2)
    68   add_custom_command(
    69     OUTPUT s2p.ll
    70     COMMAND cp ${PROJECT_SOURCE_DIR}/s2p.ll .
    71     DEPENDS ${PROJECT_SOURCE_DIR}/s2p.ll)
    72 
    73 endif (USE_AVX2)
    74 
    75 # compile s2p.ll, and make sure test_s2p depends on it.
     70# compile ir_impl.bc
    7671add_custom_command(
    77   OUTPUT  s2p_optimized.o s2p_optimized.bc
    78   COMMAND ${LLVM_OPT} -O3 -std-compile-opts ${LLVM_SSE_FLAGS} s2p.ll -o s2p_optimized.bc
    79   COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj s2p_optimized.bc
    80   DEPENDS s2p.ll)
     72  OUTPUT  ir_impl.o ir_impl_opt.bc
     73  COMMAND ${LLVM_OPT} -O3 -std-compile-opts ${LLVM_SSE_FLAGS} ir_impl.bc -o ir_impl_opt.bc
     74  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj ir_impl_opt.bc -o ir_impl.o
     75  DEPENDS ir_impl.bc)
    8176
    8277add_test(
     
    10095  COMMAND ${CMAKE_CTEST_COMMAND}
    10196  DEPENDS test_s2p test_link test_pack test_llc xmlwf u8u16)
    102 
    10397
    10498# `make check` also depends on test_pack_avx2
  • trunk/lib_ir/s2p.h

    r3970 r4050  
    22#define S2P_H
    33
    4 #include "idisa.hpp"
     4#include "ir_common.h"
    55
    66extern "C" {
    7 
    8   //Implemented in s2p.ll
    9   BitBlock packh_16(BitBlock a, BitBlock b);
    10   BitBlock packl_16(BitBlock a, BitBlock b);
    11 
    12   BitBlock ifh_1(BitBlock a, BitBlock b, BitBlock c);
    13   BitBlock srli_16(BitBlock a, BitBlock shift_mask);
    14   BitBlock slli_16(BitBlock a, BitBlock shift_mask);
    15 
    167  void s2p_step_ir(BitBlock s0, BitBlock s1, BitBlock hi_mask, BitBlock shift_mask, BitBlock *p0, BitBlock *p1);
    178
    189  void s2p_bytepack_ir(BitBlock s0, BitBlock s1, BitBlock s2, BitBlock s3, BitBlock s4, BitBlock s5, BitBlock s6, BitBlock s7, BitBlock* p0, BitBlock* p1, BitBlock* p2, BitBlock* p3, BitBlock* p4, BitBlock* p5, BitBlock* p6, BitBlock* p7);
    19 
    20   BitBlock const16_1();
    21   BitBlock const16_2();
    22   BitBlock const16_4();
    23 
    24   BitBlock himask_2();
    25   BitBlock himask_4();
    26   BitBlock himask_8();
    27 
    28   /////////////////////////////////////////
    29   //Implemented in s2p_ideal.ll, which can only be compiled on Haswell.
    30   BitBlock packh_8(BitBlock a, BitBlock b);
    31   BitBlock packl_8(BitBlock a, BitBlock b);
    32 
    33   BitBlock packh_4(BitBlock a, BitBlock b);
    34   BitBlock packl_4(BitBlock a, BitBlock b);
    35 
    36   BitBlock packh_2(BitBlock a, BitBlock b);
    37   BitBlock packl_2(BitBlock a, BitBlock b);
    3810
    3911  void s2p_ideal_ir(BitBlock s0, BitBlock s1, BitBlock s2, BitBlock s3, BitBlock s4, BitBlock s5, BitBlock s6, BitBlock s7, BitBlock *p0, BitBlock *p1, BitBlock *p2, BitBlock *p3, BitBlock *p4, BitBlock *p5, BitBlock *p6, BitBlock *p7);
  • trunk/lib_ir/test_pack.cpp

    r3922 r4050  
    22#include "s2p.h"
    33#include "s2p_back.hpp"
     4#include "p2s.h"
     5#include "p2s_back.hpp"
     6#include "ir_common.h"
    47#include <iostream>
    58#include <cstdlib>
     
    1013  SIMD_type a, b, c, d, e;
    1114
    12   //Test packh_16
    13   a = mvmd<32>::fill((int)rand() % 10000);
    14   b = mvmd<32>::fill((int)rand() % 1000);
    15   c = hsimd<16>::packh(a, b);
    16   d = packh_16(a, b);
     15  for (unsigned i = 0; i < 50; i++) {
     16    //Test packh_16
     17    a = mvmd<32>::fill((int)rand() % 10000);
     18    b = mvmd<32>::fill((int)rand() % 1000);
     19    c = hsimd<16>::packh(a, b);
     20    d = packh_16(a, b);
    1721
    18   if (Store2String(c,1) != Store2String(d,1)) {
    19     cout << Store2String(c,1) << endl;
    20     cout << Store2String(d,1) << endl;
    21     cout << "packh_16 faild." << endl;
    22     return 1;
    23   }
     22    if (Store2String(c,1) != Store2String(d,1)) {
     23      cout << Store2String(c,1) << endl;
     24      cout << Store2String(d,1) << endl;
     25      cout << "packh_16 faild." << endl;
     26      return 1;
     27    }
    2428
    25   //Test packl_16
    26   a = mvmd<32>::fill((int)rand() % 10000);
    27   b = mvmd<32>::fill((int)rand() % 1000);
    28   c = hsimd<16>::packl(a, b);
    29   d = packl_16(a, b);
     29    //Test packl_16
     30    a = mvmd<32>::fill((int)rand() % 10000);
     31    b = mvmd<32>::fill((int)rand() % 1000);
     32    c = hsimd<16>::packl(a, b);
     33    d = packl_16(a, b);
    3034
    31   if (Store2String(c,1) != Store2String(d,1)) {
    32     cout << Store2String(c,1) << endl;
    33     cout << Store2String(d,1) << endl;
    34     cout << "packl_16 faild." << endl;
    35     return 1;
    36   }
     35    if (Store2String(c,1) != Store2String(d,1)) {
     36      cout << Store2String(c,1) << endl;
     37      cout << Store2String(d,1) << endl;
     38      cout << "packl_16 faild." << endl;
     39      return 1;
     40    }
    3741
    38   //Test ifh_1
    39   a = mvmd<32>::fill((int)rand() % 10000);
    40   b = mvmd<32>::fill((int)rand() % 1000);
    41   c = mvmd<32>::fill((int)rand() % 1000);
    42   d = ifh_1(a, b, c);
    43   e = simd<1>::ifh(a, b, c);
    44   if (Store2String(d,1) != Store2String(e,1)) {
    45     cout << "ifh_1 faild." << endl;
    46     return 1;
    47   }
     42    //Test ifh_1
     43    a = mvmd<32>::fill((int)rand() % 10000);
     44    b = mvmd<32>::fill((int)rand() % 1000);
     45    c = mvmd<32>::fill((int)rand() % 1000);
     46    d = ifh_1(a, b, c);
     47    e = simd<1>::ifh(a, b, c);
     48    if (Store2String(d,1) != Store2String(e,1)) {
     49      cout << "ifh_1 faild." << endl;
     50      return 1;
     51    }
    4852
    49   //Test srli_16
    50   a = mvmd<32>::fill((int)rand() % 10000);
    51   b = mvmd<16>::fill(1);
    52   c = simd<16>::srli<1>(a);
    53   d = srli_16(a, b);
    54   if (Store2String(d,1) != Store2String(c,1)) {
    55     cout << "srli_16 faild." << endl;
    56     return 1;
    57   }
    58   a = mvmd<32>::fill((int)rand() % 10000);
    59   b = mvmd<16>::fill(2);
    60   c = simd<16>::srli<2>(a);
    61   d = srli_16(a, b);
    62   if (Store2String(d,1) != Store2String(c,1)) {
    63     cout << "srli_16 faild." << endl;
    64     return 1;
    65   }
     53    //Test srli_16
     54    a = mvmd<32>::fill((int)rand() % 10000);
     55    b = mvmd<16>::fill(1);
     56    c = simd<16>::srli<1>(a);
     57    d = srli_16(a, b);
     58    if (Store2String(d,1) != Store2String(c,1)) {
     59      cout << "srli_16 faild." << endl;
     60      return 1;
     61    }
     62    a = mvmd<32>::fill((int)rand() % 10000);
     63    b = mvmd<16>::fill(2);
     64    c = simd<16>::srli<2>(a);
     65    d = srli_16(a, b);
     66    if (Store2String(d,1) != Store2String(c,1)) {
     67      cout << "srli_16 faild." << endl;
     68      return 1;
     69    }
    6670
    67   //Test slli_16
    68   a = mvmd<32>::fill((int)rand() % 10000);
    69   b = mvmd<16>::fill(1);
    70   c = simd<16>::slli<1>(a);
    71   d = slli_16(a, b);
    72   if (Store2String(d,1) != Store2String(c,1)) {
    73     cout << "slli_16 faild." << endl;
    74     return 1;
    75   }
    76   a = mvmd<32>::fill((int)rand() % 10000);
    77   b = mvmd<16>::fill(2);
    78   c = simd<16>::slli<2>(a);
    79   d = slli_16(a, b);
    80   if (Store2String(d,1) != Store2String(c,1)) {
    81     cout << "slli_16 faild." << endl;
    82     return 1;
    83   }
     71    //Test slli_16
     72    a = mvmd<32>::fill((int)rand() % 10000);
     73    b = mvmd<16>::fill(1);
     74    c = simd<16>::slli<1>(a);
     75    d = slli_16(a, b);
     76    if (Store2String(d,1) != Store2String(c,1)) {
     77      cout << "slli_16 faild." << endl;
     78      return 1;
     79    }
     80    a = mvmd<32>::fill((int)rand() % 10000);
     81    b = mvmd<16>::fill(2);
     82    c = simd<16>::slli<2>(a);
     83    d = slli_16(a, b);
     84    if (Store2String(d,1) != Store2String(c,1)) {
     85      cout << "slli_16 faild." << endl;
     86      return 1;
     87    }
    8488
    85   //Test s2p_step
    86   SIMD_type hi_mask = simd<2>::himask(), p0, p1, q0, q1;
    87   a = mvmd<32>::fill((int)rand() % 10000);
    88   b = mvmd<32>::fill((int)rand() % 10000);
    89   c = mvmd<16>::fill(2);
    90   s2p_step(a, b, hi_mask, 2, p0, p1);
    91   s2p_step_ir(a, b, hi_mask, c, &q0, &q1);
    92   if (Store2String(p0,1) != Store2String(q0,1) ||
    93       Store2String(p1,1) != Store2String(q1,1)) {
    94     cout << "s2p_step failed." << endl;
    95     return 1;
    96   }
    97   a = mvmd<32>::fill((int)rand() % 10000);
    98   b = mvmd<32>::fill((int)rand() % 10000);
    99   c = mvmd<16>::fill(4);
    100   s2p_step(a, b, hi_mask, 4, p0, p1);
    101   s2p_step_ir(a, b, hi_mask, c, &q0, &q1);
    102   if (Store2String(p0,1) != Store2String(q0,1) ||
    103       Store2String(p1,1) != Store2String(q1,1)) {
    104     cout << "s2p_step failed." << endl;
    105     return 1;
     89    //Test s2p_step
     90    SIMD_type hi_mask = simd<2>::himask(), p0, p1, q0, q1;
     91    a = mvmd<32>::fill((int)rand() % 10000);
     92    b = mvmd<32>::fill((int)rand() % 10000);
     93    c = mvmd<16>::fill(2);
     94    s2p_step(a, b, hi_mask, 2, p0, p1);
     95    s2p_step_ir(a, b, hi_mask, c, &q0, &q1);
     96    if (Store2String(p0,1) != Store2String(q0,1) ||
     97        Store2String(p1,1) != Store2String(q1,1)) {
     98      cout << "s2p_step failed." << endl;
     99      return 1;
     100    }
     101    a = mvmd<32>::fill((int)rand() % 10000);
     102    b = mvmd<32>::fill((int)rand() % 10000);
     103    c = mvmd<16>::fill(4);
     104    s2p_step(a, b, hi_mask, 4, p0, p1);
     105    s2p_step_ir(a, b, hi_mask, c, &q0, &q1);
     106    if (Store2String(p0,1) != Store2String(q0,1) ||
     107        Store2String(p1,1) != Store2String(q1,1)) {
     108      cout << "s2p_step failed." << endl;
     109      return 1;
     110    }
     111
     112    //Test esimd<8>::mergeh
     113    c = mergeh_8(a, b);
     114    d = esimd<8>::mergeh(a, b);
     115    if (Store2String(c,1) != Store2String(d,1)) {
     116      cout << "mergh8 failed." << endl;
     117      return 1;
     118    }
     119
     120    //Test esimd<8>::mergel
     121    c = mergel_8(a, b);
     122    d = esimd<8>::mergel(a, b);
     123    if (Store2String(c,1) != Store2String(d,1)) {
     124      cout << "mergl8 failed." << endl;
     125      return 1;
     126    }
     127
     128    //Test p2s_step
     129    p2s_step_ir(a, b, simd<8>::himask(), mvmd<16>::fill(1), &p0, &p1);
     130    p2s_step(a, b, simd<8>::himask(), 1, q0, q1);
     131    if (Store2String(p0,1) != Store2String(q0,1) ||
     132        Store2String(p1,1) != Store2String(q1,1)) {
     133      cout << "p2s_step failed." << endl;
     134      return 1;
     135    }
     136    p2s_step_ir(a, b, simd<8>::himask(), mvmd<16>::fill(2), &p0, &p1);
     137    p2s_step(a, b, simd<8>::himask(), 2, q0, q1);
     138    if (Store2String(p0,1) != Store2String(q0,1) ||
     139        Store2String(p1,1) != Store2String(q1,1)) {
     140      cout << "p2s_step failed." << endl;
     141      return 1;
     142    }
     143    p2s_step_ir(a, b, simd<8>::himask(), mvmd<16>::fill(4), &p0, &p1);
     144    p2s_step(a, b, simd<8>::himask(), 4, q0, q1);
     145    if (Store2String(p0,1) != Store2String(q0,1) ||
     146        Store2String(p1,1) != Store2String(q1,1)) {
     147      cout << "p2s_step failed." << endl;
     148      return 1;
     149    }
    106150  }
    107151
  • trunk/lib_ir/u8u16/src/u8u16.cpp

    r4042 r4050  
    1111
    1212#include <simd-lib/s2p.h>
    13 #include <simd-lib/p2s.hpp>
     13#include <simd-lib/p2s_back.hpp>
    1414
    1515#define minimum(x,y) ((x) <(y) ?(x) :(y) )
Note: See TracChangeset for help on using the changeset viewer.