Changeset 328 for trunk/lib


Ignore:
Timestamp:
Nov 11, 2009, 3:47:55 PM (10 years ago)
Author:
cameron
Message:

Add simd<8>::mult, simd<32>::mult

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/sse_simd_t.h

    r318 r328  
    11/*  Idealized SIMD Operations with SSE versions
    2     Copyright (C) 2006, 2007, 2008, Robert D. Cameron and Dan Lin
     2    Copyright (C) 2006, 2007, 2008, 2009, Robert D. Cameron and Dan Lin
    33    Licensed to the public under the Open Software License 3.0.
    44    Licensed to International Characters Inc.
     
    340340}
    341341
    342 /* simd_mult for 16 bits only. */
     342/* simd_mult built-in for 16 bits only. */
    343343
    344344template<> inline SIMD_type simd<16>::mult(SIMD_type r1, SIMD_type r2) {return _mm_mullo_epi16(r1, r2);}
     345
     346
     347/* _mm_mul_epu2 is equivalent of simd<64>::mult<l,l>*/
     348template<> inline SIMD_type simd<32>::mult(SIMD_type r1, SIMD_type r2) {
     349        return simd_or(_mm_mul_epu32(r1, r2),
     350                       sisd::slli<32>(_mm_mul_epu32(sisd::srli<32>(r1), sisd::srli<32>(r2))));
     351}
     352
     353
     354template<>
     355inline SIMD_type simd<8>::mult(SIMD_type r1, SIMD_type r2){
     356        return simd_or(simd<16>::mult<h,x>(r1, simd_and(simd<16>::himask(), r2)),
     357                       simd<16>::mult<l,l>(r1, r2));
     358}
     359
     360
     361
     362
    345363
    346364/* simd_max for 8 bits only. */
     
    458476/* Half operand modifier functions.*/
    459477
    460 /* Half operand modifier*/
    461 /* Half operand modifier*/
    462478template <int fw, HOM_t m>
    463479struct SIMD {
     
    477493};
    478494
     495// Wish we could make this generic.
    479496//template <int fw>
    480497//struct SIMD<fw, h> {
     
    538555inline SIMD_type simd<fw>::mergel(SIMD_type r1, SIMD_type r2){
    539556        return simd<fw>::mergel(SIMD<fw,m1>::hom(r1),SIMD<fw,m2>::hom(r2));
     557
     558template<int fw> template <HOM_t m1, HOM_t m2>
     559inline SIMD_type simd<fw>::mult(SIMD_type r1, SIMD_type r2){
     560        return simd<fw>::mult(SIMD<fw,m1>::hom(r1),SIMD<fw,m2>::hom(r2));
    540561}
    541562
Note: See TracChangeset for help on using the changeset viewer.