Fix exclusion masks and add SIMD debug tools
Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
parent
4c5f013bf4
commit
9daf9e5f4d
4
Makefile
4
Makefile
@ -56,6 +56,10 @@ ifeq ($(strip $(USE_REFERENCE_VERSION)),true)
|
|||||||
DEFINES += -DUSE_REFERENCE_VERSION
|
DEFINES += -DUSE_REFERENCE_VERSION
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(strip $(DEBUG)),true)
|
||||||
|
DEFINES += -DDEBUG
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(VECTOR_WIDTH),)
|
ifneq ($(VECTOR_WIDTH),)
|
||||||
DEFINES += -DVECTOR_WIDTH=$(VECTOR_WIDTH)
|
DEFINES += -DVECTOR_WIDTH=$(VECTOR_WIDTH)
|
||||||
endif
|
endif
|
||||||
|
@ -10,6 +10,8 @@ DATA_TYPE ?= DP
|
|||||||
DATA_LAYOUT ?= AOS
|
DATA_LAYOUT ?= AOS
|
||||||
# Assembly syntax to generate (ATT/INTEL)
|
# Assembly syntax to generate (ATT/INTEL)
|
||||||
ASM_SYNTAX ?= ATT
|
ASM_SYNTAX ?= ATT
|
||||||
|
# Debug
|
||||||
|
DEBUG ?= false
|
||||||
|
|
||||||
# Number of times to run the atoms loop on stubbed variant
|
# Number of times to run the atoms loop on stubbed variant
|
||||||
ATOMS_LOOP_RUNS ?= 1
|
ATOMS_LOOP_RUNS ?= 1
|
||||||
@ -30,7 +32,7 @@ COMPUTE_STATS ?= true
|
|||||||
# AOS or SOA
|
# AOS or SOA
|
||||||
CLUSTER_LAYOUT ?= SOA
|
CLUSTER_LAYOUT ?= SOA
|
||||||
# Use reference version
|
# Use reference version
|
||||||
USE_REFERENCE_VERSION ?= true
|
USE_REFERENCE_VERSION ?= false
|
||||||
|
|
||||||
#Feature options
|
#Feature options
|
||||||
OPTIONS = -DALIGNMENT=64
|
OPTIONS = -DALIGNMENT=64
|
||||||
|
@ -186,10 +186,10 @@ double computeForceLJ_4xn(Parameter *param, Atom *atom, Neighbor *neighbor, Stat
|
|||||||
MD_SIMD_FLOAT dely3 = simd_sub(yi3_tmp, yj_tmp);
|
MD_SIMD_FLOAT dely3 = simd_sub(yi3_tmp, yj_tmp);
|
||||||
MD_SIMD_FLOAT delz3 = simd_sub(zi3_tmp, zj_tmp);
|
MD_SIMD_FLOAT delz3 = simd_sub(zi3_tmp, zj_tmp);
|
||||||
|
|
||||||
MD_SIMD_MASK excl_mask0 = simd_mask_from_u32((unsigned int)(0xff - 0x80 * cond0 - 0x8 * cond1));
|
MD_SIMD_MASK excl_mask0 = simd_mask_from_u32((unsigned int)(0xff - 0x1 * cond0 - 0x10 * cond1));
|
||||||
MD_SIMD_MASK excl_mask1 = simd_mask_from_u32((unsigned int)(0xff - 0x40 * cond0 - 0x4 * cond1));
|
MD_SIMD_MASK excl_mask1 = simd_mask_from_u32((unsigned int)(0xff - 0x2 * cond0 - 0x20 * cond1));
|
||||||
MD_SIMD_MASK excl_mask2 = simd_mask_from_u32((unsigned int)(0xff - 0x20 * cond0 - 0x2 * cond1));
|
MD_SIMD_MASK excl_mask2 = simd_mask_from_u32((unsigned int)(0xff - 0x4 * cond0 - 0x40 * cond1));
|
||||||
MD_SIMD_MASK excl_mask3 = simd_mask_from_u32((unsigned int)(0xff - 0x10 * cond0 - 0x1 * cond1));
|
MD_SIMD_MASK excl_mask3 = simd_mask_from_u32((unsigned int)(0xff - 0x8 * cond0 - 0x80 * cond1));
|
||||||
|
|
||||||
MD_SIMD_FLOAT rsq0 = simd_fma(delx0, delx0, simd_fma(dely0, dely0, simd_mul(delz0, delz0)));
|
MD_SIMD_FLOAT rsq0 = simd_fma(delx0, delx0, simd_fma(dely0, dely0, simd_mul(delz0, delz0)));
|
||||||
MD_SIMD_FLOAT rsq1 = simd_fma(delx1, delx1, simd_fma(dely1, dely1, simd_mul(delz1, delz1)));
|
MD_SIMD_FLOAT rsq1 = simd_fma(delx1, delx1, simd_fma(dely1, dely1, simd_mul(delz1, delz1)));
|
||||||
|
@ -21,11 +21,14 @@
|
|||||||
* =======================================================================================
|
* =======================================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#include <zmmintrin.h>
|
#include <zmmintrin.h>
|
||||||
|
|
||||||
#define MD_SIMD_FLOAT __m512d
|
#define MD_SIMD_FLOAT __m512d
|
||||||
#define MD_SIMD_MASK __mmask8
|
#define MD_SIMD_MASK __mmask8
|
||||||
|
#define SIMD_PRINT_REAL(a) simd_print_real(#a, a);
|
||||||
|
#define SIMD_PRINT_MASK(a) simd_print_mask(#a, a);
|
||||||
|
|
||||||
static inline MD_SIMD_FLOAT simd_broadcast(double scalar) { return _mm512_set1_pd(scalar); }
|
static inline MD_SIMD_FLOAT simd_broadcast(double scalar) { return _mm512_set1_pd(scalar); }
|
||||||
static inline MD_SIMD_FLOAT simd_zero() { return _mm512_set1_pd(0.0); }
|
static inline MD_SIMD_FLOAT simd_zero() { return _mm512_set1_pd(0.0); }
|
||||||
@ -35,7 +38,8 @@ static inline MD_SIMD_FLOAT simd_mul(MD_SIMD_FLOAT a, MD_SIMD_FLOAT b) { return
|
|||||||
static inline MD_SIMD_FLOAT simd_fma(MD_SIMD_FLOAT a, MD_SIMD_FLOAT b, MD_SIMD_FLOAT c) { return _mm512_fmadd_pd(a, b, c); }
|
static inline MD_SIMD_FLOAT simd_fma(MD_SIMD_FLOAT a, MD_SIMD_FLOAT b, MD_SIMD_FLOAT c) { return _mm512_fmadd_pd(a, b, c); }
|
||||||
static inline MD_SIMD_FLOAT simd_reciprocal(MD_SIMD_FLOAT a) { return _mm512_rcp14_pd(a); }
|
static inline MD_SIMD_FLOAT simd_reciprocal(MD_SIMD_FLOAT a) { return _mm512_rcp14_pd(a); }
|
||||||
static inline MD_SIMD_FLOAT simd_masked_add(MD_SIMD_FLOAT a, MD_SIMD_FLOAT b, MD_SIMD_MASK m) { return _mm512_mask_add_pd(a, m, a, b); }
|
static inline MD_SIMD_FLOAT simd_masked_add(MD_SIMD_FLOAT a, MD_SIMD_FLOAT b, MD_SIMD_MASK m) { return _mm512_mask_add_pd(a, m, a, b); }
|
||||||
static inline MD_SIMD_MASK simd_mask_from_u32(unsigned int m) { return _cvtu32_mask8(m); }
|
static inline MD_SIMD_MASK simd_mask_from_u32(unsigned int a) { return _cvtu32_mask8(a); }
|
||||||
|
static inline MD_SIMD_MASK simd_mask_to_u32(unsigned int a) { return _cvtmask8_u32(a); }
|
||||||
static inline MD_SIMD_MASK simd_mask_and(MD_SIMD_MASK a, MD_SIMD_MASK b) { return _kand_mask8(a, b); }
|
static inline MD_SIMD_MASK simd_mask_and(MD_SIMD_MASK a, MD_SIMD_MASK b) { return _kand_mask8(a, b); }
|
||||||
static inline MD_SIMD_MASK simd_mask_cond_lt(MD_SIMD_FLOAT a, MD_SIMD_FLOAT b) { return _mm512_cmp_pd_mask(a, b, _CMP_LT_OQ); }
|
static inline MD_SIMD_MASK simd_mask_cond_lt(MD_SIMD_FLOAT a, MD_SIMD_FLOAT b) { return _mm512_cmp_pd_mask(a, b, _CMP_LT_OQ); }
|
||||||
|
|
||||||
@ -59,3 +63,17 @@ static inline MD_FLOAT simd_horizontal_sum(MD_SIMD_FLOAT a) {
|
|||||||
x = _mm512_add_pd(x, _mm512_permute_pd(x, 0x01));
|
x = _mm512_add_pd(x, _mm512_permute_pd(x, 0x01));
|
||||||
return *((double *) &x);
|
return *((double *) &x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void simd_print_real(const char *ref, MD_SIMD_FLOAT a) {
|
||||||
|
double x[8];
|
||||||
|
memcpy(x, &a, sizeof(x));
|
||||||
|
|
||||||
|
fprintf(stdout, "%s: ", ref);
|
||||||
|
for(int i = 0; i < 8; i++) {
|
||||||
|
fprintf(stdout, "%f ", x[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void simd_print_mask(const char *ref, MD_SIMD_MASK a) { fprintf(stdout, "%s: %x\n", ref, simd_mask_to_u32(a)); }
|
||||||
|
@ -33,9 +33,9 @@
|
|||||||
#define ABS(a) ((a) >= 0 ? (a) : -(a))
|
#define ABS(a) ((a) >= 0 ? (a) : -(a))
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DEBUG_MESSAGE(msg) printf
|
#define DEBUG_MESSAGE printf
|
||||||
#else
|
#else
|
||||||
#define DEBUG_MESSAGE(msg)
|
#define DEBUG_MESSAGE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FF_LJ 0
|
#define FF_LJ 0
|
||||||
|
Loading…
Reference in New Issue
Block a user