mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Merge branch 'master' of https://github.com/paboyle/Grid
This commit is contained in:
commit
325e745daa
1
.gitignore
vendored
1
.gitignore
vendored
@ -95,6 +95,7 @@ Thumbs.db
|
||||
# build directory #
|
||||
###################
|
||||
build/*
|
||||
build_debug/*
|
||||
|
||||
# IDE related files #
|
||||
#####################
|
||||
|
@ -71,7 +71,7 @@ AC_CHECK_FUNCS([gettimeofday])
|
||||
|
||||
AC_ARG_ENABLE([simd],[AC_HELP_STRING([--enable-simd=SSE4|AVX|AVXFMA4|AVX2|AVX512|IMCI],\
|
||||
[Select instructions to be SSE4.0, AVX 1.0, AVX 2.0+FMA, AVX 512, IMCI])],\
|
||||
[ac_SIMD=${enable_simd}],[ac_SIMD=AVX2])
|
||||
[ac_SIMD=${enable_simd}],[ac_SIMD=DEBUG])
|
||||
|
||||
supported=no
|
||||
|
||||
|
@ -36,7 +36,6 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include <immintrin.h>
|
||||
#ifdef HAVE_MM_MALLOC_H
|
||||
#include <mm_malloc.h>
|
||||
#endif
|
||||
|
@ -30,15 +30,6 @@
|
||||
/* GRID_DEFAULT_PRECISION is SINGLE */
|
||||
#undef GRID_DEFAULT_PRECISION_SINGLE
|
||||
|
||||
/* Support Altivec instructions */
|
||||
#undef HAVE_ALTIVEC
|
||||
|
||||
/* Support AVX (Advanced Vector Extensions) instructions */
|
||||
#undef HAVE_AVX
|
||||
|
||||
/* Support AVX2 (Advanced Vector Extensions 2) instructions */
|
||||
#undef HAVE_AVX2
|
||||
|
||||
/* Define to 1 if you have the declaration of `be64toh', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_BE64TOH
|
||||
@ -53,9 +44,6 @@
|
||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||
#undef HAVE_EXECINFO_H
|
||||
|
||||
/* Support FMA3 (Fused Multiply-Add) instructions */
|
||||
#undef HAVE_FMA
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
@ -74,30 +62,9 @@
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Support mmx instructions */
|
||||
#undef HAVE_MMX
|
||||
|
||||
/* Define to 1 if you have the <mm_malloc.h> header file. */
|
||||
#undef HAVE_MM_MALLOC_H
|
||||
|
||||
/* Support SSE (Streaming SIMD Extensions) instructions */
|
||||
#undef HAVE_SSE
|
||||
|
||||
/* Support SSE2 (Streaming SIMD Extensions 2) instructions */
|
||||
#undef HAVE_SSE2
|
||||
|
||||
/* Support SSE3 (Streaming SIMD Extensions 3) instructions */
|
||||
#undef HAVE_SSE3
|
||||
|
||||
/* Support SSSE4.1 (Streaming SIMD Extensions 4.1) instructions */
|
||||
#undef HAVE_SSE4_1
|
||||
|
||||
/* Support SSSE4.2 (Streaming SIMD Extensions 4.2) instructions */
|
||||
#undef HAVE_SSE4_2
|
||||
|
||||
/* Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions */
|
||||
#undef HAVE_SSSE3
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
|
@ -45,9 +45,6 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#define __X86_64
|
||||
|
||||
|
||||
namespace Grid {
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
@ -291,12 +288,11 @@ void Grid_sa_signal_handler(int sig,siginfo_t *si,void * ptr)
|
||||
// Linux/Posix
|
||||
#ifdef __linux__
|
||||
// And x86 64bit
|
||||
ucontext_t * uc= (ucontext_t *)ptr;
|
||||
#ifdef __x86_64__
|
||||
ucontext_t * uc= (ucontext_t *)ptr;
|
||||
struct sigcontext *sc = (struct sigcontext *)&uc->uc_mcontext;
|
||||
printf(" instruction %llx\n",(unsigned long long)sc->rip);
|
||||
|
||||
#define REG(A) printf(" %s %lx\n",#A,sc-> A);
|
||||
|
||||
REG(rdi);
|
||||
REG(rsi);
|
||||
REG(rbp);
|
||||
@ -316,6 +312,7 @@ void Grid_sa_signal_handler(int sig,siginfo_t *si,void * ptr)
|
||||
REG(r13);
|
||||
REG(r14);
|
||||
REG(r15);
|
||||
#endif
|
||||
#endif
|
||||
BACKTRACE();
|
||||
exit(0);
|
||||
|
@ -43,8 +43,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
||||
#else
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
namespace Grid {
|
||||
|
||||
namespace Grid {
|
||||
|
||||
#ifdef __linux__
|
||||
static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||
@ -58,6 +58,23 @@ static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __bgq__
|
||||
inline uint64_t cyclecount(void){
|
||||
uint64_t tmp;
|
||||
asm volatile ("mfspr %0,0x10C" : "=&r" (tmp) );
|
||||
return tmp;
|
||||
}
|
||||
#elif defined __x86_64__
|
||||
#include <x86intrin.h>
|
||||
inline uint64_t cyclecount(void){
|
||||
return __rdtsc();
|
||||
}
|
||||
#else
|
||||
#warning No cycle counter implemented for this architecture
|
||||
inline uint64_t cyclecount(void){
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
class PerformanceCounter {
|
||||
private:
|
||||
@ -149,7 +166,7 @@ public:
|
||||
ioctl(fd, PERF_EVENT_IOC_RESET, 0);
|
||||
ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
|
||||
}
|
||||
begin =__rdtsc();
|
||||
begin =cyclecount();
|
||||
#else
|
||||
begin = 0;
|
||||
#endif
|
||||
@ -162,7 +179,7 @@ public:
|
||||
ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
|
||||
::read(fd, &count, sizeof(long long));
|
||||
}
|
||||
elapsed = __rdtsc() - begin;
|
||||
elapsed = cyclecount() - begin;
|
||||
#else
|
||||
elapsed = 0;
|
||||
#endif
|
||||
|
@ -118,12 +118,12 @@ void WilsonKernels<Impl >::DiracOptAsmDhopSite(StencilImpl &st,DoubledGaugeField
|
||||
|
||||
StencilEntry *SE;
|
||||
|
||||
//#define STAMP(i) timers[i] = __rdtsc() ;
|
||||
#define STAMP(i) //timers[i] = __rdtsc() ;
|
||||
//#define STAMP(i) timers[i] = cyclecount() ;
|
||||
#define STAMP(i) //timers[i] = cyclecount() ;
|
||||
|
||||
MASK_REGS;
|
||||
|
||||
first = __rdtsc();
|
||||
first = cyclecount();
|
||||
|
||||
SE=st.GetEntry(ptype,Xm,ss);
|
||||
|
||||
|
@ -120,7 +120,7 @@ THE SOFTWARE.
|
||||
\
|
||||
\
|
||||
template <typename T>\
|
||||
static void write(Writer<T> &WR,const std::string &s, const cname &obj){ \
|
||||
static inline void write(Writer<T> &WR,const std::string &s, const cname &obj){ \
|
||||
push(WR,s);\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_WRITE_MEMBER,__VA_ARGS__)) \
|
||||
pop(WR);\
|
||||
@ -128,14 +128,14 @@ THE SOFTWARE.
|
||||
\
|
||||
\
|
||||
template <typename T>\
|
||||
static void read(Reader<T> &RD,const std::string &s, cname &obj){ \
|
||||
static inline void read(Reader<T> &RD,const std::string &s, cname &obj){ \
|
||||
push(RD,s);\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_READ_MEMBER,__VA_ARGS__)) \
|
||||
pop(RD);\
|
||||
} \
|
||||
\
|
||||
\
|
||||
friend std::ostream & operator << (std::ostream &os, const cname &obj ) { \
|
||||
friend inline std::ostream & operator << (std::ostream &os, const cname &obj ) { \
|
||||
os<<"class "<<#cname<<" {"<<std::endl;\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_OS_WRITE_MEMBER,__VA_ARGS__)) \
|
||||
os<<"}"; \
|
||||
@ -165,7 +165,7 @@ namespace Grid {
|
||||
class EnumIO<name> {\
|
||||
public:\
|
||||
template <typename T>\
|
||||
static void write(Writer<T> &WR,const std::string &s, const name &obj){ \
|
||||
static inline void write(Writer<T> &WR,const std::string &s, const name &obj){ \
|
||||
switch (obj) {\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASE,__VA_ARGS__))\
|
||||
default: Grid::write(WR,s,#undefname); break;\
|
||||
@ -173,7 +173,7 @@ namespace Grid {
|
||||
}\
|
||||
\
|
||||
template <typename T>\
|
||||
static void read(Reader<T> &RD,const std::string &s, name &obj){ \
|
||||
static inline void read(Reader<T> &RD,const std::string &s, name &obj){ \
|
||||
std::string buf;\
|
||||
Grid::read(RD, s, buf);\
|
||||
if (buf == #undefname) {obj = name::undefname;}\
|
||||
@ -182,7 +182,7 @@ namespace Grid {
|
||||
}\
|
||||
};\
|
||||
\
|
||||
std::ostream & operator << (std::ostream &os, const name &obj ) { \
|
||||
inline std::ostream & operator << (std::ostream &os, const name &obj ) { \
|
||||
switch (obj) {\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASEIO,__VA_ARGS__))\
|
||||
default: os << #undefname; break;\
|
||||
|
@ -80,6 +80,20 @@ void XmlReader::pop(void)
|
||||
node_ = node_.parent();
|
||||
}
|
||||
|
||||
bool XmlReader::nextElement(const std::string &s)
|
||||
{
|
||||
if (node_.next_sibling(s.c_str()))
|
||||
{
|
||||
node_ = node_.next_sibling(s.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void XmlReader::readDefault(const string &s, string &output)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ namespace Grid
|
||||
virtual ~XmlReader(void) = default;
|
||||
void push(const std::string &s);
|
||||
void pop(void);
|
||||
bool nextElement(const std::string &s);
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, U &output);
|
||||
template <typename U>
|
||||
|
@ -35,6 +35,7 @@ Author: neo <cossu@post.kek.jp>
|
||||
// Time-stamp: <2015-06-09 14:28:02 neo>
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
namespace Grid {
|
||||
namespace Optimization {
|
||||
|
||||
template<class vtype>
|
||||
@ -243,6 +244,36 @@ namespace Optimization {
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Some Template specialization
|
||||
struct Permute{
|
||||
|
||||
static inline float Permute0(float in){
|
||||
return in;
|
||||
};
|
||||
static inline float Permute1(float in){
|
||||
return in;
|
||||
};
|
||||
static inline float Permute2(float in){
|
||||
return in;
|
||||
};
|
||||
static inline float Permute3(float in){
|
||||
return in;
|
||||
};
|
||||
|
||||
static inline double Permute0(double in){
|
||||
return in;
|
||||
};
|
||||
static inline double Permute1(double in){
|
||||
return in;
|
||||
};
|
||||
static inline double Permute2(double in){
|
||||
return in;
|
||||
};
|
||||
static inline double Permute3(double in){
|
||||
return in;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template < typename vtype >
|
||||
void permute(vtype &a, vtype b, int perm) {
|
||||
};
|
||||
@ -282,7 +313,6 @@ namespace Optimization {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// Here assign types
|
||||
namespace Grid {
|
||||
|
||||
typedef float SIMD_Ftype; // Single precision type
|
||||
typedef double SIMD_Dtype; // Double precision type
|
||||
|
Loading…
Reference in New Issue
Block a user