PGOBENCH = ./$(EXE) bench 32 1 10 default depth
### Object files
-OBJS = application.o bitboard.o pawns.o material.o endgame.o evaluate.o main.o \
+OBJS = bitboard.o pawns.o material.o endgame.o evaluate.o main.o \
misc.o move.o movegen.o history.o movepick.o search.o position.o \
direction.o tt.o uci.o ucioption.o book.o bitbase.o san.o benchmark.o timeman.o
+++ /dev/null
-/*
- Stockfish, a UCI chess playing engine derived from Glaurung 2.1
- Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
- Copyright (C) 2008-2010 Marco Costalba, Joona Kiiski, Tord Romstad
-
- Stockfish 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.
-
- Stockfish 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 <http://www.gnu.org/licenses/>.
-*/
-
-
-////
-//// Includes
-////
-
-#include "bitboard.h"
-#include "direction.h"
-#include "endgame.h"
-#include "evaluate.h"
-#include "material.h"
-#include "misc.h"
-#include "movepick.h"
-#include "position.h"
-#include "search.h"
-#include "thread.h"
-#include "ucioption.h"
-
-
-/// Application class is in charge of initializing global resources
-/// at startup and cleanly releases them when program terminates.
-
-Application::Application() {
-
- init_direction_table();
- init_bitboards();
- init_uci_options();
- Position::init_zobrist();
- Position::init_piece_square_tables();
- init_eval(1);
- init_bitbases();
- init_search();
- init_threads();
-}
-
-void Application::initialize() {
-
- // A static Application object is allocated
- // once only when this function is called.
- static Application singleton;
-}
-
-void Application::free_resources() {
-
- // Warning, following functions reference global objects that
- // must be still alive when free_resources() is called.
- exit_threads();
- quit_eval();
-}
-
-void Application::exit_with_failure() {
-
- exit(EXIT_FAILURE);
-}
+++ /dev/null
-/*
- Stockfish, a UCI chess playing engine derived from Glaurung 2.1
- Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
- Copyright (C) 2008-2010 Marco Costalba, Joona Kiiski, Tord Romstad
-
- Stockfish 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.
-
- Stockfish 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 <http://www.gnu.org/licenses/>.
-*/
-
-
-#if !defined(APPLICATION_H_INCLUDED)
-#define APPLICATION_H_INCLUDED
-
-
-/// Singleton class used to housekeep memory and global resources
-/// so to be sure we always leave in a clean state.
-
-class Application {
-
- Application();
- Application(const Application&);
-
-public:
- static void initialize();
- static void free_resources();
- static void exit_with_failure();
-};
-
-#endif // !defined(APPLICATION_H_INCLUDED)
if (!fenFile.is_open())
{
cerr << "Unable to open positions file " << posFile << endl;
- Application::exit_with_failure();
+ exit(EXIT_FAILURE);
}
string pos;
while (fenFile.good())
return;
}
cerr << "Failed to open book file " << fileName << endl;
- Application::exit_with_failure();
+ exit(EXIT_FAILURE);
}
if (!good())
{
cerr << "Failed to read book entry at index " << idx << endl;
- Application::exit_with_failure();
+ exit(EXIT_FAILURE);
}
}
#include <iostream>
#include <string>
+#include "bitboard.h"
#include "bitcount.h"
+#include "direction.h"
+#include "endgame.h"
+#include "evaluate.h"
+#include "material.h"
#include "misc.h"
+#include "position.h"
+#include "search.h"
+#include "thread.h"
+#include "ucioption.h"
#ifdef USE_CALLGRIND
#include <valgrind/callgrind.h>
cout.rdbuf()->pubsetbuf(NULL, 0);
cin.rdbuf()->pubsetbuf(NULL, 0);
- // Initialization through global resources manager
- Application::initialize();
+ // Startup initializations
+ init_direction_table();
+ init_bitboards();
+ init_uci_options();
+ Position::init_zobrist();
+ Position::init_piece_square_tables();
+ init_eval(1);
+ init_bitbases();
+ init_search();
+ init_threads();
#ifdef USE_CALLGRIND
CALLGRIND_START_INSTRUMENTATION;
benchmark(argc, argv);
}
- Application::free_resources();
+ exit_threads();
+ quit_eval();
return 0;
}
{
cerr << "Failed to allocate " << MaterialTableSize * sizeof(MaterialInfo)
<< " bytes for material hash table." << endl;
- Application::exit_with_failure();
+ exit(EXIT_FAILURE);
}
memset(entries, 0, MaterialTableSize * sizeof(MaterialInfo));
}
#include <fstream>
#include <string>
-#include "application.h"
#include "types.h"
////
{
std::cerr << "Failed to allocate " << (PawnTableSize * sizeof(PawnInfo))
<< " bytes for pawn hash table." << std::endl;
- Application::exit_with_failure();
+ exit(EXIT_FAILURE);
}
memset(entries, 0, PawnTableSize * sizeof(PawnInfo));
}
if (!ok)
{
cout << "Failed to create thread number " << i << endl;
- Application::exit_with_failure();
+ exit(EXIT_FAILURE);
}
// Wait until the thread has finished launching and is gone to sleep
{
std::cerr << "Failed to allocate " << mbSize
<< " MB for transposition table." << std::endl;
- Application::exit_with_failure();
+ exit(EXIT_FAILURE);
}
clear();
}
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#if !defined(TYPES_H_INCLUDED)
#define TYPES_H_INCLUDED
// Bitboard type
typedef uint64_t Bitboard;
+#include <cstdlib>
////
//// Configuration