Skip to content

Commit

Permalink
一応Linuxでコンパイルしてみた
Browse files Browse the repository at this point in the history
g++用makefileを追加、g++にない関数をinline asemblerで追加。
文字コードがSJISになっているものが多い気がするので、環境依存はありそうです。
  • Loading branch information
YasuhiroIke committed Jan 14, 2017
1 parent 6062a31 commit b45182b
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# なのはminiにするときはNANOHAMINI=1の前の#を取り、
# なのはnanoにするときはNANOHAMINI=1の前に#を付け、NANOHANANO=1の前の#を取る
# nanoperyにするときはNANOPERY=1の前の#を取る
#
#NANOHAMINI=1
#NANOHANANO=1

EVAL_TYPE=EVAL_APERY
EVAL_OBJ=evaluate_apery.o
EXE = usapyon2dashAVX
PGD = usapyon2dashAVX.pgd
PGOLOG = usapyon2dashAVX_prof.txt

OBJS = mate1ply.o misc.o timeman.o $(EVAL_OBJ) position.o \
tt.o main.o move.o \
movegen.o search.o uci.o movepick.o thread.o ucioption.o \
benchmark.o book.o \
shogi.o mate.o problem.o

CC=g++
LD=link



# Compile Options
#
# -DEVAL_MINI なのはmini(2駒関係(KP+PP)の評価関数)
# -DEVAL_NANO なのはnano(2駒関係(KPのみ)の評価関数)
# -DEVAL_APERY nanopery(Aperyの評価関数)
#
# -DTWIG Apery(大樹の枝)の評価関数を使う
# -DUSE_AVX2_EVAL 評価関数の計算時にAVX命令を使う
#
# Visual C++オプション
#
# /D_CRT_SECURE_NO_WARNINGS
# secureな関数を使っていないときの警告を出さない
# /Zc:forScope スコープ ループに標準 C++ を適用する
# /Wall 警告をすべて有効にする
# /GS[-] セキュリティ チェックを有効にする
# /favor:<blend|AMD64|EM64T> 最適化するプロセッサ
# /GL[-] リンク時のコード生成を行う
# /RTCs スタック フレーム ランタイム チェック
# /RTCu 初期化されていないローカル変数のチェック

FLAGS = -DNDEBUG -D$(EVAL_TYPE) -DUSAPYON2 -DNANOHA -DCHK_PERFORM -DTWIG -DUSE_AVX2_EVAL\
-DOLD_LOCKS \

#CXXFLAGS=$(FLAGS) /MT /W4 /Wall /nologo /Od /GS /RTCsu
CXXFLAGS=$(FLAGS) -O3 -DIS_64BIT -msse -std=c++11 -mavx2 -Wa,-q -c
LDFLAGS=-lpthread -o$(EXE)
PGOLDFLAGS1=/NOLOGO /STACK:16777216,32768 /out:$(EXE) /LTCG:PGI
PGOLDFLAGS2=/NOLOGO /STACK:16777216,32768 /out:$(EXE) /LTCG:PGO


all: $(EXE)

$(EXE) : $(OBJS)
$(CC) -o $@ $(OBJS) $(LDFLAGS)

.cpp.o :
$(CC) $(CXXFLAGS) $*.cpp

clean :
rm -f *.o
rm -f $(EXE)

34 changes: 34 additions & 0 deletions src/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,40 @@ class PRNG {
{ return T(rand64() & rand64() & rand64()); }
};

#ifdef _MSC_VER
#include <intrin.h>
#ifdef _WIN64
#pragma intrinsic(_BitScanForward64)
#pragma intrinsic(_BitScanReverse64)
#define USING_INTRINSICS
#endif
#elif defined(__GNUC__) && defined(__LP64__)
static inline unsigned char _BitScanForward64(unsigned long* Index, uint64_t Mask)
{
uint64_t Ret;
__asm__
(
"bsfq %[Mask], %[Ret]"
:[Ret] "=r" (Ret)
:[Mask] "mr" (Mask)
);
*Index = (unsigned long)Ret;
return Mask?1:0;
}
static inline unsigned char _BitScanReverse64(unsigned long* Index, uint64_t Mask)
{
uint64_t Ret;
__asm__
(
"bsrq %[Mask], %[Ret]"
:[Ret] "=r" (Ret)
:[Mask] "mr" (Mask)
);
*Index = (unsigned long)Ret;
return Mask?1:0;
}
#define USING_INTRINSICS
#endif

inline unsigned long lsb(int64_t b) {
unsigned long idx;
Expand Down
5 changes: 5 additions & 0 deletions src/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
#include <memory> // For std::unique_ptr
#include <string>

#ifdef _MSC_VER
#else
#include <immintrin.h> // AVX2
#endif

#ifndef NANOHA
#include "bitboard.h"
#endif
Expand Down

0 comments on commit b45182b

Please sign in to comment.