Migrate package to Nim 2.2.0 (bench 5041843)

This commit is contained in:
2025-01-17 11:50:32 +01:00
parent cca013d103
commit aba893c988
45 changed files with 152 additions and 135 deletions

6
.gitattributes vendored
View File

@@ -1,5 +1,5 @@
*.zstd filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
heimdall/heimdallpkg/resources/Pohl.epd.zip filter=lfs diff=lfs merge=lfs -text
heimdall/heimdallpkg/resources/8moves_v3.epd.zip filter=lfs diff=lfs merge=lfs -text
heimdall/heimdallpkg/resources/E12.46FRC-1250k-D12-1s-Resolved.zip filter=lfs diff=lfs merge=lfs -text
heimdall/heimdall/resources/Pohl.epd.zip filter=lfs diff=lfs merge=lfs -text
heimdall/heimdall/resources/8moves_v3.epd.zip filter=lfs diff=lfs merge=lfs -text
heimdall/heimdall/resources/E12.46FRC-1250k-D12-1s-Resolved.zip filter=lfs diff=lfs merge=lfs -text

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"makefile.configureOnOpen": false
}

View File

@@ -1,13 +1,13 @@
{
"private" : false,
"nps" : 219064,
"nps" : 455004,
"source" : "https://github.com/nocturn9x/heimdall",
"build" : {
"path" : "",
"compilers" : ["clang"],
"cpuflags" : ["POPCNT"],
"systems" : ["Linux"]
"compilers" : ["nim"],
"cpuflags" : ["POPCNT", "AVX2"],
"systems" : ["Linux", "Windows"]
},
"test_presets" : {
@@ -38,31 +38,46 @@
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "8.0+0.08",
"workload_size" : 32,
"book_name" : "8moves_v3.epd",
"test_max_games" : 40000
"book_name" : "UHO_Lichess_4852_v1.epd",
"test_bounds" : "[-5.00, 0.00]"
},
"LTC Regression" : {
"both_options" : "Threads=1 Hash=64",
"both_time_control" : "40+0.4",
"workload_size" : 8,
"book_name" : "8moves_v3.epd",
"test_max_games" : 40000
"book_name" : "UHO_Lichess_4852_v1.epd",
"test_bounds" : "[-5.00, 0.00]"
},
"STC Fixed Games" : {
"STC Fixed Games (1000)" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "8.0+0.08",
"workload_size" : 32,
"test_max_games" : 1000
},
"LTC Fixed Games" : {
"STC Fixed Games (2000)" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "8.0+0.08",
"workload_size" : 32,
"test_max_games" : 2000
},
"LTC Fixed Games (1000)" : {
"both_options" : "Threads=1 Hash=64",
"both_time_control" : "40.0+0.4",
"workload_size" : 8,
"test_max_games" : 1000
},
"LTC Fixed Games (2000)" : {
"both_options" : "Threads=1 Hash=64",
"both_time_control" : "40.0+0.4",
"workload_size" : 8,
"test_max_games" : 2000
}
},
"tune_presets" : {

View File

@@ -6,7 +6,7 @@ CC := clang
EXE := bin/heimdall
EVALFILE := ../hofud-v2.bin
LD := ld
SRCDIR := heimdall
SRCDIR := src
LFLAGS := -flto -fuse-ld=$(LD)
NFLAGS := --cc:$(CC) --mm:atomicArc -d:useMalloc -o:$(EXE) -d:evalFile=$(EVALFILE)

View File

@@ -11,8 +11,9 @@ let me know should that not be the case), sitting around the top 60 rank globall
## Building and Installation
Just run `make`, this is the easiest (Nim 2.0.4 is required, see [here](https://github.com/dom96/choosenim)). It will
build the most optimized executable possible, but AVX2 support is expected on the target platform.
Just run `make`, this is the easiest (Nim 2.2.0 is required, see [here](https://github.com/dom96/choosenim)). It will
build the most optimized executable possible, but AVX2 support is expected on the target platform. Heimdall also requires
the clang compiler to be built, as executables generated by gcc are horrendously slow for some reason.
You can also run `make modern` to build a modern version of Heimdall with a more generic instruction set (AVX2 support is still required here,
the target architecture will just not be `native`). This will allow the generated executable to run without issues on systems without the exact CPU
@@ -28,6 +29,10 @@ own binary directory is in your system's path), which will build the same execut
legacy/generic installation support as of now)
**P.P.S**: You should also be able to use Heimdall as a library: the code is decently documented (although I don't recommend
you do, as it was not designed for this, and especially search/eval is a bit hacky in some places). Let me know if you have
trouble
## Testing
Just run `nimble test`: sit back, relax, get yourself a cup of coffee and wait for it to finish (it WILL take a long time :))

View File

@@ -5,7 +5,7 @@ version = "1.2.2"
author = "nocturn9x"
description = "A UCI chess engine written in nim"
license = "Apache-2.0"
srcDir = "heimdall"
srcDir = "src"
binDir = "bin"
installExt = @["nim"]
bin = @["heimdall"]
@@ -13,7 +13,7 @@ bin = @["heimdall"]
# Dependencies
requires "nim >= 2.0.4"
requires "nim >= 2.2.0"
requires "jsony == 1.1.5"
requires "nint128 == 0.3.3"
requires "struct == 0.2.3"

View File

@@ -6,7 +6,7 @@
-d:useMalloc
--mm:atomicArc
--deepcopy:on
--path="heimdall"
--path="src"
-d:majorVersion=1
-d:minorVersion=2
-d:patchVersion=2

View File

@@ -12,23 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import heimdallpkg/tui
import heimdallpkg/movegen
import heimdallpkg/bitboards
import heimdallpkg/moves
import heimdallpkg/pieces
import heimdallpkg/magics
import heimdallpkg/rays
import heimdallpkg/position
import heimdallpkg/board
import heimdallpkg/transpositions
import heimdallpkg/search
import heimdallpkg/eval
import heimdallpkg/util/tunables
import heimdallpkg/uci
import heimdallpkg/datagen/generate
import heimdallpkg/datagen/tool
import heimdallpkg/util/limits
import heimdall/tui
import heimdall/movegen
import heimdall/moves
import heimdall/magics
import heimdall/position
import heimdall/board
import heimdall/transpositions
import heimdall/search
import heimdall/eval
import heimdall/util/tunables
import heimdall/uci
import heimdall/datagen/generate
import heimdall/datagen/tool
import heimdall/util/limits
import std/os
@@ -42,15 +39,12 @@ import std/strformat
import std/options
export tui, movegen, bitboards, moves, pieces, magics, rays, position, board, transpositions, search, eval, uci, tunables
when defined(mimalloc):
{.link: "../mimalloc.o".}
{.warning: "-d:mimalloc switch enabled, statically linking mimalloc".}
const benchFens = staticRead("heimdallpkg/resources/misc/bench.txt").splitLines()
const benchFens = staticRead("heimdall/resources/misc/bench.txt").splitLines()
proc runBench(depth: int = 13) =

View File

@@ -14,13 +14,13 @@
## Implementation of a simple chessboard
import heimdallpkg/pieces
import heimdallpkg/magics
import heimdallpkg/moves
import heimdallpkg/rays
import heimdallpkg/bitboards
import heimdallpkg/position
import heimdallpkg/zobrist
import heimdall/pieces
import heimdall/magics
import heimdall/moves
import heimdall/rays
import heimdall/bitboards
import heimdall/position
import heimdall/zobrist

View File

@@ -11,8 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import heimdallpkg/eval
import heimdallpkg/pieces
import heimdall/eval
import heimdall/pieces
import std/options

View File

@@ -12,17 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import heimdallpkg/search
import heimdallpkg/uci
import heimdallpkg/board
import heimdallpkg/eval
import heimdallpkg/movegen
import heimdallpkg/transpositions
import heimdallpkg/util/tunables
import heimdallpkg/datagen/scharnagl
import heimdallpkg/datagen/marlinformat
import heimdallpkg/datagen/adjudication
import heimdallpkg/util/limits
import heimdall/search
import heimdall/uci
import heimdall/board
import heimdall/eval
import heimdall/movegen
import heimdall/transpositions
import heimdall/util/tunables
import heimdall/datagen/scharnagl
import heimdall/datagen/marlinformat
import heimdall/datagen/adjudication
import heimdall/util/limits
import std/os

View File

@@ -20,8 +20,8 @@ import std/algorithm
import struct
import heimdallpkg/pieces
import heimdallpkg/position
import heimdall/pieces
import heimdall/position
const RECORD_SIZE* = 32

View File

@@ -14,7 +14,7 @@
# This code also comes from the analog brain of a certain code horse. Many thanks!
import heimdallpkg/pieces
import heimdall/pieces
import std/enumerate
import std/strformat

View File

@@ -23,9 +23,9 @@ import std/times
import std/options
import heimdallpkg/datagen/marlinformat
import heimdallpkg/eval
import heimdallpkg/pieces
import heimdall/datagen/marlinformat
import heimdall/eval
import heimdall/pieces
proc runDataTool*(dataFile: string, filterScores: tuple[min, max: Score], dryRun: bool = false, outputName = "filtered.bin", limit: Option[int]) =

View File

@@ -13,16 +13,16 @@
# limitations under the License.
## Position evaluation utilities
import heimdallpkg/pieces
import heimdallpkg/position
import heimdallpkg/board
import heimdallpkg/moves
import heimdallpkg/nnue/util
import heimdall/pieces
import heimdall/position
import heimdall/board
import heimdall/moves
import heimdall/nnue/util
import nnue/model
when defined(simd):
import heimdallpkg/util/simd
import heimdall/util/simd
import std/streams

View File

@@ -16,8 +16,8 @@
# Blatantly stolen from this amazing article: https://analog-hors.github.io/site/magic-bitboards/
import heimdallpkg/bitboards
import heimdallpkg/pieces
import heimdall/bitboards
import heimdall/pieces
import std/options

View File

@@ -19,15 +19,15 @@ import std/strutils
import std/tables
import heimdallpkg/bitboards
import heimdallpkg/board
import heimdallpkg/magics
import heimdallpkg/pieces
import heimdallpkg/moves
import heimdallpkg/position
import heimdallpkg/rays
import heimdallpkg/see
import heimdallpkg/datagen/marlinformat
import heimdall/bitboards
import heimdall/board
import heimdall/magics
import heimdall/pieces
import heimdall/moves
import heimdall/position
import heimdall/rays
import heimdall/see
import heimdall/datagen/marlinformat
export bitboards, magics, pieces, moves, position, rays, board

View File

@@ -13,7 +13,7 @@
# limitations under the License.
## Handling of moves
import heimdallpkg/pieces
import heimdall/pieces
import std/strformat

View File

@@ -14,7 +14,7 @@
# Thanks @analog-hors for the contribution! The code below is heavily derived from hers :)
import heimdallpkg/pieces
import heimdall/pieces
const

View File

@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import heimdallpkg/nnue/model
import heimdall/nnue/model
import std/endians

View File

@@ -15,12 +15,12 @@ import std/strformat
import std/strutils
import heimdallpkg/bitboards
import heimdallpkg/magics
import heimdallpkg/pieces
import heimdallpkg/zobrist
import heimdallpkg/moves
import heimdallpkg/rays
import heimdall/bitboards
import heimdall/magics
import heimdall/pieces
import heimdall/zobrist
import heimdall/moves
import heimdall/rays
export bitboards, magics, pieces, zobrist, moves, rays

View File

@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import heimdallpkg/bitboards
import heimdallpkg/magics
import heimdallpkg/pieces
import heimdall/bitboards
import heimdall/magics
import heimdall/pieces
export bitboards, pieces

View File

@@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import heimdallpkg/see
import heimdallpkg/eval
import heimdallpkg/board
import heimdallpkg/util/limits
import heimdallpkg/util/wdl
import heimdallpkg/util/tunables
import heimdallpkg/util/shared
import heimdallpkg/util/aligned
import heimdallpkg/transpositions
import heimdallpkg/movegen
import heimdall/see
import heimdall/eval
import heimdall/board
import heimdall/util/limits
import heimdall/util/wdl
import heimdall/util/tunables
import heimdall/util/shared
import heimdall/util/aligned
import heimdall/transpositions
import heimdall/movegen
import std/math

View File

@@ -16,9 +16,9 @@
import std/algorithm
import heimdallpkg/position
import heimdallpkg/pieces
import heimdallpkg/board
import heimdall/position
import heimdall/pieces
import heimdall/board

View File

@@ -16,9 +16,9 @@
import std/options
import heimdallpkg/zobrist
import heimdallpkg/eval
import heimdallpkg/moves
import heimdall/zobrist
import heimdall/eval
import heimdall/moves
import nint128

View File

@@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import heimdallpkg/movegen
import heimdallpkg/eval
import heimdallpkg/uci
import heimdallpkg/datagen/scharnagl
import heimdallpkg/nnue/model
import heimdall/movegen
import heimdall/eval
import heimdall/uci
import heimdall/datagen/scharnagl
import heimdall/nnue/model
import std/strformat

View File

@@ -24,14 +24,14 @@ import std/random
randomize()
import heimdallpkg/board
import heimdallpkg/movegen
import heimdallpkg/search
import heimdallpkg/eval
import heimdallpkg/util/tunables
import heimdallpkg/util/limits
import heimdallpkg/util/aligned
import heimdallpkg/transpositions
import heimdall/board
import heimdall/movegen
import heimdall/search
import heimdall/eval
import heimdall/util/tunables
import heimdall/util/limits
import heimdall/util/aligned
import heimdall/transpositions
type

View File

@@ -19,10 +19,10 @@ import std/times
import std/options
import heimdallpkg/moves
import heimdallpkg/eval
import heimdallpkg/util/shared
import heimdallpkg/util/tunables
import heimdall/moves
import heimdall/eval
import heimdall/util/shared
import heimdall/util/tunables
type

View File

@@ -17,9 +17,9 @@ import std/atomics
import std/monotimes
import heimdallpkg/eval
import heimdallpkg/moves
import heimdallpkg/pieces
import heimdall/eval
import heimdall/moves
import heimdall/pieces
# Shared constants

View File

@@ -26,7 +26,7 @@ when defined(avx2):
# Since Nim has apparently no way to grab the size of M256i using its own sizeof(),
# we have to fallback to writing a minimal C file from which we can then import the
# value
var sz* {.header:"heimdallpkg/util/simd_avx2_size.h", importc:"CHUNK_SIZE".}: cint
var sz* {.header:"heimdall/util/simd_avx2_size.h", importc:"CHUNK_SIZE".}: cint
let CHUNK_SIZE* = int(sz)
# Routines blatantly stolen from Alexandria. Many thanks cj!

View File

@@ -1,5 +1,5 @@
import heimdallpkg/eval
import heimdallpkg/util/shared
import heimdall/eval
import heimdall/util/shared
import std/sequtils

View File

@@ -17,7 +17,7 @@
import std/random
import heimdallpkg/pieces
import heimdall/pieces
type