mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-10 06:00:45 +01:00
Merge pull request #24 from aportelli/master
BG/Q compatibility + XML fixes
This commit is contained in:
commit
f3661aac4f
1
.gitignore
vendored
1
.gitignore
vendored
@ -95,6 +95,7 @@ Thumbs.db
|
|||||||
# build directory #
|
# build directory #
|
||||||
###################
|
###################
|
||||||
build/*
|
build/*
|
||||||
|
build_debug/*
|
||||||
|
|
||||||
# IDE related files #
|
# 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],\
|
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])],\
|
[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
|
supported=no
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <immintrin.h>
|
|
||||||
#ifdef HAVE_MM_MALLOC_H
|
#ifdef HAVE_MM_MALLOC_H
|
||||||
#include <mm_malloc.h>
|
#include <mm_malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,15 +30,6 @@
|
|||||||
/* GRID_DEFAULT_PRECISION is SINGLE */
|
/* GRID_DEFAULT_PRECISION is SINGLE */
|
||||||
#undef GRID_DEFAULT_PRECISION_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
|
/* Define to 1 if you have the declaration of `be64toh', and to 0 if you
|
||||||
don't. */
|
don't. */
|
||||||
#undef HAVE_DECL_BE64TOH
|
#undef HAVE_DECL_BE64TOH
|
||||||
@ -53,9 +44,6 @@
|
|||||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||||
#undef HAVE_EXECINFO_H
|
#undef HAVE_EXECINFO_H
|
||||||
|
|
||||||
/* Support FMA3 (Fused Multiply-Add) instructions */
|
|
||||||
#undef HAVE_FMA
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `gettimeofday' function. */
|
/* Define to 1 if you have the `gettimeofday' function. */
|
||||||
#undef HAVE_GETTIMEOFDAY
|
#undef HAVE_GETTIMEOFDAY
|
||||||
|
|
||||||
@ -74,30 +62,9 @@
|
|||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#undef HAVE_MEMORY_H
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
/* Support mmx instructions */
|
|
||||||
#undef HAVE_MMX
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <mm_malloc.h> header file. */
|
/* Define to 1 if you have the <mm_malloc.h> header file. */
|
||||||
#undef HAVE_MM_MALLOC_H
|
#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. */
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
#undef HAVE_STDINT_H
|
#undef HAVE_STDINT_H
|
||||||
|
|
||||||
|
11
lib/Init.cc
11
lib/Init.cc
@ -45,9 +45,6 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#define __X86_64
|
|
||||||
|
|
||||||
|
|
||||||
namespace Grid {
|
namespace Grid {
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
@ -289,14 +286,13 @@ void Grid_sa_signal_handler(int sig,siginfo_t *si,void * ptr)
|
|||||||
printf(" code %d\n",si->si_code);
|
printf(" code %d\n",si->si_code);
|
||||||
|
|
||||||
// Linux/Posix
|
// Linux/Posix
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
// And x86 64bit
|
// 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;
|
struct sigcontext *sc = (struct sigcontext *)&uc->uc_mcontext;
|
||||||
printf(" instruction %llx\n",(unsigned long long)sc->rip);
|
printf(" instruction %llx\n",(unsigned long long)sc->rip);
|
||||||
|
|
||||||
#define REG(A) printf(" %s %lx\n",#A,sc-> A);
|
#define REG(A) printf(" %s %lx\n",#A,sc-> A);
|
||||||
|
|
||||||
REG(rdi);
|
REG(rdi);
|
||||||
REG(rsi);
|
REG(rsi);
|
||||||
REG(rbp);
|
REG(rbp);
|
||||||
@ -316,6 +312,7 @@ void Grid_sa_signal_handler(int sig,siginfo_t *si,void * ptr)
|
|||||||
REG(r13);
|
REG(r13);
|
||||||
REG(r14);
|
REG(r14);
|
||||||
REG(r15);
|
REG(r15);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
BACKTRACE();
|
BACKTRACE();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -43,8 +43,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
|
|||||||
#else
|
#else
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#endif
|
#endif
|
||||||
namespace Grid {
|
|
||||||
|
|
||||||
|
namespace Grid {
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
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
|
#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 {
|
class PerformanceCounter {
|
||||||
private:
|
private:
|
||||||
@ -149,7 +166,7 @@ public:
|
|||||||
ioctl(fd, PERF_EVENT_IOC_RESET, 0);
|
ioctl(fd, PERF_EVENT_IOC_RESET, 0);
|
||||||
ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
|
ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
|
||||||
}
|
}
|
||||||
begin =__rdtsc();
|
begin =cyclecount();
|
||||||
#else
|
#else
|
||||||
begin = 0;
|
begin = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -162,7 +179,7 @@ public:
|
|||||||
ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
|
ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
|
||||||
::read(fd, &count, sizeof(long long));
|
::read(fd, &count, sizeof(long long));
|
||||||
}
|
}
|
||||||
elapsed = __rdtsc() - begin;
|
elapsed = cyclecount() - begin;
|
||||||
#else
|
#else
|
||||||
elapsed = 0;
|
elapsed = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -118,12 +118,12 @@ void WilsonKernels<Impl >::DiracOptAsmDhopSite(StencilImpl &st,DoubledGaugeField
|
|||||||
|
|
||||||
StencilEntry *SE;
|
StencilEntry *SE;
|
||||||
|
|
||||||
//#define STAMP(i) timers[i] = __rdtsc() ;
|
//#define STAMP(i) timers[i] = cyclecount() ;
|
||||||
#define STAMP(i) //timers[i] = __rdtsc() ;
|
#define STAMP(i) //timers[i] = cyclecount() ;
|
||||||
|
|
||||||
MASK_REGS;
|
MASK_REGS;
|
||||||
|
|
||||||
first = __rdtsc();
|
first = cyclecount();
|
||||||
|
|
||||||
SE=st.GetEntry(ptype,Xm,ss);
|
SE=st.GetEntry(ptype,Xm,ss);
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ THE SOFTWARE.
|
|||||||
\
|
\
|
||||||
\
|
\
|
||||||
template <typename T>\
|
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);\
|
push(WR,s);\
|
||||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_WRITE_MEMBER,__VA_ARGS__)) \
|
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_WRITE_MEMBER,__VA_ARGS__)) \
|
||||||
pop(WR);\
|
pop(WR);\
|
||||||
@ -128,14 +128,14 @@ THE SOFTWARE.
|
|||||||
\
|
\
|
||||||
\
|
\
|
||||||
template <typename T>\
|
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);\
|
push(RD,s);\
|
||||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_READ_MEMBER,__VA_ARGS__)) \
|
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_READ_MEMBER,__VA_ARGS__)) \
|
||||||
pop(RD);\
|
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;\
|
os<<"class "<<#cname<<" {"<<std::endl;\
|
||||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_OS_WRITE_MEMBER,__VA_ARGS__)) \
|
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_OS_WRITE_MEMBER,__VA_ARGS__)) \
|
||||||
os<<"}"; \
|
os<<"}"; \
|
||||||
@ -165,7 +165,7 @@ namespace Grid {
|
|||||||
class EnumIO<name> {\
|
class EnumIO<name> {\
|
||||||
public:\
|
public:\
|
||||||
template <typename T>\
|
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) {\
|
switch (obj) {\
|
||||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASE,__VA_ARGS__))\
|
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASE,__VA_ARGS__))\
|
||||||
default: Grid::write(WR,s,#undefname); break;\
|
default: Grid::write(WR,s,#undefname); break;\
|
||||||
@ -173,7 +173,7 @@ namespace Grid {
|
|||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
template <typename T>\
|
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;\
|
std::string buf;\
|
||||||
Grid::read(RD, s, buf);\
|
Grid::read(RD, s, buf);\
|
||||||
if (buf == #undefname) {obj = name::undefname;}\
|
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) {\
|
switch (obj) {\
|
||||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASEIO,__VA_ARGS__))\
|
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASEIO,__VA_ARGS__))\
|
||||||
default: os << #undefname; break;\
|
default: os << #undefname; break;\
|
||||||
|
@ -80,6 +80,20 @@ void XmlReader::pop(void)
|
|||||||
node_ = node_.parent();
|
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 <>
|
template <>
|
||||||
void XmlReader::readDefault(const string &s, string &output)
|
void XmlReader::readDefault(const string &s, string &output)
|
||||||
{
|
{
|
||||||
|
@ -68,6 +68,7 @@ namespace Grid
|
|||||||
virtual ~XmlReader(void) = default;
|
virtual ~XmlReader(void) = default;
|
||||||
void push(const std::string &s);
|
void push(const std::string &s);
|
||||||
void pop(void);
|
void pop(void);
|
||||||
|
bool nextElement(const std::string &s);
|
||||||
template <typename U>
|
template <typename U>
|
||||||
void readDefault(const std::string &s, U &output);
|
void readDefault(const std::string &s, U &output);
|
||||||
template <typename U>
|
template <typename U>
|
||||||
|
@ -35,6 +35,7 @@ Author: neo <cossu@post.kek.jp>
|
|||||||
// Time-stamp: <2015-06-09 14:28:02 neo>
|
// Time-stamp: <2015-06-09 14:28:02 neo>
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Grid {
|
||||||
namespace Optimization {
|
namespace Optimization {
|
||||||
|
|
||||||
template<class vtype>
|
template<class vtype>
|
||||||
@ -243,6 +244,36 @@ namespace Optimization {
|
|||||||
|
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
// Some Template specialization
|
// 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 >
|
template < typename vtype >
|
||||||
void permute(vtype &a, vtype b, int perm) {
|
void permute(vtype &a, vtype b, int perm) {
|
||||||
};
|
};
|
||||||
@ -282,7 +313,6 @@ namespace Optimization {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Here assign types
|
// Here assign types
|
||||||
namespace Grid {
|
|
||||||
|
|
||||||
typedef float SIMD_Ftype; // Single precision type
|
typedef float SIMD_Ftype; // Single precision type
|
||||||
typedef double SIMD_Dtype; // Double precision type
|
typedef double SIMD_Dtype; // Double precision type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user