Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • static_index
2 results

common.hxx

Blame
  • sve_int.hpp 3.94 KiB
    /*
    
       Copyright (C) 2019, Forschungszentrum Juelich
    
       Author(s): Bine Brank, b.brank@fz-juelich.de
    
       Redistribution and use in source and binary forms, with or without
       modification, are permitted provided that the following conditions are
       met:
        - Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.
        - Redistributions in binary form must reproduce the above copyright
          notice, this list of conditions and the following disclaimer in the
          documentation and/or other materials provided with the distribution.
        - Neither the name(s) of the copyright holder(s) nor the names of its
          contributors may be used to endorse or promote products derived
          from this software without specific prior written permission.
    
       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
       "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
       LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
       A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
       HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
       SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
       LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
       DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
       THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
       (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
       OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
    */
    
    #ifndef SVE_INT_HPP
    #define SVE_INT_HPP
    
    
    template<>
    struct svetype<int>{
        typedef svint32_t vec;
        typedef svint32_t intvec;
        typedef int32_t scal;
    
        static inline vec vload(svbool_t pg, const scal *base)
        { return svld1_s32(pg, base); } 
    
        static inline vec vload_gatherindex(svbool_t pg, const scal *base, intvec indices )
        { return svld1_gather_index(pg, base, indices); } 
    
        static inline void vstore(svbool_t pg, scal* base, vec data)
        { svst1(pg, base, data); }
    
        static inline intvec index(int32_t base, int32_t step)
        { return svindex_s32(base, step); }
    
        static inline uint64_t count()
        { return svcntw(); }
    
        static inline svbool_t svtrue()
        { return svptrue_b32(); }
    
        static inline svbool_t svwhile(int64_t op1, int64_t op2)
        { return svwhilelt_b32(op1, op2); }
    
        static inline vec dup_all(scal op)
        { return svdup_s32(op);}
    
        static inline vec dup_z(svbool_t pg, scal op)
        { return svdup_s32_z(pg, op); }
    
        static inline vec neg_z(svbool_t pg, vec op1)
        { return svneg_s32_z(pg, op1); }
    
        static inline vec abs_z(svbool_t pg, vec op1)
        { return svabs_s32_z(pg, op1); }
    
        static inline vec mulscal_z(svbool_t pg, vec op1, scal op2)
        { return svmul_n_s32_z(pg, op1, op2); }
    
        static inline vec and_z(svbool_t pg, vec op1, vec op2)
        { return svand_z(pg, op1, op2); }
    
        static inline vec orr_z(svbool_t pg, vec op1, vec op2)
        { return svorr_z(pg, op1, op2); }
    
        static inline vec eor_z(svbool_t pg, vec op1, vec op2)
        { return sveor_z(pg, op1, op2); }
    
        static inline vec not_z(svbool_t pg, vec op1, vec op2)
        { return svnot_z(pg, op1, op2); }
    
        // vector vector operations
        static inline vec add_z(svbool_t pg, vec op1, vec op2)
        { return svadd_s32_z(pg, op1, op2); }
    
        static inline vec sub_z(svbool_t pg, vec op1, vec op2)
        { return svsub_s32_z(pg, op1, op2); }
    
        static inline vec mul_z(svbool_t pg, vec op1, vec op2)
        { return svmul_s32_z(pg, op1, op2); }
    
        static inline vec div_z(svbool_t pg, vec op1, vec op2)
        { return svdiv_s32_z(pg, op1, op2); }
    
        static inline vec conj_z(svbool_t pg, vec op1)
        { return op1; }
    
        static inline vec muladdscalar_z(svbool_t pg, vec op1, vec op2, scal op3)
        { return svmla_n_s32_z(pg, op1, op2, op3); }
    
        static inline scal reduce_sum( svbool_t pg, vec op )
        { return svaddv_s32(pg, op); }
    };
    #endif // SVE_INT_HPP