1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
#ifndef ULMBLAS_IMPL_LEVEL3_UKERNEL_UTRLSM_TCC
#define ULMBLAS_IMPL_LEVEL3_UKERNEL_UTRLSM_TCC 1

#include <ulmblas/impl/config/simd.h>
#include <ulmblas/impl/level1/scal.h>
#include <ulmblas/impl/level1extensions/gecopy.h>
#include <ulmblas/impl/level3/ukernel/ugemm.h>
#include <ulmblas/impl/level3/ukernel/utrlsm.h>

//
//  Selected optimized micro kernel
//
#if defined(USE_SSE)
#   define  SELECT_UTRLSM_KERNEL    sse
#   include <ulmblas/impl/level3/ukernel/sse/utrlsm.h>
#else
#   define  SELECT_UTRLSM_KERNEL    ref
#   include <ulmblas/impl/level3/ukernel/ref/utrlsm.h>
#endif


namespace ulmBLAS {

//
//  Buffered variant.  Used for zero padded panels.
//
template <typename IndexType, typename T, typename TC>
void
utrlsm(IndexType    mr,
       IndexType    nr,
       const T      *A,
       const T      *B,
       TC           *C,
       IndexType    incRowC,
       IndexType    incColC)
{
    const IndexType MR = BlockSizeUGemm<T>::MR;
    const IndexType NR = BlockSizeUGemm<T>::NR;

    T   A_[MR*MR];
    T   B_[MR*NR];
    T   C_[MR*NR];

    scal(MR*MR, T(0), A_, IndexType(1));
    scal(MR*NR, T(0), B_, IndexType(1));

    gecopy(mr, mr, false, A, IndexType(1), MR, A_, IndexType(1), MR);
    gecopy(mr, nr, false, B, NR, IndexType(1), B_, NR, IndexType(1));

    utrlsm(A_, B_, C_, IndexType(1), MR);
    gecopy(mr, nr, false, C_, IndexType(1), MR, C, incRowC, incColC);
}

//
//  Buffered variant.  Used if the result A^(-1)*B needs to be upcasted for
//  computing C <- A^(-1)*B
//
template <typename T, typename TC, typename IndexType>
void
utrlsm(const T     *A,
       const T     *B,
       TC          *C,
       IndexType   incRowC,
       IndexType   incColC)
{
    const IndexType MR = BlockSizeUGemm<T>::MR;
    const IndexType NR = BlockSizeUGemm<T>::NR;

    utrlsm(MR, NR, A, B, C, incRowC, incColC);
}

//
//  Unbuffered variant.
//
template <typename IndexType, typename T>
void
utrlsm(const T     *A,
       const T     *B,
       T           *C,
       IndexType   incRowC,
       IndexType   incColC)
{
    SELECT_UTRLSM_KERNEL::utrlsm(A, B, C, incRowC, incColC);
}

// namespace ulmBLAS

#endif // ULMBLAS_IMPL_LEVEL3_UKERNEL_UTRLSM_TCC