mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Split all OMP directives into lattice subdir for easy maintainance of
parallelism and future OMP 4.0 offload.
This commit is contained in:
parent
4e1a3aee82
commit
f64d39ab57
@ -1,5 +1,6 @@
|
|||||||
#ifndef GRID_COMPARISON_H
|
#ifndef GRID_COMPARISON_H
|
||||||
#define GRID_COMPARISON_H
|
#define GRID_COMPARISON_H
|
||||||
|
|
||||||
namespace Grid {
|
namespace Grid {
|
||||||
|
|
||||||
// Generic list of functors
|
// Generic list of functors
|
||||||
@ -132,133 +133,8 @@ namespace Grid {
|
|||||||
{
|
{
|
||||||
return Comparison(sne<Integer,Integer>(),lhs,rhs);
|
return Comparison(sne<Integer,Integer>(),lhs,rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
// relational operators
|
|
||||||
//
|
|
||||||
// Support <,>,<=,>=,==,!=
|
|
||||||
//
|
|
||||||
//Query supporting bitwise &, |, ^, !
|
|
||||||
//Query supporting logical &&, ||,
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
template<class vfunctor,class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> LLComparison(vfunctor op,const Lattice<lobj> &lhs,const Lattice<robj> &rhs)
|
|
||||||
{
|
|
||||||
Lattice<vInteger> ret(rhs._grid);
|
|
||||||
#pragma omp parallel for
|
|
||||||
for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
|
||||||
ret._odata[ss]=op(lhs._odata[ss],rhs._odata[ss]);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
template<class vfunctor,class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> LSComparison(vfunctor op,const Lattice<lobj> &lhs,const robj &rhs)
|
|
||||||
{
|
|
||||||
Lattice<vInteger> ret(lhs._grid);
|
|
||||||
#pragma omp parallel for
|
|
||||||
for(int ss=0;ss<lhs._grid->oSites(); ss++){
|
|
||||||
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
template<class vfunctor,class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> SLComparison(vfunctor op,const lobj &lhs,const Lattice<robj> &rhs)
|
|
||||||
{
|
|
||||||
Lattice<vInteger> ret(rhs._grid);
|
|
||||||
#pragma omp parallel for
|
|
||||||
for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
|
||||||
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Less than
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator < (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vlt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator < (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vlt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator < (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vlt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Less than equal
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator <= (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vle<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator <= (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vle<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator <= (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vle<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Greater than
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator > (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vgt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator > (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vgt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator > (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vgt<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Greater than equal
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator >= (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vge<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator >= (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vge<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator >= (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vge<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// equal
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator == (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(veq<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator == (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(veq<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator == (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(veq<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// not equal
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator != (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return LLComparison(vne<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator != (const Lattice<lobj> & lhs, const robj & rhs) {
|
|
||||||
return LSComparison(vne<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
template<class lobj,class robj>
|
|
||||||
inline Lattice<vInteger> operator != (const lobj & lhs, const Lattice<robj> & rhs) {
|
|
||||||
return SLComparison(vne<lobj,robj>(),lhs,rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <lattice/Grid_lattice_comparison.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "Grid.h"
|
#include <Grid.h>
|
||||||
|
|
||||||
#undef __X86_64
|
#undef __X86_64
|
||||||
namespace Grid {
|
namespace Grid {
|
||||||
|
133
lib/lattice/Grid_lattice_comparison.h
Normal file
133
lib/lattice/Grid_lattice_comparison.h
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
#ifndef GRID_LATTICE_COMPARISON_H
|
||||||
|
#define GRID_LATTICE_COMPARISON_H
|
||||||
|
|
||||||
|
namespace Grid {
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// relational operators
|
||||||
|
//
|
||||||
|
// Support <,>,<=,>=,==,!=
|
||||||
|
//
|
||||||
|
//Query supporting bitwise &, |, ^, !
|
||||||
|
//Query supporting logical &&, ||,
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class vfunctor,class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> LLComparison(vfunctor op,const Lattice<lobj> &lhs,const Lattice<robj> &rhs)
|
||||||
|
{
|
||||||
|
Lattice<vInteger> ret(rhs._grid);
|
||||||
|
#pragma omp parallel for
|
||||||
|
for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
||||||
|
ret._odata[ss]=op(lhs._odata[ss],rhs._odata[ss]);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template<class vfunctor,class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> LSComparison(vfunctor op,const Lattice<lobj> &lhs,const robj &rhs)
|
||||||
|
{
|
||||||
|
Lattice<vInteger> ret(lhs._grid);
|
||||||
|
#pragma omp parallel for
|
||||||
|
for(int ss=0;ss<lhs._grid->oSites(); ss++){
|
||||||
|
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
template<class vfunctor,class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> SLComparison(vfunctor op,const lobj &lhs,const Lattice<robj> &rhs)
|
||||||
|
{
|
||||||
|
Lattice<vInteger> ret(rhs._grid);
|
||||||
|
#pragma omp parallel for
|
||||||
|
for(int ss=0;ss<rhs._grid->oSites(); ss++){
|
||||||
|
ret._odata[ss]=op(lhs._odata[ss],rhs);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Less than
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator < (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vlt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator < (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vlt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator < (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vlt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Less than equal
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator <= (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vle<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator <= (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vle<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator <= (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vle<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Greater than
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator > (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vgt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator > (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vgt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator > (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vgt<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Greater than equal
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator >= (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vge<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator >= (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vge<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator >= (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vge<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// equal
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator == (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(veq<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator == (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(veq<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator == (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(veq<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// not equal
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator != (const Lattice<lobj> & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return LLComparison(vne<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator != (const Lattice<lobj> & lhs, const robj & rhs) {
|
||||||
|
return LSComparison(vne<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
template<class lobj,class robj>
|
||||||
|
inline Lattice<vInteger> operator != (const lobj & lhs, const Lattice<robj> & rhs) {
|
||||||
|
return SLComparison(vne<lobj,robj>(),lhs,rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user