Skip to content

Commit

Permalink
Merge branch 'work2' into cms/v5-34-18
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf committed May 16, 2014
2 parents 4f40be5 + af422ce commit fb22a6f
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 38 deletions.
53 changes: 53 additions & 0 deletions cint/cintex/src/CINTFunctional.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,58 @@ namespace ROOT { namespace Cintex {
#define DATAPATTERN 0xDADADADAL
#endif

#if defined(__arm__)
__attribute__((naked, used))
static void f0a() {
__asm__ __volatile__ ("push {fp, lr}\n\t"
"add fp, sp, #4\n\t"
"ldr r3, [pc, #8]\n\t"
"ldr r0, [pc, #8]\n\t"
"blx r3\n\t"
"pop {fp, pc}\n\t"
".word 0xfafafafa\n\t"
".word 0xdadadada");
}

__attribute__((naked, used))
static void f1a(void* a0) {
__asm__ __volatile__ ("push {fp, lr}\n\t"
"add fp, sp, #4\n\t"
"sub sp, sp, #8\n\t"
"str r0, [fp, #-8]\n\t"
"ldr r3, [pc, #16]\n\t"
"ldr r0, [pc, #16]\n\t"
"ldr r1, [fp, #-8]\n\t"
"blx r3\n\t"
"sub sp, fp, #4\n\t"
"pop {fp, pc}\n\t"
".word 0xfafafafa\n\t"
".word 0xdadadada");
}

__attribute__((naked, used))
static void f4a(void* a0, void* a1, void* a2, void* a3) {
__asm__ __volatile__ ("push {fp, lr}\n\t"
"add fp, sp, #4\n\t"
"sub sp, sp, #24\n\t"
"str r0, [fp, #-8]\n\t"
"str r1, [fp, #-12]\n\t"
"str r2, [fp, #-16]\n\t"
"str r3, [fp, #-20]\n\t"
"ldr r3, [fp, #-20]\n\t"
"str r3, [sp]\n\t"
"ldr ip, [pc, #24]\n\t"
"ldr r0, [pc, #24]\n\t"
"ldr r1, [fp, #-8]\n\t"
"ldr r2, [fp, #-12]\n\t"
"ldr r3, [fp, #-16]\n\t"
"blx ip\n\t"
"sub sp, fp, #4\n\t"
"pop {fp, pc}\n\t"
".word 0xfafafafa\n\t"
".word 0xdadadada");
}
#else
static void f0a() {
typedef void (*f_t)(void*);
((f_t)FUNCPATTERN)((void*)DATAPATTERN);
Expand All @@ -481,6 +533,7 @@ namespace ROOT { namespace Cintex {
typedef void (*f_t)(void*,void*,void*,void*,void*);
((f_t)FUNCPATTERN)((void*)DATAPATTERN, a0, a1, a2, a3);
}
#endif /* defined(__arm__) */

struct FunctionCode_t {
FunctionCode_t(int narg) : f_offset(0), fa_offset(0), fSize(0) {
Expand Down
4 changes: 4 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -6391,6 +6391,10 @@ if test ! "x$enable_cintex" = "xno"; then
enable_cintex="yes"
result "yes"
;;
armv7l)
enable_cintex="yes"
result "yes"
;;
*)
logmsg " incompatible Cintex architecture $chip"
enable_cintex=""
Expand Down
10 changes: 10 additions & 0 deletions core/thread/src/TThread.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,16 @@ void TThread::Init()
gGlobalMutex = new TMutex(kTRUE);
gCint->SetAlloclockfunc(CINT_alloc_lock);
gCint->SetAllocunlockfunc(CINT_alloc_unlock);

//To avoid deadlocks, gCintMutex and gROOTMutex need
// to point at the same instance
{
R__LOCKGUARD(gGlobalMutex);
if (!gCINTMutex) {
gCINTMutex = gGlobalMutex->Factory(kTRUE);
}
gROOTMutex = gCINTMutex;
}
}

//______________________________________________________________________________
Expand Down
10 changes: 5 additions & 5 deletions math/smatrix/inc/Math/MatrixFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ template <class T, unsigned int D1, unsigned int D2, class R>
inline SMatrix<T,D1,D1,MatRepSym<T,D1> > Similarity(const SMatrix<T,D1,D2,R>& lhs, const SMatrix<T,D2,D2,MatRepSym<T,D2> >& rhs) {
SMatrix<T,D1,D2, MatRepStd<T,D1,D2> > tmp = lhs * rhs;
typedef SMatrix<T,D1,D1,MatRepSym<T,D1> > SMatrixSym;
SMatrixSym mret;
SMatrixSym mret =SMatrixNoInit();
AssignSym::Evaluate(mret, tmp * Transpose(lhs) );
return mret;
}
Expand All @@ -729,7 +729,7 @@ template <class A, class T, unsigned int D1, unsigned int D2, class R>
inline SMatrix<T,D1,D1,MatRepSym<T,D1> > Similarity(const Expr<A,T,D1,D2,R>& lhs, const SMatrix<T,D2,D2,MatRepSym<T,D2> >& rhs) {
SMatrix<T,D1,D2,MatRepStd<T,D1,D2> > tmp = lhs * rhs;
typedef SMatrix<T,D1,D1,MatRepSym<T,D1> > SMatrixSym;
SMatrixSym mret;
SMatrixSym mret = SMatrixNoInit();
AssignSym::Evaluate(mret, tmp * Transpose(lhs) );
return mret;
}
Expand All @@ -744,7 +744,7 @@ template <class T, unsigned int D1>
inline SMatrix<T,D1,D1,MatRepSym<T,D1> > Similarity(const SMatrix<T,D1,D1,MatRepSym<T,D1> >& lhs, const SMatrix<T,D1,D1,MatRepSym<T,D1> >& rhs) {
SMatrix<T,D1,D1, MatRepStd<T,D1,D1> > tmp = lhs * rhs;
typedef SMatrix<T,D1,D1,MatRepSym<T,D1> > SMatrixSym;
SMatrixSym mret;
SMatrixSym mret = SMatrixNoInit();
AssignSym::Evaluate(mret, tmp * lhs );
return mret;
}
Expand All @@ -765,7 +765,7 @@ template <class T, unsigned int D1, unsigned int D2, class R>
inline SMatrix<T,D2,D2,MatRepSym<T,D2> > SimilarityT(const SMatrix<T,D1,D2,R>& lhs, const SMatrix<T,D1,D1,MatRepSym<T,D1> >& rhs) {
SMatrix<T,D1,D2,MatRepStd<T,D1,D2> > tmp = rhs * lhs;
typedef SMatrix<T,D2,D2,MatRepSym<T,D2> > SMatrixSym;
SMatrixSym mret;
SMatrixSym mret = SMatrixNoInit();
AssignSym::Evaluate(mret, Transpose(lhs) * tmp );
return mret;
}
Expand All @@ -779,7 +779,7 @@ template <class A, class T, unsigned int D1, unsigned int D2, class R>
inline SMatrix<T,D2,D2,MatRepSym<T,D2> > SimilarityT(const Expr<A,T,D1,D2,R>& lhs, const SMatrix<T,D1,D1,MatRepSym<T,D1> >& rhs) {
SMatrix<T,D1,D2,MatRepStd<T,D1,D2> > tmp = rhs * lhs;
typedef SMatrix<T,D2,D2,MatRepSym<T,D2> > SMatrixSym;
SMatrixSym mret;
SMatrixSym mret = SMatrixNoInit();
AssignSym::Evaluate(mret, Transpose(lhs) * tmp );
return mret;
}
Expand Down
178 changes: 145 additions & 33 deletions math/smatrix/inc/Math/MatrixRepresentationsStatic.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
#ifndef ROOT_Math_MatrixRepresentationsStatic
#define ROOT_Math_MatrixRepresentationsStatic 1

//#ifndef SMATRIX_USE_COMPUTATION
//#define SMATRIX_USE_CONSTEXPR
//#endif


#ifndef SMATRIX_USE_CONSTEXPR
#define SMATRIX_USE_COMPUTATION
#endif


// Include files

/**
Expand All @@ -23,6 +33,14 @@
#include "Math/StaticCheck.h"
#endif

#ifdef SMATRIX_USE_CONSTEXPR
#include <cstddef>
#include <utility>
#include <type_traits>
#include <array>
#endif


namespace ROOT {

namespace Math {
Expand Down Expand Up @@ -142,6 +160,56 @@ namespace Math {
int fOff[D*D];
};

#ifdef SMATRIX_USE_CONSTEXPR
namespace rowOffsetsUtils {

///////////
// Some meta template stuff
template<int...> struct indices{};

template<int I, class IndexTuple, int N>
struct make_indices_impl;

template<int I, int... Indices, int N>
struct make_indices_impl<I, indices<Indices...>, N>
{
typedef typename make_indices_impl<I + 1, indices<Indices..., I>,
N>::type type;
};

template<int N, int... Indices>
struct make_indices_impl<N, indices<Indices...>, N> {
typedef indices<Indices...> type;
};

template<int N>
struct make_indices : make_indices_impl<0, indices<>, N> {};
// end of stuff



template<int I0, class F, int... I>
constexpr std::array<decltype(std::declval<F>()(std::declval<int>())), sizeof...(I)>
do_make(F f, indices<I...>)
{
return std::array<decltype(std::declval<F>()(std::declval<int>())),
sizeof...(I)>{{ f(I0 + I)... }};
}

template<int N, int I0 = 0, class F>
constexpr std::array<decltype(std::declval<F>()(std::declval<int>())), N>
make(F f) {
return do_make<I0>(f, typename make_indices<N>::type());
}

} // namespace rowOffsetsUtils

#elif defined(SMATRIX_USE_COMPUTATION)

#else



// Make the lookup tables available at compile time:
// Add them to a namespace?
static const int fOff1x1[] = {0};
Expand Down Expand Up @@ -233,6 +301,8 @@ template<>
int apply(unsigned int i) const { return fOff10x10[i]; }
};

#endif

//_________________________________________________________________________________
/**
MatRepSym
Expand All @@ -257,35 +327,35 @@ template<>

public:

#if defined(SMATRIX_USE_CONSTEXPR) || defined(SMATRIX_USE_COMPUTATION)
/* constexpr */ inline MatRepSym(){}
#else
MatRepSym() :fOff(0) { CreateOffsets(); }

#endif
typedef T value_type;

inline const T& operator()(unsigned int i, unsigned int j) const {
return fArray[Offsets()(i,j)];
}
inline T& operator()(unsigned int i, unsigned int j) {
return fArray[Offsets()(i,j)];
}

inline T& operator[](unsigned int i) {
return fArray[Offsets().apply(i) ];
//return fArray[Offsets()(i/D, i%D)];
}
inline T & operator()(unsigned int i, unsigned int j)
{ return fArray[offset(i, j)]; }

inline const T& operator[](unsigned int i) const {
return fArray[Offsets().apply(i) ];
//return fArray[Offsets()(i/D, i%D)];
}
inline /* constexpr */ T const & operator()(unsigned int i, unsigned int j) const
{ return fArray[offset(i, j)]; }

inline T apply(unsigned int i) const {
return fArray[Offsets().apply(i) ];
//return operator()(i/D, i%D);
}
inline T& operator[](unsigned int i) {
return fArray[off(i)];
}

inline T* Array() { return fArray; }
inline /* constexpr */ T const & operator[](unsigned int i) const {
return fArray[off(i)];
}

inline const T* Array() const { return fArray; }
inline /* constexpr */ T apply(unsigned int i) const {
return fArray[off(i)];
}

inline T* Array() { return fArray; }

inline const T* Array() const { return fArray; }

/**
assignment : only symmetric to symmetric allowed
Expand Down Expand Up @@ -336,7 +406,7 @@ template<>
}
return rc;
}

enum {
/// return no. of matrix rows
kRows = D,
Expand All @@ -346,26 +416,68 @@ template<>
kSize = D*(D+1)/2
};


void CreateOffsets() {
const static RowOffsets<D> off;
fOff = &off;
}

inline const RowOffsets<D> & Offsets() const {
return *fOff;
}

#ifdef SMATRIX_USE_CONSTEXPR
static constexpr int off0(int i) { return i==0 ? 0 : off0(i-1)+i;}
static constexpr int off2(int i, int j) { return j<i ? off0(i)+j : off0(j)+i; }
static constexpr int off1(int i) { return off2(i/D, i%D);}

static int off(int i) {
static constexpr auto v = rowOffsetsUtils::make<D*D>(off1);
return v[i];
}

static inline constexpr unsigned int
offset(unsigned int i, unsigned int j)
{
//if (j > i) std::swap(i, j);
return off(i*D+j);
// return (i>j) ? (i * (i+1) / 2) + j : (j * (j+1) / 2) + i;
}
#elif defined(SMATRIX_USE_COMPUTATION)
static inline unsigned int
offset(unsigned int i, unsigned int j)
{
return (i>j) ? (i * (i+1) / 2) + j : (j * (j+1) / 2) + i;
}
static inline unsigned int
off(unsigned int i) {
return offset(i/D, i%D);
}
#else
unsigned int
offset(unsigned int i, unsigned int j) const
{
return Offsets()(i,j);
}
unsigned int
off(unsigned int i) const {
return Offsets().apply(i);
}


void CreateOffsets() {
const static RowOffsets<D> off;
fOff = &off;
}

inline const RowOffsets<D> & Offsets() const {
return *fOff;
}
#endif


private:
//T __attribute__ ((aligned (16))) fArray[kSize];
T fArray[kSize];

#if !defined(SMATRIX_USE_CONSTEXPR) && !defined(SMATRIX_USE_COMPUTATION)
const RowOffsets<D> * fOff; //! transient

#endif
};



} // namespace Math
} // namespace ROOT

Expand Down
Loading

0 comments on commit fb22a6f

Please sign in to comment.