Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions sources/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,26 @@ DATADIRPERSONALITIES = $(DATADIR)/personalities
# Define the CPP compiler
CXX = g++

OPT = -O3 -fno-rtti
LDOPT = -s
FEATURES = -DUSEGEN -DUSE_THREADS

# you can override OPT, LDOPT and FEATURES in config.mak, if you don't want
# your build stripped - e.g. for debugging, or want to turn threads off.
-include config.mak


# Define features
# Other options are -DBOOKGEN -DNO_THREADS
CFG = -DNDEBUG -DUSEGEN -DUSE_THREADS -DBOOKSPATH=$(DATADIRBOOKS) -DPERSONALITIESPATH=$(DATADIRPERSONALITIES)
CFG = -DNDEBUG $(FEATURES) -DBOOKSPATH=$(DATADIRBOOKS) -DPERSONALITIESPATH=$(DATADIRPERSONALITIES)
CFG1 = -DUSEGEN -DUSE_THREADS -DBOOKSPATH=$(DATADIRBOOKS) -DPERSONALITIESPATH=$(DATADIRPERSONALITIES)

# Define compiler flags
CXXFLAGS = -g -std=c++14 -Wall -Wno-unknown-pragmas -O3 -fno-rtti -pthread $(CFG)
CXXFLAGS = -g -std=c++14 -Wall -Wno-unknown-pragmas $(OPT) -pthread $(CFG)
CXX1FLAGS = -g -std=c++14 -Wall -Wno-unknown-pragmas -pthread $(CFG1)

# Define linker options
LDFLAGS = -s -Wl,--no-as-needed,--gc-sections
LDFLAGS = $(LDOPT) -Wl,--no-as-needed,--gc-sections -Wl,-z,stack-size=8097152
LD1FLAGS = -lm

# Command line switches
Expand Down
8 changes: 2 additions & 6 deletions sources/src/book.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,8 @@ U64 sBook::GetPolyglotKey(POS *p) {
void sBook::OpenPolyglot() {

ClosePolyglot();

if (!isabsolute(bookName)) // if known locations don't exist we want to load only from absolute paths
if (!ChDirEnv("RIIIBOOKS")) // try `RIIIBOOKS` env var first (26/08/17: linux only)
if (!ChDir(_BOOKSPATH)) return; // next built-in path

bookFile = fopen(bookName, "rb");
char path[1024];
bookFile = fopen(getPath(path, sizeof(path), bookName, "RIIIBOOKS", _BOOKSPATH), "rb");

if (bookFile == NULL) return;

Expand Down
6 changes: 3 additions & 3 deletions sources/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ if (Glob.is_noisy) {
printf("info string opening books path is '%ls' (%s)\n", _BOOKSPATH, ChDir(_BOOKSPATH) ? "exists" : "doesn't exist");
printf("info string personalities path is '%ls' (%s)\n", _PERSONALITIESPATH, ChDir(_PERSONALITIESPATH) ? "exists" : "doesn't exist");
#else
printf("info string opening books path is '%s' (%s)\n", _BOOKSPATH, ChDir(_BOOKSPATH) ? "exists" : "doesn't exist");
printf("info string personalities path is '%s' (%s)\n", _PERSONALITIESPATH, ChDir(_PERSONALITIESPATH) ? "exists" : "doesn't exist");
printf("info string opening books path is '%s' (%s)\n", _BOOKSPATH, access(_BOOKSPATH, R_OK) == 0 ? "exists" : "doesn't exist");
printf("info string personalities path is '%s' (%s)\n", _PERSONALITIESPATH, access(_PERSONALITIESPATH, R_OK) == 0 ? "exists" : "doesn't exist");
#endif
}

Expand Down Expand Up @@ -163,4 +163,4 @@ void cGlobals::Init() {

bool cGlobals::CanReadBook() {
return (use_books_from_pers == reading_personality || !use_personality_files);
}
}
10 changes: 9 additions & 1 deletion sources/src/rodent.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ If not, see <http://www.gnu.org/licenses/>.
#include <cstdint>
#include <cinttypes>

#if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h> /* for access() */
#endif

//#define USE_TUNING

using U64 = uint64_t;
Expand Down Expand Up @@ -70,12 +74,13 @@ static constexpr int max_tt_size_mb = 4096; // TODO: Fruit 3.2.1 uses 16384 on 6

//#define NO_THREADS

#define MAX_THREADS 48

#ifndef NO_THREADS
#include <thread>
#ifndef USE_THREADS
#define USE_THREADS
#endif
#define MAX_THREADS 48
#else
#undef USE_THREADS
#endif
Expand Down Expand Up @@ -601,6 +606,7 @@ const char* const paramNames[N_OF_VAL] = {

class cParam {
public:
char personality_file[80];
int wait[N_OF_VAL];
int values[N_OF_VAL]; // evaluation parameters
int max_val[N_OF_VAL];
Expand Down Expand Up @@ -993,6 +999,8 @@ void ReadThreadNumber(const char *fileName);
void SetPieceValue(int pc, int val, int slot);
void UciLoop();
int my_random(int n);
char *getPath(char *buf, unsigned buflen,
const char *fn, const char *env_override, const char* builtindir);

extern const int tp_value[7];
extern const int ph_value[7];
Expand Down
4 changes: 3 additions & 1 deletion sources/src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,8 @@ void CheckTimeout() {
}
else if (strcmp(command, "ponderhit") == 0)
Glob.pondering = false;
else if (strcmp(command, "isready") == 0)
printf("readyok\n");
}

int time = cEngine::msMoveTime;
Expand Down Expand Up @@ -1192,7 +1194,7 @@ void cEngine::Slowdown() {

#ifndef USE_THREADS
if ((!(Glob.nodes & 2047))
&& !Glob.is_testing
&& !Glob.isTesting
&& mRootDepth > 1) CheckTimeout();
#endif

Expand Down
15 changes: 8 additions & 7 deletions sources/src/uci_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void PrintUciOptions() {

if (Glob.use_personality_files) {
if (pers_aliases.count == 0 || Glob.show_pers_file)
printf("option name PersonalityFile type string default default.txt\n");
printf("option name PersonalityFile type string default %s\n", Par.personality_file);
if (pers_aliases.count != 0) {
printf("option name Personality type combo default ---"); // `---` in case we want PersonalityFile
for (int i = 0; i < pers_aliases.count; i++)
Expand Down Expand Up @@ -437,18 +437,19 @@ void ReadThreadNumber(const char * fileName) {
void ReadPersonality(const char *fileName) {

FILE *personalityFile = NULL;
if (isabsolute(fileName) // if known locations don't exist we want to load only from absolute paths
|| ChDirEnv("RIIIPERSONALITIES") // try `RIIIPERSONALITIES` env var first (26/08/17: linux only)
|| ChDir(_PERSONALITIESPATH)) // next built-in path
personalityFile = fopen(fileName, "r");

char path[1024];
(void) getPath(path, sizeof(path), fileName, "RIIIPERSONALITIES", _PERSONALITIESPATH);
personalityFile = fopen(path, "r");
if (Glob.is_noisy)
printf("info string reading personality '%s' (%s)\n", fileName, personalityFile == NULL ? "failure" : "success");
printf("info string reading personality '%s' (%s)\n", path, personalityFile == NULL ? "failure" : "success");

// Exit if this personality file doesn't exist

if (personalityFile == NULL)
return;
const char *p = strrchr(fileName, '/');
if(!p) p = fileName; else ++p;
strcpy(Par.personality_file, p);

// It is possible that user will attempt to load a personality of older Rodent version.
// There is nothing wrong with that, except that there will be some parameters missing.
Expand Down
15 changes: 15 additions & 0 deletions sources/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ If not, see <http://www.gnu.org/licenses/>.

#include "rodent.h"

char *getPath(char *buf, unsigned buflen,
const char *fileName, const char *env_override, const char* builtindir) {
if (isabsolute(fileName)) {
snprintf(buf, buflen, "%s", fileName);
} else if(env_override && getenv(env_override)) {
// try `RIIIPERSONALITIES` env var first (26/08/17: linux only)
snprintf(buf, buflen, "%s/%s", getenv(env_override), fileName);
} else if(builtindir) {
snprintf(buf, buflen, "%s/%s", builtindir, fileName);
} else {
snprintf(buf, buflen, "%s", fileName);
}
return buf;
}

bool InputAvailable() {

#if defined(_WIN32) || defined(_WIN64)
Expand Down