Preliminary support for scanning for compilers
This commit is contained in:
1 parent
fde8fc3b9b
commit
67d7e2a4d5
5 files changed
+122
-24
No files matched your search
+80
-17
@@ -24,24 +24,30 @@ import argparse, ast, hashlib, json, math, multiprocessing, os
|
|||||||
import platform, re, requests, shutil, subprocess, sys, time, zipfile
|
import platform, re, requests, shutil, subprocess, sys, time, zipfile
|
||||||
|
|
||||||
|
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
|
||||||
HTTP_TIMEOUT = 30 # Timeout in seconds for requests
|
HTTP_TIMEOUT = 30 # Timeout in seconds for requests
|
||||||
WORKLOAD_TIMEOUT = 60 # Timeout when there is no work
|
WORKLOAD_TIMEOUT = 60 # Timeout when there is no work
|
||||||
ERROR_TIMEOUT = 60 # Timeout when an error is thrown
|
ERROR_TIMEOUT = 60 # Timeout when an error is thrown
|
||||||
GAMES_PER_CONCURRENCY = 32 # Total games to play per concurrency
|
GAMES_PER_CONCURRENCY = 32 # Total games to play per concurrency
|
||||||
|
|
||||||
CUSTOM_SETTINGS = {
|
CUSTOM_SETTINGS = {
|
||||||
'ETHEREAL' : { 'args' : [] }, # Configuration for Ethereal
|
'Ethereal' : { 'args' : [] }, # Configuration for Ethereal
|
||||||
'LASER' : { 'args' : [] }, # Configuration for Laser
|
'Laser' : { 'args' : [] }, # Configuration for Laser
|
||||||
'WEISS' : { 'args' : [] }, # Configuration for Weiss
|
'Weiss' : { 'args' : [] }, # Configuration for Weiss
|
||||||
'DEMOLITO' : { 'args' : [] }, # Configuration for Demolito
|
'Demolito' : { 'args' : [] }, # Configuration for Demolito
|
||||||
'RUBICHESS' : { 'args' : [] }, # Configuration for RubiChess
|
'Rubichess' : { 'args' : [] }, # Configuration for RubiChess
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
|
||||||
|
|
||||||
# Treat Windows and Linux systems differently
|
# Treat Windows and Linux systems differently
|
||||||
IS_WINDOWS = platform.system() == 'Windows'
|
IS_WINDOWS = platform.system() == 'Windows'
|
||||||
IS_LINUX = platform.system() != 'Windows'
|
IS_LINUX = platform.system() != 'Windows'
|
||||||
|
|
||||||
|
COMPILERS = {} # Mapping of Engines to Compilers
|
||||||
|
|
||||||
def addExtension(name):
|
def addExtension(name):
|
||||||
return name + ["", ".exe"][IS_WINDOWS]
|
return name + ["", ".exe"][IS_WINDOWS]
|
||||||
|
|
||||||
@@ -68,8 +74,55 @@ def killCutechess(cutechess):
|
|||||||
cutechess.wait()
|
cutechess.wait()
|
||||||
cutechess.stdout.close()
|
cutechess.stdout.close()
|
||||||
|
|
||||||
except Exception as error:
|
except KeyboardInterrupt: sys.exit()
|
||||||
return
|
except Exception as error: pass
|
||||||
|
|
||||||
|
|
||||||
|
def getCompilationSettings(server):
|
||||||
|
|
||||||
|
# Get a dictionary of engine -> compilers
|
||||||
|
data = requests.get(
|
||||||
|
pathjoin(server, 'getCompilers'),
|
||||||
|
timeout=HTTP_TIMEOUT).content.decode('utf-8')
|
||||||
|
data = ast.literal_eval(data)
|
||||||
|
|
||||||
|
for engine, compilers in data.items():
|
||||||
|
for compiler in compilers:
|
||||||
|
|
||||||
|
# Compilers may require a specific version
|
||||||
|
if '>=' in compiler: command, version = compiler.split('>=')
|
||||||
|
else: command = compiler; version = (0, 0, 0)
|
||||||
|
|
||||||
|
# Try to execute the compiler from the command line
|
||||||
|
try: stdout, stderr = subprocess.Popen(
|
||||||
|
[command, '--version'],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT,
|
||||||
|
).communicate()
|
||||||
|
except OSError: continue
|
||||||
|
|
||||||
|
# Parse the version number reported by the compiler
|
||||||
|
stdout = stdout.decode('utf-8')
|
||||||
|
match = re.search(r'[0-9]+\.[0-9]+\.[0-9]+', stdout).group()
|
||||||
|
actual = tuple(map(int, match.split('.')))
|
||||||
|
|
||||||
|
# Compiler was not sufficient
|
||||||
|
if actual < version: continue
|
||||||
|
|
||||||
|
# Compiler was sufficient
|
||||||
|
COMPILERS[engine] = {
|
||||||
|
'command' : command, 'version' : match,
|
||||||
|
'default' : compiler == compilers[0]
|
||||||
|
}; break
|
||||||
|
|
||||||
|
# Report each engine configuration we can build for
|
||||||
|
for engine in [engine for engine in data.keys() if engine in COMPILERS]:
|
||||||
|
command, version = COMPILERS[engine]['command'], COMPILERS[engine]['version']
|
||||||
|
print("Found {0} {1} for {2}".format(command, version, engine))
|
||||||
|
|
||||||
|
# Report each engine configuration we cannot build for
|
||||||
|
for engine in [engine for engine in data.keys() if engine not in COMPILERS]:
|
||||||
|
print("Unable to find compiler for {0}".format(engine))
|
||||||
|
|
||||||
def getFile(source, output):
|
def getFile(source, output):
|
||||||
|
|
||||||
@@ -130,7 +183,6 @@ def getMachineID():
|
|||||||
|
|
||||||
def getEngine(data, engine):
|
def getEngine(data, engine):
|
||||||
|
|
||||||
# Log the fact that we are setting up a new engine
|
|
||||||
print('Engine {0}'.format(data['test']['engine']))
|
print('Engine {0}'.format(data['test']['engine']))
|
||||||
print('Branch {0}'.format(engine['name']))
|
print('Branch {0}'.format(engine['name']))
|
||||||
print('Commit {0}'.format(engine['sha']))
|
print('Commit {0}'.format(engine['sha']))
|
||||||
@@ -141,18 +193,23 @@ def getEngine(data, engine):
|
|||||||
tokens = engine['source'].split('/')
|
tokens = engine['source'].split('/')
|
||||||
unzipname = '{0}-{1}'.format(tokens[-3], tokens[-1].replace('.zip', ''))
|
unzipname = '{0}-{1}'.format(tokens[-3], tokens[-1].replace('.zip', ''))
|
||||||
getAndUnzipFile(engine['source'], '{0}.zip'.format(engine['name']), 'tmp')
|
getAndUnzipFile(engine['source'], '{0}.zip'.format(engine['name']), 'tmp')
|
||||||
pathway = pathjoin('tmp/{0}/'.format(unzipname), data['test']['path'])
|
pathway = pathjoin('tmp/{0}/'.format(unzipname), data['test']['build']['path'])
|
||||||
|
|
||||||
# Check CUSTOM_SETTINGS for a custom configuration
|
# Use base command and an EXE= hook
|
||||||
command = ['make', 'EXE={0}'.format(engine['name'])]
|
command = [data['test']['build']['command']]
|
||||||
if data['test']['engine'].upper() in CUSTOM_SETTINGS:
|
command.append('EXE={0}'.format(engine['name']))
|
||||||
config = CUSTOM_SETTINGS[data['test']['engine'].upper()]
|
|
||||||
command.extend(config['args'])
|
# Use a CC= hook if we are using the non-default compiler
|
||||||
|
if not COMPILERS[data['test']['engine']]['default']:
|
||||||
|
command.append('CC={0}'.format(COMPILERS[data['test']['engine']]['command']))
|
||||||
|
|
||||||
|
# Add any other custom compilation options if we have them
|
||||||
|
if data['test']['engine'] in CUSTOM_SETTINGS:
|
||||||
|
command.extend(CUSTOM_SETTINGS[data['test']['engine']]['args'])
|
||||||
|
|
||||||
# Build the engine. If something goes wrong with the
|
# Build the engine. If something goes wrong with the
|
||||||
# compilation process, we will figure this out later on
|
# compilation process, we will figure this out later on
|
||||||
subprocess.Popen(command, cwd=pathway).wait()
|
subprocess.Popen(command, cwd=pathway).wait(); print("")
|
||||||
print("") # Leave a new line to seperate output
|
|
||||||
|
|
||||||
# Move the binary to the /Engines/ directory
|
# Move the binary to the /Engines/ directory
|
||||||
output = '{0}{1}'.format(pathway, engine['name'])
|
output = '{0}{1}'.format(pathway, engine['name'])
|
||||||
@@ -436,6 +493,7 @@ def reportResults(arguments, data, wins, losses, draws, crashes, timelosses):
|
|||||||
# Hit the server with the updated test results
|
# Hit the server with the updated test results
|
||||||
url = pathjoin(arguments.server, 'submitResults')
|
url = pathjoin(arguments.server, 'submitResults')
|
||||||
try: return requests.post(url, data=data, timeout=HTTP_TIMEOUT).text
|
try: return requests.post(url, data=data, timeout=HTTP_TIMEOUT).text
|
||||||
|
except KeyboardInterrupt: sys.exit()
|
||||||
except: print('[NOTE] Unable To Reach Server'); return "Unable"
|
except: print('[NOTE] Unable To Reach Server'); return "Unable"
|
||||||
|
|
||||||
|
|
||||||
@@ -518,7 +576,6 @@ def completeWorkload(workRequestData, arguments):
|
|||||||
print('[ERROR] Invalid Login Credentials')
|
print('[ERROR] Invalid Login Credentials')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
# Bad machines will be registered again
|
# Bad machines will be registered again
|
||||||
if data == 'Bad Machine':
|
if data == 'Bad Machine':
|
||||||
workRequestData['machineid'] = 'None'
|
workRequestData['machineid'] = 'None'
|
||||||
@@ -565,6 +622,10 @@ def main():
|
|||||||
# Make sure we have cutechess installed
|
# Make sure we have cutechess installed
|
||||||
getCutechess(arguments.server)
|
getCutechess(arguments.server)
|
||||||
|
|
||||||
|
# Determine how we will compile engines
|
||||||
|
print("\nChecking for installed Compilers",)
|
||||||
|
getCompilationSettings(arguments.server)
|
||||||
|
|
||||||
# Create the Engines directory if it does not exist
|
# Create the Engines directory if it does not exist
|
||||||
if not os.path.isdir('Engines'):
|
if not os.path.isdir('Engines'):
|
||||||
os.mkdir('Engines')
|
os.mkdir('Engines')
|
||||||
@@ -572,9 +633,11 @@ def main():
|
|||||||
# Continually pull down and complete workloads
|
# Continually pull down and complete workloads
|
||||||
while True:
|
while True:
|
||||||
try: completeWorkload(workRequestData, arguments)
|
try: completeWorkload(workRequestData, arguments)
|
||||||
|
except KeyboardInterrupt: sys.exit()
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
print ('[ERROR] {0}'.format(str(error)))
|
print ('[ERROR] {0}'.format(str(error)))
|
||||||
time.sleep(ERROR_TIMEOUT)
|
time.sleep(ERROR_TIMEOUT)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
+30
-5
@@ -77,10 +77,12 @@ OPENBENCH_CONFIG = {
|
|||||||
'engines' : {
|
'engines' : {
|
||||||
|
|
||||||
'Ethereal' : {
|
'Ethereal' : {
|
||||||
|
|
||||||
'proto' : 'uci',
|
'proto' : 'uci',
|
||||||
'nps' : 1275000,
|
'nps' : 1275000,
|
||||||
'path' : '/src/',
|
'build' : { 'path' : '/src/', 'command' : 'make', 'compilers' : ['gcc'] },
|
||||||
'source' : 'https://github.com/AndyGrant/Ethereal',
|
'source' : 'https://github.com/AndyGrant/Ethereal',
|
||||||
|
|
||||||
'testmodes' : {
|
'testmodes' : {
|
||||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '12.0+0.12' },
|
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '12.0+0.12' },
|
||||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||||
@@ -90,10 +92,12 @@ OPENBENCH_CONFIG = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'Laser' : {
|
'Laser' : {
|
||||||
|
|
||||||
'proto' : 'uci',
|
'proto' : 'uci',
|
||||||
'nps' : 710000,
|
'nps' : 710000,
|
||||||
'path' : '/src/',
|
'build' : { 'path' : '/src/', 'command' : 'make', 'compilers' : ['g++'] },
|
||||||
'source' : 'https://github.com/jeffreyan11/uci-chess-engine',
|
'source' : 'https://github.com/jeffreyan11/uci-chess-engine',
|
||||||
|
|
||||||
'testmodes' : {
|
'testmodes' : {
|
||||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||||
@@ -103,10 +107,12 @@ OPENBENCH_CONFIG = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'Weiss' : {
|
'Weiss' : {
|
||||||
|
|
||||||
'proto' : 'uci',
|
'proto' : 'uci',
|
||||||
'nps' : 2675000,
|
'nps' : 2675000,
|
||||||
'path' : '/src/',
|
'build' : { 'path' : '/src/', 'command' : 'make', 'compilers' : ['gcc'] },
|
||||||
'source' : 'https://github.com/TerjeKir/weiss',
|
'source' : 'https://github.com/TerjeKir/weiss',
|
||||||
|
|
||||||
'testmodes' : {
|
'testmodes' : {
|
||||||
'stc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '10.0+0.1' },
|
'stc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '10.0+0.1' },
|
||||||
'ltc' : { 'threads' : 1, 'hash' : 128, 'timecontrol' : '60.0+0.6' },
|
'ltc' : { 'threads' : 1, 'hash' : 128, 'timecontrol' : '60.0+0.6' },
|
||||||
@@ -116,10 +122,12 @@ OPENBENCH_CONFIG = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'Demolito' : {
|
'Demolito' : {
|
||||||
|
|
||||||
'proto' : 'uci',
|
'proto' : 'uci',
|
||||||
'nps' : 1250000,
|
'nps' : 1250000,
|
||||||
'path' : '/src/',
|
'build' : { 'path' : '/src/', 'command' : 'make', 'compilers' : ['gcc', 'clang'] },
|
||||||
'source' : 'https://github.com/lucasart/Demolito',
|
'source' : 'https://github.com/lucasart/Demolito',
|
||||||
|
|
||||||
'testmodes' : {
|
'testmodes' : {
|
||||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '8.0+0.08' },
|
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '8.0+0.08' },
|
||||||
'ltc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '32.0+0.32'},
|
'ltc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '32.0+0.32'},
|
||||||
@@ -129,10 +137,12 @@ OPENBENCH_CONFIG = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'RubiChess' : {
|
'RubiChess' : {
|
||||||
|
|
||||||
'proto' : 'uci',
|
'proto' : 'uci',
|
||||||
'nps' : 1000000,
|
'nps' : 1000000,
|
||||||
'path' : '/src/',
|
'build' : { 'path' : '/src/', 'command' : 'make', 'compilers' : ['g++'] },
|
||||||
'source' : 'https://github.com/Matthies/RubiChess',
|
'source' : 'https://github.com/Matthies/RubiChess',
|
||||||
|
|
||||||
'testmodes' : {
|
'testmodes' : {
|
||||||
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||||
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||||
@@ -140,5 +150,20 @@ OPENBENCH_CONFIG = {
|
|||||||
'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' },
|
'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'FabChess' : {
|
||||||
|
|
||||||
|
'proto' : 'uci',
|
||||||
|
'nps' : 1000000,
|
||||||
|
'build' : { 'path' : '/src/', 'command' : 'make', 'compilers' : ['cargo>=1.43.0'] },
|
||||||
|
'source' : 'https://github.com/fabianvdW/FabChess',
|
||||||
|
|
||||||
|
'testmodes' : {
|
||||||
|
'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' },
|
||||||
|
'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' },
|
||||||
|
'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' },
|
||||||
|
'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' },
|
||||||
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
+2
-1
@@ -49,8 +49,9 @@ urlpatterns = [
|
|||||||
django.urls.path(r'test/<int:id>/<str:action>', OpenBench.views.test),
|
django.urls.path(r'test/<int:id>/<str:action>', OpenBench.views.test),
|
||||||
django.urls.path(r'newTest/', OpenBench.views.newTest),
|
django.urls.path(r'newTest/', OpenBench.views.newTest),
|
||||||
|
|
||||||
# Links for the Client to update the Server
|
# Links for the Client to work with the Server
|
||||||
django.urls.path(r'getFiles/', OpenBench.views.getFiles),
|
django.urls.path(r'getFiles/', OpenBench.views.getFiles),
|
||||||
|
django.urls.path(r'getCompilers/', OpenBench.views.getCompilers),
|
||||||
django.urls.path(r'getWorkload/', OpenBench.views.getWorkload),
|
django.urls.path(r'getWorkload/', OpenBench.views.getWorkload),
|
||||||
django.urls.path(r'wrongBench/', OpenBench.views.wrongBench),
|
django.urls.path(r'wrongBench/', OpenBench.views.wrongBench),
|
||||||
django.urls.path(r'submitNPS/', OpenBench.views.submitNPS),
|
django.urls.path(r'submitNPS/', OpenBench.views.submitNPS),
|
||||||
|
|||||||
+1
-1
@@ -345,7 +345,7 @@ def workloadDictionary(machine, result, test):
|
|||||||
'test' : {
|
'test' : {
|
||||||
'id' : test.id,
|
'id' : test.id,
|
||||||
'nps' : OPENBENCH_CONFIG['engines'][test.engine]['nps'],
|
'nps' : OPENBENCH_CONFIG['engines'][test.engine]['nps'],
|
||||||
'path' : OPENBENCH_CONFIG['engines'][test.engine]['path'],
|
'build' : OPENBENCH_CONFIG['engines'][test.engine]['build'],
|
||||||
'book' : OPENBENCH_CONFIG['books'][test.bookname],
|
'book' : OPENBENCH_CONFIG['books'][test.bookname],
|
||||||
'timecontrol' : test.timecontrol,
|
'timecontrol' : test.timecontrol,
|
||||||
'engine' : test.engine,
|
'engine' : test.engine,
|
||||||
|
|||||||
@@ -450,6 +450,15 @@ def getFiles(request):
|
|||||||
# Core Files should be sitting in framework's repo
|
# Core Files should be sitting in framework's repo
|
||||||
return HttpResponse(OpenBench.config.OPENBENCH_CONFIG['corefiles'])
|
return HttpResponse(OpenBench.config.OPENBENCH_CONFIG['corefiles'])
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
@not_minified_response
|
||||||
|
def getCompilers(request):
|
||||||
|
|
||||||
|
data = {} # Return all engine-compiler information
|
||||||
|
for engine, config in OpenBench.config.OPENBENCH_CONFIG['engines'].items():
|
||||||
|
data[engine] = config['build']['compilers']
|
||||||
|
return HttpResponse(str(data))
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@not_minified_response
|
@not_minified_response
|
||||||
def getWorkload(request):
|
def getWorkload(request):
|
||||||
|
|||||||
Reference in new issue
Block a user