2022-02-02 18:00:44 +01:00
|
|
|
/*
|
2022-09-05 10:39:42 +02:00
|
|
|
* Copyright (C) 2022 NHR@FAU, University Erlangen-Nuremberg.
|
|
|
|
* All rights reserved. This file is part of MD-Bench.
|
|
|
|
* Use of this source code is governed by a LGPL-3.0
|
|
|
|
* license that can be found in the LICENSE file.
|
2022-02-02 18:00:44 +01:00
|
|
|
*/
|
2022-11-15 00:55:46 +01:00
|
|
|
#ifndef __SIMD_H__
|
|
|
|
#define __SIMD_H__
|
|
|
|
|
2022-04-05 02:57:23 +02:00
|
|
|
#include <stdio.h>
|
2022-03-15 02:40:56 +01:00
|
|
|
#include <stdlib.h>
|
2022-02-02 21:54:18 +01:00
|
|
|
#include <string.h>
|
2022-02-02 18:00:44 +01:00
|
|
|
#include <immintrin.h>
|
2022-11-15 00:55:46 +01:00
|
|
|
|
2022-07-19 02:30:26 +02:00
|
|
|
#ifndef NO_ZMM_INTRIN
|
|
|
|
# include <zmmintrin.h>
|
|
|
|
#endif
|
2022-02-02 18:00:44 +01:00
|
|
|
|
2022-04-05 02:57:23 +02:00
|
|
|
#ifndef CLUSTER_M
|
|
|
|
# define CLUSTER_M 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CLUSTER_N
|
|
|
|
# define CLUSTER_N 1
|
|
|
|
#endif
|
|
|
|
|
2022-11-15 00:55:46 +01:00
|
|
|
#if defined(__ISA_AVX512__)
|
2022-03-16 14:52:55 +01:00
|
|
|
# if PRECISION == 2
|
|
|
|
# include "simd/avx512_double.h"
|
|
|
|
# else
|
|
|
|
# include "simd/avx512_float.h"
|
|
|
|
# endif
|
2022-11-15 00:55:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__ISA_AVX2__)
|
|
|
|
# if PRECISION == 2
|
|
|
|
# include "simd/avx2_double.h"
|
|
|
|
# else
|
|
|
|
# include "simd/avx2_float.h"
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__ISA_AVX__)
|
2022-03-16 14:52:55 +01:00
|
|
|
# if PRECISION == 2
|
2022-11-15 00:55:46 +01:00
|
|
|
# include "simd/avx_double.h"
|
2022-03-16 14:52:55 +01:00
|
|
|
# else
|
2022-11-15 00:55:46 +01:00
|
|
|
# include "simd/avx_float.h"
|
2022-03-16 14:52:55 +01:00
|
|
|
# endif
|
2022-03-02 23:12:04 +01:00
|
|
|
#endif
|
2022-02-04 17:52:48 +01:00
|
|
|
|
2022-03-16 14:52:55 +01:00
|
|
|
#define SIMD_PRINT_REAL(a) simd_print_real(#a, a);
|
|
|
|
#define SIMD_PRINT_MASK(a) simd_print_mask(#a, a);
|
2022-03-15 02:40:56 +01:00
|
|
|
|
2022-02-02 21:54:18 +01:00
|
|
|
static inline void simd_print_real(const char *ref, MD_SIMD_FLOAT a) {
|
2022-02-04 17:52:48 +01:00
|
|
|
double x[VECTOR_WIDTH];
|
2022-02-02 21:54:18 +01:00
|
|
|
memcpy(x, &a, sizeof(x));
|
|
|
|
|
|
|
|
fprintf(stdout, "%s: ", ref);
|
2022-02-04 17:52:48 +01:00
|
|
|
for(int i = 0; i < VECTOR_WIDTH; i++) {
|
2022-02-02 21:54:18 +01:00
|
|
|
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)); }
|
2022-11-15 00:55:46 +01:00
|
|
|
|
|
|
|
#endif // __SIMD_H__
|