mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-18 15:57:05 +01:00
Accelerator mark up of entire tensore space for offload
This commit is contained in:
@ -35,12 +35,12 @@ NAMESPACE_BEGIN(Grid);
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class rtype,class vtype,class mtype>
|
||||
strong_inline void mult(iScalar<rtype> * __restrict__ ret,const iScalar<mtype> * __restrict__ lhs,const iScalar<vtype> * __restrict__ rhs){
|
||||
accelerator_inline void mult(iScalar<rtype> * __restrict__ ret,const iScalar<mtype> * __restrict__ lhs,const iScalar<vtype> * __restrict__ rhs){
|
||||
mult(&ret->_internal,&lhs->_internal,&rhs->_internal);
|
||||
}
|
||||
|
||||
template<class rrtype,class ltype,class rtype,int N>
|
||||
strong_inline void mult(iMatrix<rrtype,N> * __restrict__ ret,const iMatrix<ltype,N> * __restrict__ lhs,const iMatrix<rtype,N> * __restrict__ rhs){
|
||||
accelerator_inline void mult(iMatrix<rrtype,N> * __restrict__ ret,const iMatrix<ltype,N> * __restrict__ lhs,const iMatrix<rtype,N> * __restrict__ rhs){
|
||||
for(int c1=0;c1<N;c1++){
|
||||
for(int c2=0;c2<N;c2++){
|
||||
mult(&ret->_internal[c1][c2],&lhs->_internal[c1][0],&rhs->_internal[0][c2]);
|
||||
@ -57,7 +57,7 @@ strong_inline void mult(iMatrix<rrtype,N> * __restrict__ ret,const iMatrix<ltype
|
||||
}
|
||||
|
||||
template<class rrtype,class ltype,class rtype,int N>
|
||||
strong_inline void mult(iMatrix<rrtype,N> * __restrict__ ret,const iMatrix<ltype,N> * __restrict__ lhs,const iScalar<rtype> * __restrict__ rhs){
|
||||
accelerator_inline void mult(iMatrix<rrtype,N> * __restrict__ ret,const iMatrix<ltype,N> * __restrict__ lhs,const iScalar<rtype> * __restrict__ rhs){
|
||||
for(int c2=0;c2<N;c2++){
|
||||
for(int c1=0;c1<N;c1++){
|
||||
mult(&ret->_internal[c1][c2],&lhs->_internal[c1][c2],&rhs->_internal);
|
||||
@ -66,7 +66,7 @@ strong_inline void mult(iMatrix<rrtype,N> * __restrict__ ret,const iMatrix<ltype
|
||||
}
|
||||
|
||||
template<class rrtype,class ltype,class rtype, int N>
|
||||
strong_inline void mult(iMatrix<rrtype,N> * __restrict__ ret,const iScalar<ltype> * __restrict__ lhs,const iMatrix<rtype,N> * __restrict__ rhs){
|
||||
accelerator_inline void mult(iMatrix<rrtype,N> * __restrict__ ret,const iScalar<ltype> * __restrict__ lhs,const iMatrix<rtype,N> * __restrict__ rhs){
|
||||
for(int c2=0;c2<N;c2++){
|
||||
for(int c1=0;c1<N;c1++){
|
||||
mult(&ret->_internal[c1][c2],&lhs->_internal,&rhs->_internal[c1][c2]);
|
||||
@ -75,7 +75,7 @@ strong_inline void mult(iMatrix<rrtype,N> * __restrict__ ret,const iScalar<ltype
|
||||
}
|
||||
// Matrix left multiplies vector
|
||||
template<class rtype,class vtype,class mtype,int N>
|
||||
strong_inline void mult(iVector<rtype,N> * __restrict__ ret,const iMatrix<mtype,N> * __restrict__ lhs,const iVector<vtype,N> * __restrict__ rhs)
|
||||
accelerator_inline void mult(iVector<rtype,N> * __restrict__ ret,const iMatrix<mtype,N> * __restrict__ lhs,const iVector<vtype,N> * __restrict__ rhs)
|
||||
{
|
||||
for(int c1=0;c1<N;c1++){
|
||||
mult(&ret->_internal[c1],&lhs->_internal[c1][0],&rhs->_internal[0]);
|
||||
@ -86,7 +86,7 @@ strong_inline void mult(iVector<rtype,N> * __restrict__ ret,const iMatrix<mtype,
|
||||
return;
|
||||
}
|
||||
template<class rtype,class vtype,class mtype,int N>
|
||||
strong_inline void mult(iVector<rtype,N> * __restrict__ ret,
|
||||
accelerator_inline void mult(iVector<rtype,N> * __restrict__ ret,
|
||||
const iScalar<mtype> * __restrict__ lhs,
|
||||
const iVector<vtype,N> * __restrict__ rhs){
|
||||
for(int c1=0;c1<N;c1++){
|
||||
@ -94,7 +94,7 @@ strong_inline void mult(iVector<rtype,N> * __restrict__ ret,
|
||||
}
|
||||
}
|
||||
template<class rtype,class vtype,class mtype,int N>
|
||||
strong_inline void mult(iVector<rtype,N> * __restrict__ ret,
|
||||
accelerator_inline void mult(iVector<rtype,N> * __restrict__ ret,
|
||||
const iVector<vtype,N> * __restrict__ rhs,
|
||||
const iScalar<mtype> * __restrict__ lhs){
|
||||
for(int c1=0;c1<N;c1++){
|
||||
@ -104,7 +104,7 @@ strong_inline void mult(iVector<rtype,N> * __restrict__ ret,
|
||||
|
||||
|
||||
|
||||
template<class rtype,class vtype,class mtype,int N> strong_inline
|
||||
template<class rtype,class vtype,class mtype,int N> accelerator_inline
|
||||
iVector<rtype,N> operator * (const iMatrix<mtype,N>& lhs,const iVector<vtype,N>& rhs)
|
||||
{
|
||||
iVector<rtype,N> ret;
|
||||
@ -112,7 +112,7 @@ iVector<rtype,N> operator * (const iMatrix<mtype,N>& lhs,const iVector<vtype,N>&
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class rtype,class vtype,class mtype,int N> strong_inline
|
||||
template<class rtype,class vtype,class mtype,int N> accelerator_inline
|
||||
iVector<rtype,N> operator * (const iScalar<mtype>& lhs,const iVector<vtype,N>& rhs)
|
||||
{
|
||||
iVector<rtype,N> ret;
|
||||
@ -120,7 +120,7 @@ iVector<rtype,N> operator * (const iScalar<mtype>& lhs,const iVector<vtype,N>& r
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class rtype,class vtype,class mtype,int N> strong_inline
|
||||
template<class rtype,class vtype,class mtype,int N> accelerator_inline
|
||||
iVector<rtype,N> operator * (const iVector<mtype,N>& lhs,const iScalar<vtype>& rhs)
|
||||
{
|
||||
iVector<rtype,N> ret;
|
||||
@ -131,14 +131,14 @@ iVector<rtype,N> operator * (const iVector<mtype,N>& lhs,const iScalar<vtype>& r
|
||||
//////////////////////////////////////////////////////////////////
|
||||
// Divide by scalar
|
||||
//////////////////////////////////////////////////////////////////
|
||||
template<class rtype,class vtype> strong_inline
|
||||
template<class rtype,class vtype> accelerator_inline
|
||||
iScalar<rtype> operator / (const iScalar<rtype>& lhs,const iScalar<vtype>& rhs)
|
||||
{
|
||||
iScalar<rtype> ret;
|
||||
ret._internal = lhs._internal/rhs._internal;
|
||||
return ret;
|
||||
}
|
||||
template<class rtype,class vtype,int N> strong_inline
|
||||
template<class rtype,class vtype,int N> accelerator_inline
|
||||
iVector<rtype,N> operator / (const iVector<rtype,N>& lhs,const iScalar<vtype>& rhs)
|
||||
{
|
||||
iVector<rtype,N> ret;
|
||||
@ -147,7 +147,7 @@ iVector<rtype,N> operator / (const iVector<rtype,N>& lhs,const iScalar<vtype>& r
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template<class rtype,class vtype,int N> strong_inline
|
||||
template<class rtype,class vtype,int N> accelerator_inline
|
||||
iMatrix<rtype,N> operator / (const iMatrix<rtype,N>& lhs,const iScalar<vtype>& rhs)
|
||||
{
|
||||
iMatrix<rtype,N> ret;
|
||||
@ -174,14 +174,14 @@ iMatrix<rtype,N> operator / (const iMatrix<rtype,N>& lhs,const iScalar<vtype>& r
|
||||
//
|
||||
// We can special case scalar_type ??
|
||||
template<class l,class r>
|
||||
strong_inline auto operator * (const iScalar<l>& lhs,const iScalar<r>& rhs) -> iScalar<decltype(lhs._internal * rhs._internal)>
|
||||
accelerator_inline auto operator * (const iScalar<l>& lhs,const iScalar<r>& rhs) -> iScalar<decltype(lhs._internal * rhs._internal)>
|
||||
{
|
||||
typedef iScalar<decltype(lhs._internal*rhs._internal)> ret_t;
|
||||
ret_t ret;
|
||||
mult(&ret,&lhs,&rhs);
|
||||
return ret;
|
||||
}
|
||||
template<class l,class r,int N> strong_inline
|
||||
template<class l,class r,int N> accelerator_inline
|
||||
auto operator * (const iMatrix<l,N>& lhs,const iMatrix<r,N>& rhs) -> iMatrix<decltype(lhs._internal[0][0]*rhs._internal[0][0]),N>
|
||||
{
|
||||
typedef decltype(lhs._internal[0][0]*rhs._internal[0][0]) ret_t;
|
||||
@ -189,7 +189,7 @@ auto operator * (const iMatrix<l,N>& lhs,const iMatrix<r,N>& rhs) -> iMatrix<dec
|
||||
mult(&ret,&lhs,&rhs);
|
||||
return ret;
|
||||
}
|
||||
template<class l,class r, int N> strong_inline
|
||||
template<class l,class r, int N> accelerator_inline
|
||||
auto operator * (const iMatrix<r,N>& lhs,const iScalar<l>& rhs) -> iMatrix<decltype(lhs._internal[0][0]*rhs._internal),N>
|
||||
{
|
||||
typedef decltype(lhs._internal[0][0]*rhs._internal) ret_t;
|
||||
@ -201,7 +201,7 @@ auto operator * (const iMatrix<r,N>& lhs,const iScalar<l>& rhs) -> iMatrix<declt
|
||||
}}
|
||||
return ret;
|
||||
}
|
||||
template<class l,class r,int N> strong_inline
|
||||
template<class l,class r,int N> accelerator_inline
|
||||
auto operator * (const iScalar<l>& lhs,const iMatrix<r,N>& rhs) -> iMatrix<decltype(lhs._internal*rhs._internal[0][0]),N>
|
||||
{
|
||||
typedef decltype(lhs._internal*rhs._internal[0][0]) ret_t;
|
||||
@ -212,7 +212,7 @@ auto operator * (const iScalar<l>& lhs,const iMatrix<r,N>& rhs) -> iMatrix<declt
|
||||
}}
|
||||
return ret;
|
||||
}
|
||||
template<class l,class r,int N> strong_inline
|
||||
template<class l,class r,int N> accelerator_inline
|
||||
auto operator * (const iMatrix<l,N>& lhs,const iVector<r,N>& rhs) -> iVector<decltype(lhs._internal[0][0]*rhs._internal[0]),N>
|
||||
{
|
||||
typedef decltype(lhs._internal[0][0]*rhs._internal[0]) ret_t;
|
||||
@ -225,7 +225,7 @@ auto operator * (const iMatrix<l,N>& lhs,const iVector<r,N>& rhs) -> iVector<dec
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template<class l,class r,int N> strong_inline
|
||||
template<class l,class r,int N> accelerator_inline
|
||||
auto operator * (const iScalar<l>& lhs,const iVector<r,N>& rhs) -> iVector<decltype(lhs._internal*rhs._internal[0]),N>
|
||||
{
|
||||
typedef decltype(lhs._internal*rhs._internal[0]) ret_t;
|
||||
@ -235,7 +235,7 @@ auto operator * (const iScalar<l>& lhs,const iVector<r,N>& rhs) -> iVector<declt
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
template<class l,class r,int N> strong_inline
|
||||
template<class l,class r,int N> accelerator_inline
|
||||
auto operator * (const iVector<l,N>& lhs,const iScalar<r>& rhs) -> iVector<decltype(lhs._internal[0]*rhs._internal),N>
|
||||
{
|
||||
typedef decltype(lhs._internal[0]*rhs._internal) ret_t;
|
||||
|
Reference in New Issue
Block a user