Skip to content

Commit

Permalink
Revert "Auto-detect PEXT"
Browse files Browse the repository at this point in the history
Also provide a CC hook for compiler.
  • Loading branch information
lucasart committed Nov 24, 2019
1 parent 454b53f commit 06dab81
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion official
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ popcnt:
$(CC) -mpopcnt $(CF) -DVERSION=\"$(VERSION)\" ./src/*.c -o $(EXE) -static $(LF)

pext:
$(CC) -mpopcnt -mbmi2 $(CF) -DVERSION=\"$(VERSION)\" ./src/*.c -o $(EXE) -static $(LF)
$(CC) -mpopcnt -mbmi2 -DPEXT $(CF) -DVERSION=\"$(VERSION)\" ./src/*.c -o $(EXE) -static $(LF)

clean:
rm $(EXE)
4 changes: 2 additions & 2 deletions src/bitboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <stdio.h>
#include "bitboard.h"

#ifdef __BMI2__
#ifdef PEXT
#include <immintrin.h> // Header for _pext_u64() intrinsic
#endif

Expand Down Expand Up @@ -101,7 +101,7 @@ static bitboard_t slider_attacks(int square, bitboard_t occ, const int dir[4][2]

static int slider_index(bitboard_t occ, bitboard_t mask, bitboard_t magic, unsigned shift)
{
#ifdef __BMI2__
#ifdef PEXT
(void)magic, (void)shift; // Silence compiler warnings (unused variables)
return _pext_u64(occ, mask);
#else
Expand Down
16 changes: 7 additions & 9 deletions src/makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# makefile for dev and OpenBench

# TODO:
# * auto-detect compiler: clang if available (8% faster), otherwise gcc. For now assume gcc only
# for openbench.
# Compiler: gcc by default (for OpenBench), but clang produces faster code
CC = gcc

# Compilation flags
CF = -std=gnu11 -DNDEBUG -O3 -flto -Wfatal-errors -Wall -Wextra -Wshadow
Expand All @@ -13,14 +12,13 @@ LF = -s -lm -lpthread
# EXE is the hook used by OpenBench to specify the output file name
EXE = demolito

# POPCNT: auto-detection (for both targets), thanks to march=native and compiler intrinsic.
# PEXT: off for openbench target (we can't assume that all OpenBench workers have it).
# pext is only for Intel CPU with BMI2 support (haswell+). Do not use it for AMD.

openbench:
gcc -march=native $(CF) -DVERSION=\"dev\" ./*.c -o $(EXE) $(LF)
default:
$(CC) -march=native $(CF) -DVERSION=\"dev\" ./*.c -o $(EXE) $(LF)

dev:
clang -march=native $(CF) -DVERSION=\"dev\" ./*.c -o $(EXE) $(LF)
pext:
$(CC) -march=native -DPEXT $(CF) -DVERSION=\"dev\" ./*.c -o $(EXE) $(LF)

clean:
rm $(EXE)

0 comments on commit 06dab81

Please sign in to comment.