aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-11-19 11:19:14 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2023-11-19 11:19:14 +0100
commita9ce50120b68db3669aaadeac348db8926bc15c4 (patch)
tree33cd118de37634970503553197370776564bce10
parentc5fb4d1c0f0ecc30673a46e517dc82c5af2af5ef (diff)
downloadnissy-core-a9ce50120b68db3669aaadeac348db8926bc15c4.tar.gz
nissy-core-a9ce50120b68db3669aaadeac348db8926bc15c4.zip
Improved architecture detection
-rwxr-xr-xconfigure.sh7
-rw-r--r--cube.c8
-rw-r--r--utils/detect-immintrin.c5
3 files changed, 9 insertions, 11 deletions
diff --git a/configure.sh b/configure.sh
index 9a790ca..b9779c2 100755
--- a/configure.sh
+++ b/configure.sh
@@ -1,8 +1,13 @@
1#!/bin/sh 1#!/bin/sh
2 2
3cc -mavx2 utils/detect-immintrin.c && detected="AVX2" && rm a.out 3detect() { cc -march=native -dM -E - < /dev/null | grep "$1"; }
4
5[ -n "$(detect __AVX2__)" ] && detected="AVX2"
6
4TYPE=${TYPE-"$detected"} 7TYPE=${TYPE-"$detected"}
5 8
9echo "Using CUBE_$TYPE"
10
6STD="-std=c99" 11STD="-std=c99"
7WFLAGS="-pedantic -Wall -Wextra -Wno-unused-parameter -Wno-unused-function" 12WFLAGS="-pedantic -Wall -Wextra -Wno-unused-parameter -Wno-unused-function"
8[ "$TYPE" = "AVX2" ] && AVX="-mavx2" 13[ "$TYPE" = "AVX2" ] && AVX="-mavx2"
diff --git a/cube.c b/cube.c
index b5a30a6..895c088 100644
--- a/cube.c
+++ b/cube.c
@@ -2,9 +2,7 @@
2#include <stdbool.h> 2#include <stdbool.h>
3#include <string.h> 3#include <string.h>
4 4
5#ifdef CUBE_AVX2 5#include "cube.h"
6#include <immintrin.h>
7#endif
8 6
9#ifdef DEBUG 7#ifdef DEBUG
10#include <stdio.h> 8#include <stdio.h>
@@ -25,8 +23,6 @@
25#define DBG_ASSERT(condition, retval, ...) 23#define DBG_ASSERT(condition, retval, ...)
26#endif 24#endif
27 25
28#include "cube.h"
29
30/****************************************************************************** 26/******************************************************************************
31Section: constants, strings and other stuff 27Section: constants, strings and other stuff
32******************************************************************************/ 28******************************************************************************/
@@ -495,6 +491,8 @@ Note: the #ifdef below is closed in the next section.
495 491
496#ifdef CUBE_AVX2 492#ifdef CUBE_AVX2
497 493
494#include <immintrin.h>
495
498typedef __m256i cube_fast_t; 496typedef __m256i cube_fast_t;
499 497
500#define _co2_avx2 _mm256_set_epi64x(0, 0, 0, 0x6060606060606060) 498#define _co2_avx2 _mm256_set_epi64x(0, 0, 0, 0x6060606060606060)
diff --git a/utils/detect-immintrin.c b/utils/detect-immintrin.c
deleted file mode 100644
index 20da678..0000000
--- a/utils/detect-immintrin.c
+++ /dev/null
@@ -1,5 +0,0 @@
1#include <immintrin.h>
2
3int main() {
4 return 0;
5}

Generated with cgit - Back to sebastiano.tronto.net