From a179f40f7d690a67c657e10c15631c5b15a6dda6 Mon Sep 17 00:00:00 2001 From: dhb <1084714805@qq.com> Date: Fri, 7 Jun 2024 12:13:28 +0800 Subject: [PATCH] kick version to 0.41.01 [skip_fishtest] --- Rapfi/CMakeLists.txt | 2 +- Rapfi/command/gomocup.cpp | 5 +- Rapfi/config.cpp | 5 +- Rapfi/core/utils.h | 12 ++++ Rapfi/core/version.cpp | 120 +++++++++++++++++++++++++++++++++++++ Rapfi/core/version.h | 32 ---------- Rapfi/search/hashtable.cpp | 1 - 7 files changed, 137 insertions(+), 40 deletions(-) create mode 100644 Rapfi/core/version.cpp delete mode 100644 Rapfi/core/version.h diff --git a/Rapfi/CMakeLists.txt b/Rapfi/CMakeLists.txt index aca33abc..2daa9e64 100644 --- a/Rapfi/CMakeLists.txt +++ b/Rapfi/CMakeLists.txt @@ -40,6 +40,7 @@ set(CORE_SOURCES core/iohelper.cpp core/utils.cpp core/platform.cpp + core/version.cpp database/dbclient.cpp database/dbutils.cpp @@ -93,7 +94,6 @@ set(HEADERS core/pos.h core/types.h core/utils.h - core/version.h database/cache.h database/dbclient.h diff --git a/Rapfi/command/gomocup.cpp b/Rapfi/command/gomocup.cpp index a2395109..c5ccaaa1 100644 --- a/Rapfi/command/gomocup.cpp +++ b/Rapfi/command/gomocup.cpp @@ -19,7 +19,6 @@ #include "../config.h" #include "../core/iohelper.h" #include "../core/utils.h" -#include "../core/version.h" #include "../database/dbclient.h" #include "../database/dbutils.h" #include "../database/yxdbstorage.h" @@ -170,7 +169,7 @@ void think(Board &board, void setGUIMode() { - MESSAGEL("Rapfi Engine Ver " CURRENT_VER); + MESSAGEL("Rapfi " << getVersionInfo()); MESSAGEL("INFO MAX_THREAD_NUM 256"); MESSAGEL("INFO MAX_HASH_SIZE 30"); GUIMode = true; @@ -1280,7 +1279,7 @@ extern "C" bool gomocupLoopOnce() && cmd != "YXQUERYDATABASEALLT") Search::Threads.stopThinking(); if (cmd == "END") return true; - else if (cmd == "ABOUT") std::cout << EngineInfo << std::endl; + else if (cmd == "ABOUT") std::cout << getEngineInfo() << std::endl; else if (cmd == "START") start(); else if (cmd == "RECTSTART") rectStart(); else if (cmd == "INFO") getOption(); diff --git a/Rapfi/config.cpp b/Rapfi/config.cpp index 89abcf6a..f6727e1f 100644 --- a/Rapfi/config.cpp +++ b/Rapfi/config.cpp @@ -20,7 +20,6 @@ #include "command/command.h" #include "core/iohelper.h" -#include "core/version.h" #include "database/dbstorage.h" #include "database/yxdbstorage.h" #include "eval/evaluator.h" @@ -273,8 +272,8 @@ bool Config::loadConfig(std::istream &configStream, bool skipModelLoading) /// This is used to check if the config file is suitable for current version of Rapfi. void Config::readRequirement(const cpptoml::table &t) { - uint64_t rapVer = ((uint64_t)RAPFI_MAJOR_VER << 32) | ((uint64_t)RAPFI_MINOR_VER << 16) - | (uint64_t)RAPFI_REVISION_VER; + auto [major, minor, revision] = getVersionNumbers(); + uint64_t rapVer = ((uint64_t)major << 32) | ((uint64_t)minor << 16) | (uint64_t)revision; if (auto minVer = t.get_array_of("min_version")) { if (minVer->size() != 3) throw std::runtime_error("illegal min_version"); diff --git a/Rapfi/core/utils.h b/Rapfi/core/utils.h index 0c0b221b..68131023 100644 --- a/Rapfi/core/utils.h +++ b/Rapfi/core/utils.h @@ -187,3 +187,15 @@ std::vector makeFileListFromPathList(const std::vector /// If raiseException is true, when failed to create, an filesystem::filesystem_error is raised. /// @return Whether directory exists (or created) if raiseException is false. bool ensureDir(std::string dirpath, bool raiseException = true); + +// ------------------------------------------------- +// Engine Version + +/// Returns the engine major/minor/revision version numbers. +std::tuple getVersionNumbers(); + +/// Returns the engine version information. +std::string getVersionInfo(); + +/// Returns the engine information. +std::string getEngineInfo(); diff --git a/Rapfi/core/version.cpp b/Rapfi/core/version.cpp new file mode 100644 index 00000000..11ec54f5 --- /dev/null +++ b/Rapfi/core/version.cpp @@ -0,0 +1,120 @@ +/* + * Rapfi, a Gomoku/Renju playing engine supporting piskvork protocol. + * Copyright (C) 2022 Rapfi developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "utils.h" + +#include + +#define RAPFI_MAJOR_VER 0 +#define RAPFI_MINOR_VER 41 +#define RAPFI_REVISION_VER 01 + +#define MACRO_STR(s) #s +#define VERSION_STR(a, b, c) MACRO_STR(a) "." MACRO_STR(b) "." MACRO_STR(c) +#define VERSION_STR2(a, b) MACRO_STR(a) "." MACRO_STR(b) +#define CURRENT_VER VERSION_STR(RAPFI_MAJOR_VER, RAPFI_MINOR_VER, RAPFI_REVISION_VER) + +std::tuple getVersionNumbers() +{ + return {RAPFI_MAJOR_VER, RAPFI_MINOR_VER, RAPFI_REVISION_VER}; +} + +std::string getBuildInfo() +{ + std::stringstream ss; + +#if defined(__INTEL_LLVM_COMPILER) + ss << "ICX " << MACRO_STR(__INTEL_LLVM_COMPILER); +#elif defined(__clang__) + ss << "clang++ " << VERSION_STR(__clang_major__, __clang_minor__, __clang_patchlevel__); +#elif _MSC_VER + ss << "MSVC " << VERSION_STR2(_MSC_FULL_VER, _MSC_BUILD); +#elif __GNUC__ + ss << "g++ " << VERSION_STR(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); +#else + ss << "Unknown compiler"; +#endif + +#if defined(__APPLE__) + ss << " on Apple"; +#elif defined(__MINGW64__) + ss << " on MinGW64"; +#elif defined(__ANDROID__) + ss << " on Android"; +#elif defined(__linux__) + ss << " on Linux"; +#elif defined(_WIN64) || defined(_WIN32) + ss << " on Windows"; +#elif defined(__EMSCRIPTEN__) + ss << " on Wasm"; +#else + ss << " on unknown system"; +#endif + +#if defined(USE_SSE) + ss << " SSE41"; +#endif +#if defined(USE_AVX2) + ss << " AVX2"; +#endif +#if defined(USE_AVX512) + ss << " AVX512"; +#endif +#if defined(USE_BMI2) + ss << " BMI2"; +#endif +#if defined(USE_VNNI) + ss << " VNNI"; +#endif +#if defined(USE_NEON_DOTPROD) + compiler += " NEON_DOTPROD"; +#elif defined(USE_NEON) + compiler += " NEON"; +#endif + +#if !defined(MULTI_THREADING) + ss << " SINGLE_THREAD"; +#endif + +#if defined(NO_PREFETCH) + ss << " NO_PREFETCH"; +#endif + +#if !defined(NDEBUG) + ss << " DEBUG"; +#endif + + return ss.str(); +} + +std::string getVersionInfo() +{ + std::stringstream ss; + ss << CURRENT_VER << " (" << getBuildInfo() << ')'; + return ss.str(); +} + +std::string getEngineInfo() +{ + std::stringstream ss; + ss << "name=\"Rapfi\", "; + ss << "version=\"" << getVersionInfo() << "\", "; + ss << "author=\"Rapfi developers (see AUTHORS file)\", "; + ss << "country=\"China\""; + return ss.str(); +} diff --git a/Rapfi/core/version.h b/Rapfi/core/version.h deleted file mode 100644 index 6c1dcaac..00000000 --- a/Rapfi/core/version.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Rapfi, a Gomoku/Renju playing engine supporting piskvork protocol. - * Copyright (C) 2022 Rapfi developers - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#define RAPFI_MAJOR_VER 0 -#define RAPFI_MINOR_VER 40 -#define RAPFI_REVISION_VER 03 - -#define MACRO_STR(s) #s -#define VERSION_STR(a, b, c) MACRO_STR(a) "." MACRO_STR(b) "." MACRO_STR(c) -#define CURRENT_VER VERSION_STR(RAPFI_MAJOR_VER, RAPFI_MINOR_VER, RAPFI_REVISION_VER) - -constexpr char EngineInfo[] = "name=\"Rapfi\", " - "version=\"" CURRENT_VER "\", " - "author=\"Rapfi developers (see AUTHORS file)\", " - "country=\"China\""; diff --git a/Rapfi/search/hashtable.cpp b/Rapfi/search/hashtable.cpp index ff306fda..0916af34 100644 --- a/Rapfi/search/hashtable.cpp +++ b/Rapfi/search/hashtable.cpp @@ -20,7 +20,6 @@ #include "../core/iohelper.h" #include "../core/utils.h" -#include "../core/version.h" #include "searchthread.h" #include