Working progress

This commit is contained in:
andrew committed 2023-05-15 18:43:35 -04:00
1 parent 0556bf7618
commit dd0f2ca29f
29 files changed
+377 -169

No files matched your search

-7
View File
@@ -1,42 +1,35 @@
{
"2moves_v1.epd" : {
"name" : "2moves_v1.epd",
"sha" : "7bec98239836f219dc41944a768c0506abed950aaec48da69a0782643e90f237",
"source" : "https://raw.githubusercontent.com/AndyGrant/OpenBench/master/Books/2moves_v1.epd.zip"
},
"8moves_v3.epd" : {
"name" : "8moves_v3.epd",
"sha" : "1f055af431656f09ee6a09d2448e0b876125f78bb7b404fca2031c403a1541e5",
"source" : "https://raw.githubusercontent.com/AndyGrant/OpenBench/master/Books/8moves_v3.epd.zip"
},
"3moves_FRC.epd" : {
"name" : "3moves_FRC.epd",
"sha" : "6bf81e1ada6a3306bbc8356f7bca1e2984a2828d658799992d5443b7179c934d",
"source" : "https://raw.githubusercontent.com/AndyGrant/OpenBench/master/Books/3moves_FRC.epd.zip"
},
"4moves_noob.epd" : {
"name" : "4moves_noob.epd",
"sha" : "4be746a91e3f8af0c9344b1e72d611e9fcfe486843867a55760970a4896f284d",
"source" : "https://raw.githubusercontent.com/AndyGrant/OpenBench/master/Books/4moves_noob.epd.zip"
},
"Pohl.epd" : {
"name" : "Pohl.epd",
"sha" : "b3e64e0dab84cf451a9ac7ef031f5a2bbcf16c7e21be95298fb03cbf021f5466",
"source" : "https://raw.githubusercontent.com/AndyGrant/OpenBench/master/Books/Pohl.epd.zip"
},
"Pohl.pgn" : {
"name" : "Pohl.pgn",
"sha" : "aaa7559c5d94e592fe5cca3586cb099d8fc5f13428d4ce84afc4b97811241c7e",
"source" : "https://raw.githubusercontent.com/AndyGrant/OpenBench/master/Books/Pohl.pgn.zip"
},
"DFRC.epd" : {
"name" : "DFRC.epd",
"sha" : "648c447ef40614a44d13b78911e81470d8ddb0d3b2711c1b180e990871f5db4f",
"source" : "https://raw.githubusercontent.com/AndyGrant/OpenBench/master/Books/DFRC.epd.zip"
}
+192 -113
View File
@@ -19,17 +19,21 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import argparse
import cpuinfo
import hashlib
import json
import multiprocessing
import os
import platform
import psutil
import re
import requests
import shutil
import sys
import time
import traceback
import uuid
import zipfile
import shutil
import multiprocessing
from subprocess import PIPE, Popen, call, STDOUT
from itertools import combinations_with_replacement
@@ -45,18 +49,18 @@ from itertools import combinations_with_replacement
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
TIMEOUT_HTTP = 30 # Timeout in seconds for HTTP requests
TIMEOUT_ERROR = 10 # Timeout in seconds when any errors are thrown
TIMEOUT_WORKLOAD = 30 # Timeout in seconds between workload requests
CLIENT_VERSION = '7' # Client version to send to the Server
TIMEOUT_HTTP = 30 # Timeout in seconds for HTTP requests
TIMEOUT_ERROR = 10 # Timeout in seconds when any errors are thrown
TIMEOUT_WORKLOAD = 30 # Timeout in seconds between workload requests
CLIENT_VERSION = '7' # Client version to send to the Server
SYZYGY_WDL_PATH = None # Pathway to WDL Syzygy Tables
FLEET_MODE = False # Exit when there are no workloads
SYZYGY_WDL_PATH = None # Pathway to WDL Syzygy Tables
FLEET_MODE = False # Exit when there are no workloads
ERRORS = {
'cutechess' : 'Unable to fetch Cutechess location and download it!',
'configure' : 'Unable to fetch and determine acceptable workloads!',
'request' : 'Unable to reach server for workload request!',
'cutechess' : 'Unable to fetch Cutechess location and download it!',
'configure' : 'Unable to fetch and determine acceptable workloads!',
'request' : 'Unable to reach server for workload request!',
}
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -77,15 +81,42 @@ CPUINFO = '' # Result of ``echo | gcc -march=native -E -dM -``
OSNAME = '%s %s' % (platform.system(), platform.release())
DEBUG = True
def locate_utility(util, force_exit=True, report_error=True):
SYSTEM_COMPILERS = {}
SYSTEM_GIT_TOKENS = {}
SYSTEM_CPU_FLAGS = []
SYSTEM_CPU_NAME = ''
SYSTEM_OS_NAME = platform.system()
SYSTEM_OS_VER = platform.release()
SYSTEM_PYTHON_VER = platform.python_version()
SYSTEM_MAC_ADDRESS = hex(uuid.getnode()).upper()[2:]
SYSTEM_LOGICAL_CORES = psutil.cpu_count(logical=True)
SYSTEM_PHYSICAL_CORES = psutil.cpu_count(logical=False)
SYSTEM_RAM_TOTAL_MB = psutil.virtual_memory().total // (1024 ** 2)
SYSTEM_MACHINE_ID = 'None'
SYSTEM_SECRET_TOKEN = 'None'
def get_version(program):
# Try to execute the program from the command line
# First with `--version`, and again with just `version`
try:
process = Popen([util, '--version'], stdout=PIPE)
stdout, stderr = process.communicate()
process = Popen([program, '--version'], stdout=PIPE, stderr=PIPE)
stdout = process.communicate()[0].decode('utf-8')
return re.search(r'\d+\.\d+(\.\d+)?', stdout).group()
ver = re.search('[0-9]+.[0-9]+.[0-9]+', str(stdout))
print('Located %s (%s)' % (util, ver.group()))
return True
except:
process = Popen([program, 'version'], stdout=PIPE, stderr=PIPE)
stdout = process.communicate()[0].decode('utf-8')
return re.search(r'\d+\.\d+(\.\d+)?', stdout).group()
def locate_utility(util, force_exit=True, report_error=True, report_found=True):
try:
version = get_version(util)
if report_found:
print('Located %s (%s)' % (util, version))
return version
except Exception:
if report_error:
@@ -94,15 +125,101 @@ def locate_utility(util, force_exit=True, report_error=True):
sys.exit()
return False
def check_for_utilities():
print('\nScanning For Basic Utilities...')
for utility in ['gcc', 'make']:
locate_utility(utility)
def scan_for_compilers(data):
print ('\nScanning for Compilers...')
# For each engine, attempt to find a valid compiler
for engine, build_info in data.items():
# Private engines don't need to be compiled
if build_info['private']: continue
# Try to find at least one working compiler
for compiler in build_info['compilers']:
# Compilers may require a specific version
if '>=' in compiler:
compiler, version = compiler.split('>=')
version = tuple(map(int, version.split('.')))
else: version = (0, 0, 0)
# Try to confirm this compiler is present, and new enough
try:
match = get_version(compiler)
if tuple(map(int, match.split('.'))) >= version:
print('%-16s | %-8s (%s)' % (engine, compiler, match))
SYSTEM_COMPILERS[engine] = (compiler, match)
break
except: continue # Unable to execute compiler
# Report missing engines in case the User is not expecting it
if engine not in SYSTEM_COMPILERS:
print('%-16s | Missing %s' % (engine, data[engine]['compilers']))
def scan_for_private_tokens(data):
print ('\nScanning for Private Tokens...')
# For each engine, attempt to find a valid compiler
for engine, build_info in data.items():
# Public engines don't need access tokens
if not build_info['private']: continue
# Private engines expect a credentials.engine file for the main repo
has_token = os.path.exists('credentials.%s' % (engine.replace(' ', '').lower()))
print('%-16s | %s' % (engine, ['Missing', 'Found'][has_token]))
if has_token: SYSTEM_GIT_TOKENS[engine] = True
def scan_for_cpu_flags(data):
print('\nScanning for CPU Flags...')
# Get all flags, and for sanity uppercase them
info = cpuinfo.get_cpu_info()
actual = [x.upper() for x in info['flags']]
# Set the CPU name which has to be done via global
global SYSTEM_CPU_NAME, SYSTEM_CPU_FLAGS
SYSTEM_CPU_NAME = info['brand_raw']
# This should cover virtually all compiler flags that we would care about
desired = ['POPCNT', 'BMI2']
desired += ['SSSE3', 'SSE4_1', 'SSE4_2', 'SSE4A', 'AVX', 'AVX2', 'FMA']
desired += ['AVX512_VNNI', 'AVX512BW', 'AVX512CD', 'AVX512DQ', 'AVX512F']
# Add any custom flags from the OpenBench configs, just in case we missed one
requested = set(sum([info['cpuflags'] for engine, info in data.items()], []))
for flag in [x for x in requested if x not in desired]: desired.append(flag)
SYSTEM_CPU_FLAGS = [x for x in desired if x in actual]
# Report the results of our search, including any "missing flags
print ('Found | ', ' '.join(SYSTEM_CPU_FLAGS))
print ('Missing | ', ' '.join([x for x in desired if x not in actual]))
def scan_for_machine_id():
# If we don't have one, the server will give us one, and then include it
# in future HTTP responses. We simply need to save the a .txt file, later
global SYSTEM_MACHINE_ID
if os.path.isfile('machine.txt'):
with open('machine.txt') as fin:
SYSTEM_MACHINE_ID = fin.readlines()[0]
if SYSTEM_MACHINE_ID == 'None':
print('[NOTE] This machine is currently unregistered')
def init_client(arguments):
# Verify that we have make installed
print('\nScanning For Basic Utilities...')
locate_utility('make')
# Use Client.py's path as the base pathway
os.chdir(os.path.dirname(os.path.abspath(__file__)))
@@ -142,17 +259,14 @@ def validate_syzygy_exists():
for filename in tablebase_names():
# Build the paths when the configuration enables Syzygy
if SYZYGY_WDL_PATH:
wdlpath = os.path.join(SYZYGY_WDL_PATH, filename + '.rtbw')
# Reset the configuration if the file is missing
if SYZYGY_WDL_PATH and not os.path.isfile(wdlpath):
SYZYGY_WDL_PATH = None
# Report final results, which may conflict with the original configuration
if SYZYGY_WDL_PATH:
print('Verified Syzygy WDL (%s)' % (SYZYGY_WDL_PATH))
else: print('Syzygy WDL Not Found')
@@ -215,8 +329,8 @@ def unzip_delete_file(source, outdir):
def make_command(arguments, engine, src_path, network_path):
command = 'make %s=%s EXE=%s -j%s' % (
['CC', 'CXX']['++' in COMPILERS[engine]], COMPILERS[engine], engine, arguments.threads)
command = 'make %s=%s EXE=%s -j%d' % (
['CC', 'CXX']['++' in SYSTEM_COMPILERS[engine]], SYSTEM_COMPILERS[engine], engine, arguments.threads)
if network_path != None:
path = os.path.relpath(os.path.abspath(network_path), src_path)
@@ -378,101 +492,62 @@ def server_download_cutechess(arguments):
@try_until_success(mesg=ERRORS['configure'])
def server_configure_worker(arguments):
# Fetch { Engine -> Compilers } from the server
# Server tells us how to build or obtain binaries
target = url_join(arguments.server, 'clientGetBuildInfo')
data = requests.get(target, timeout=TIMEOUT_HTTP).json()
def get_version(compiler):
scan_for_compilers(data) # Public engines
scan_for_private_tokens(data) # Private engines
scan_for_cpu_flags(data) # For executing binaries
scan_for_machine_id() # None, or the content of machine.txt
# Try to execute the compiler from the command line
# First with `--version`, and again with just `version`
system_info = {
'compilers' : SYSTEM_COMPILERS, # Key: Engine, Value: (Compiler, Version)
'tokens' : SYSTEM_GIT_TOKENS, # Key: Engine, Value: True, for tokens we have
'cpu_flags' : SYSTEM_CPU_FLAGS, # List of CPU flags found in the Client or Server
'cpu_name' : SYSTEM_CPU_NAME, # Raw CPU name as per py-cpuinfo
'os_name' : SYSTEM_OS_NAME, # Should be Windows, Linux, or Darwin
'os_ver' : SYSTEM_OS_VER, # Release version of the OS
'python_ver' : SYSTEM_PYTHON_VER, # Python version running the Client
'mac_address' : SYSTEM_MAC_ADDRESS, # Used to softly verify the Machine IDs
'logical_cores' : SYSTEM_LOGICAL_CORES, # Logical cores, to differentiate hyperthreads
'physical_cores' : SYSTEM_PHYSICAL_CORES, # Physical cores, to differentiate hyperthreads
'ram_total_mb' : SYSTEM_RAM_TOTAL_MB, # Total RAM on the system, to avoid over assigning
'machine_id' : SYSTEM_MACHINE_ID, # Assigned value, or None. Will be replaced if wrong
'concurrency' : arguments.threads, # Threads to use to play games
'ncutechesses' : arguments.ncutechess, # Cutechess copies, usually equal to Socket count
'client_ver' : CLIENT_VERSION, # Version of the Client, which the server may reject
'syzygy_wdl' : bool(SYZYGY_WDL_PATH), # Whether or not the machine has Syzygy support
}
try:
process = Popen([compiler, '--version'], stdout=PIPE, stderr=PIPE)
stdout = process.communicate()[0].decode('utf-8')
return re.search(r'[0-9]+\.[0-9]+\.[0-9]+', stdout).group()
payload = {
'username' : arguments.username,
'password' : arguments.password,
'system_info' : json.dumps(system_info),
}
except:
process = Popen([compiler, 'version'], stdout=PIPE, stderr=PIPE)
stdout = process.communicate()[0].decode('utf-8')
return re.search(r'[0-9]+\.[0-9]+\.[0-9]+', stdout).group()
# Send all of this to the server, and get a Machine Id + Secret Token
target = url_join(arguments.server, 'clientWorkerInfo')
response = requests.post(target, data=payload, timeout=TIMEOUT_HTTP).json()
print ('\nScanning for Compilers...')
# The 'error' header is included if there was an issue
if 'error' in response:
print('[Error] %s\n' % (response['error']))
sys.exit()
# For each engine, attempt to find a valid compiler
for engine, build_info in data.items():
# Save the machine id, to avoid re-registering every time
with open('machine.txt', 'w') as fout:
fout.write(str(response['machine_id']))
# Private engines don't need to be compiled
if build_info['private']:
continue
for compiler in build_info['compilers']:
# Compilers may require a specific version
if '>=' in compiler:
compiler, version = compiler.split('>=')
version = tuple(map(int, version.split('.')))
else: version = (0, 0, 0)
try: match = get_version(compiler)
except: continue # Unable to execute compiler
# Compiler version was sufficient
if tuple(map(int, match.split('.'))) >= version:
print('%-20s | %-8s (%s)' % (engine, compiler, match))
COMPILERS[engine] = compiler
break
# Report missing engines in case the User is not expecting it
for engine in filter(lambda x: x not in COMPILERS and not data[x]['private'], data):
compiler = data[engine]['compilers']
print('%-20s | Missing %s' % (engine, compiler))
print ('\nScanning for Private Tokens...')
# For each engine, attempt to find a valid compiler
for engine, build_info in data.items():
# Public engines don't need access tokens
if not build_info['private']:
continue
# Private engines expect a credentials.engine file for the main repo
has_token = os.path.exists('credentials.%s' % (engine.replace(' ', '').lower()))
print('%-20s | %s' % (engine, ['Missing', 'Found'][has_token]))
if has_token: COMPILERS[engine] = True
print('\nScanning for CPU Flags...')
# Use GCC -march=native to find CPU info
CPUINFO = str(Popen(
'echo | gcc -march=native -E -dM -',
stdout=PIPE, shell=True
).communicate()[0])
# Check for each requested flag using the gcc dump
desired = [info['cpuflags'] for engine, info in data.items()]
flags = set(sum(desired, [])) # Trick to flatten the list
actual = set(f for f in flags if '%s 1' % (f) in CPUINFO)
COMPILERS['cpuflags'] = ' '.join(list(actual))
# Print out the results of our search
for flag in sorted(flags):
print ('%-20s | %s' % (flag, ['Missing', 'Found'][flag in actual]))
# Save the secret token, to send with all future requests
global SYSTEM_SECRET_TOKEN
SYSTEM_SECRET_TOKEN = response['secret']
@try_until_success(mesg=ERRORS['request'])
def server_request_workload(arguments):
print('\nRequesting Workload from Server...')
machine_id = 'None'
if os.path.isfile('machine.txt'):
with open('machine.txt') as fin:
machine_id = fin.readlines()[0]
if machine_id == 'None':
print('[NOTE] This machine is currently unregistered')
supported = ' '.join(COMPILERS.keys() - ['cpuflags'])
payload = {
@@ -825,7 +900,7 @@ def download_engine(arguments, workload, branch, network):
def run_benchmarks(arguments, workload, branch, engine, network):
cores = int(arguments.threads)
cores = arguments.threads
queue = multiprocessing.Queue()
name = workload['test'][branch]['name']
private = workload['engine']['private']
@@ -898,7 +973,7 @@ def build_cutechess_command(arguments, workload, dev_cmd, base_cmd, nps, cuteche
if SYZYGY_WDL_PATH and workload['test']['syzygy_adj'] != 'DISABLED':
flags += '-tb %s' % (SYZYGY_WDL_PATH.replace('\\', '\\\\'))
concurrency = int(arguments.threads) / int(arguments.ncutechess)
concurrency = arguments.threads / arguments.ncutechess
concurrency = concurrency // max(dev_threads, base_threads)
games = int(concurrency * workload['test']['workload_size'])
@@ -1002,11 +1077,14 @@ if __name__ == '__main__':
arguments = p.parse_args()
arguments.threads = int(arguments.threads)
arguments.ncutechess = int(arguments.ncutechess)
# Make sure the thread distibution between Cutechess copies is correct
assert (int(arguments.threads) >= 1)
assert (int(arguments.ncutechess) >= 1)
assert (int(arguments.threads) >= int(arguments.ncutechess))
assert (int(arguments.threads) % int(arguments.ncutechess) == 0)
assert (arguments.threads >= 1)
assert (arguments.ncutechess >= 1)
assert (arguments.threads >= arguments.ncutechess)
assert (arguments.threads % arguments.ncutechess == 0)
if arguments.username is None:
arguments.username = os.environ['OPENBENCH_USERNAME']
@@ -1020,11 +1098,12 @@ if __name__ == '__main__':
if arguments.fleet:
FLEET_MODE = True
check_for_utilities()
init_client(arguments)
server_download_cutechess(arguments)
server_configure_worker(arguments)
exit(1)
while True:
try:
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "",
"compilers" : ["g++"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src",
"compilers" : ["gcc"],
"cpuflags" : ["__AVX2__", "__FMA__", "__POPCNT__"]
"cpuflags" : ["AVX2", "FMA", "POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "",
"compilers" : ["cargo>=1.57.0"],
"cpuflags" : [ "__AVX2__", "__FMA__", "__POPCNT__"]
"cpuflags" : [ "AVX2", "FMA", "POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src",
"compilers" : ["clang", "gcc"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "",
"compilers" : ["g++"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src",
"compilers" : ["clang", "gcc"],
"cpuflags" : ["__AVX2__", "__FMA__", "__POPCNT__"]
"cpuflags" : ["AVX2", "FMA", "POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "",
"compilers" : ["cargo>=1.41.0"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src_files",
"compilers" : ["g++"],
"cpuflags" : ["__AVX2__", "__FMA__", "__POPCNT__"]
"cpuflags" : ["AVX2", "FMA", "POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build": {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src",
"compilers" : ["g++"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "build",
"compilers" : ["g++>=9.0.0"],
"cpuflags" : ["__AVX2__", "__FMA__", "__POPCNT__"]
"cpuflags" : ["AVX2", "FMA", "POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src",
"compilers" : ["gcc", "clang"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "src",
"compilers" : ["gcc"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "",
"compilers" : ["clang++", "g++"],
"cpuflags" : ["__POPCNT__"]
"cpuflags" : ["POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -12,7 +12,7 @@
"build" : {
"path" : "",
"compilers" : ["go"],
"cpuflags" : ["__AVX__", "__POPCNT__"]
"cpuflags" : ["AVX", "POPCNT"]
},
"testmodes" : {
+1 -1
View File
@@ -2,7 +2,7 @@ import django.apps
import threading, time
import OpenBench.utils
from django.core.management.commands.runserver import BaseRunserverCommand
from django.core.management.commands.runserver import Command as BaseRunserverCommand
class ArtifactWatcher(threading.Thread):
+4 -5
View File
@@ -19,7 +19,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
from django.db.models import CharField, IntegerField, BooleanField, FloatField
from django.db.models import ForeignKey, DateTimeField, OneToOneField
from django.db.models import JSONField, ForeignKey, DateTimeField, OneToOneField
from django.db.models import CASCADE, PROTECT, Model
from django.contrib.auth.models import User
@@ -50,15 +50,14 @@ class Profile(Model):
class Machine(Model):
user = ForeignKey(User, PROTECT, related_name='owner')
osname = CharField(max_length=128)
threads = IntegerField(default=0)
mnps = FloatField(default=0.00)
updated = DateTimeField(auto_now=True)
lastaddr = CharField(max_length=64, default='None')
secret = CharField(max_length=64, default='None')
info = JSONField()
workload = ForeignKey('Test', PROTECT, related_name='workload', default=1)
def __str__(self):
return '{0}-{1} ({2})'.format(self.user.username, self.osname, self.id)
return '[%d] %s' % (self.id, self.user.username)
class Result(Model):
+7
View File
@@ -288,4 +288,11 @@ body, html, main{
/* ??? */
td pre {
margin: 0px;
padding: 0px;
}
+33
View File
@@ -168,6 +168,37 @@ def testIdToPrettyName(test_id):
def testIdToTimeControl(test_id):
return OpenBench.models.Test.objects.get(id=test_id).timecontrol
def cpuflagsBlock(machine, N=8):
reported = []
flags = machine.info['cpu_flags']
general_flags = ['BMI2', 'POPCNT']
broad_avx_flags = ['AVX2', 'AVX', 'SSE4_2', 'SSE4_1', 'SSSE3']
for flag in general_flags:
if flag in flags:
reported.append(flag)
break
for flag in broad_avx_flags:
if flag in flags:
reported.append(flag)
break
for flag in flags:
if flag not in general_flags and flag not in broad_avx_flags:
reported.append(flag)
return ' '.join(reported)
def compilerBlock(machine):
string = ''
for engine, info in machine.info['compilers'].items():
string += '%-16s %-8s (%s)\n' % (engine, info[0], info[1])
return string
register = django.template.Library()
register.filter('oneDigitPrecision', oneDigitPrecision)
register.filter('twoDigitPrecision', twoDigitPrecision)
@@ -183,3 +214,5 @@ register.filter('testIsFRC', testIsFRC)
register.filter('resolveNetworkURL', resolveNetworkURL)
register.filter('testIdToPrettyName', testIdToPrettyName)
register.filter('testIdToTimeControl', testIdToTimeControl)
register.filter('cpuflagsBlock', cpuflagsBlock)
register.filter('compilerBlock', compilerBlock)
+3 -1
View File
@@ -43,6 +43,7 @@ urlpatterns = [
django.urls.path(r'events/', OpenBench.views.events),
django.urls.path(r'events/<int:page>/', OpenBench.views.events),
django.urls.path(r'machines/', OpenBench.views.machines),
django.urls.path(r'machines/<int:machineid>/', OpenBench.views.machines),
# Links for viewing and managing tests (maintain Legacy)
django.urls.path(r'test/<int:id>/', OpenBench.views.test),
@@ -61,6 +62,7 @@ urlpatterns = [
# Links for the Client to work with the Server
django.urls.path(r'clientGetFiles/', OpenBench.views.clientGetFiles),
django.urls.path(r'clientGetBuildInfo/', OpenBench.views.clientGetBuildInfo),
django.urls.path(r'clientWorkerInfo/', OpenBench.views.clientWorkerInfo),
django.urls.path(r'clientGetWorkload/', OpenBench.views.clientGetWorkload),
django.urls.path(r'clientGetNetwork/<str:sha256>/', OpenBench.views.clientGetNetwork),
django.urls.path(r'clientWrongBench/', OpenBench.views.clientWrongBench),
@@ -71,6 +73,6 @@ urlpatterns = [
# Redirect anything else to the Index
django.urls.path(r'', OpenBench.views.index),
# Link for Ethereal 13.00 PRO Sales
# Link for Ethereal Sales
django.urls.path(r'Ethereal/', OpenBench.views.buyEthereal),
]
+23 -2
View File
@@ -116,8 +116,8 @@ def getMachineStatus(username=None):
machines = machines.filter(user__username=username)
return ": {0} Machines / ".format(len(machines)) + \
"{0} Threads / ".format(sum([f.threads for f in machines])) + \
"{0} MNPS ".format(round(sum([f.threads * f.mnps for f in machines]), 2))
"{0} Threads / ".format(sum([f.info['concurrency'] for f in machines])) + \
"{0} MNPS ".format(round(sum([f.info['concurrency'] * f.mnps for f in machines]), 2))
def getPaging(content, page, url, pagelen=25):
@@ -404,6 +404,27 @@ def createNewTest(request):
return test, None
def get_machine(machineid, user, info):
# Create a new machine if we don't have an id
if machineid == 'None':
return Machine(user=user, info=info)
# Fetch the requested machine, which hopefully exists
try: machine = Machine.objects.get(id=int(machineid))
except: return None
# Workload requests should always contain a MAC
if 'mac_address' not in machine.info:
return None
# Soft-verify by checking if the MAC addresses match
if machine.info['mac_address'] != info['mac_address']:
return None
return machine
def getMachine(machineid, user, osname, threads):
# Create a new Machine if needed
+39 -17
View File
@@ -18,7 +18,7 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import os, hashlib, mimetypes, datetime, json, random
import os, hashlib, datetime, json, secrets
import django.http
import django.shortcuts
@@ -34,7 +34,7 @@ from OpenSite.settings import MEDIA_ROOT
from ipware import get_client_ip
from wsgiref.util import FileWrapper
from django.db.models import F
from django.http import HttpResponse, FileResponse
from django.http import HttpResponse, FileResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.core.files.storage import FileSystemStorage
from django.core.files.base import ContentFile
@@ -381,7 +381,7 @@ def events(request, page=1):
data = {'events' : events[start:end], 'paging' : paging};
return render(request, 'events.html', data)
def machines(request):
def machines(request, machineid=None):
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
@@ -390,8 +390,13 @@ def machines(request):
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
data = {'machines' : OpenBench.utils.getRecentMachines()}
return render(request, 'machines.html', data)
if machineid == None:
data = {'machines' : OpenBench.utils.getRecentMachines()}
return render(request, 'machines.html', data)
else:
data = {'machine' : OpenBench.models.Machine.objects.get(id=machineid)}
return render(request, 'machine.html', data)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@@ -624,29 +629,46 @@ def scripts(request):
@not_minified_response
def clientGetFiles(request):
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# GET : Return a URL to the location of Cutechess for Windows and Linux #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## Location of static compile of Cutechess for Windows and Linux.
## OpenBench does not serve these files, but points to a repo ideally.
return HttpResponse(OpenBench.config.OPENBENCH_CONFIG['corefiles'])
@not_minified_response
def clientGetBuildInfo(request):
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# GET : Return a Dictionary of all of the Engines that are present in #
# config.py, as well as the required compilation tools for them #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## Information pulled from the config about how to build each engine.
## Toss in a private flag as well to indicate the need for Github Tokens.
data = {}
for engine, config in OpenBench.config.OPENBENCH_CONFIG['engines'].items():
data[engine] = config['build']
data[engine]['private'] = config['private']
return HttpResponse(json.dumps(data))
return JsonResponse(data)
@csrf_exempt
@not_minified_response
def clientWorkerInfo(request):
# Verify the User's credentials
try: user = authenticate(request, True)
except UnableToAuthenticate:
return JsonResponse({ 'error' : 'Bad Credentials' })
# Attempt to fetch the Machine, or create a new one
info = json.loads(request.POST['system_info'])
machine = OpenBench.utils.get_machine(info['machine_id'], user, info)
# Indicate invalid request
if not machine:
return JsonResponse({ 'error' : 'Bad Machine Id' })
# Save the machine's latest information
machine.secret = secrets.token_hex(32)
machine.save()
# Pass back the Machine Id, and Secret Token for this session
return JsonResponse({ 'machine_id' : machine.id, 'secret' : machine.secret })
@csrf_exempt
@not_minified_response
+50
View File
@@ -0,0 +1,50 @@
{% extends "OpenBench/base.html" %}
{% load mytags %}
{% block style %}
{% load static %}
{% endblock %}
{% block content %}
<div id="config" style="display: block; overflow-x: auto;">
<table class="test-config left-align wrappable" style="table-layout: auto; width: 100%;">
<tr><td class="td-label">User</td><td>{{machine.user.username}}</td></tr>
<tr><td class="td-label">Client Version</td><td>{{machine.info.client_ver}}</td></tr>
<tr><td class="td-label">Python Version</td><td>{{machine.info.python_ver}}</td></tr>
<tr><td class="td-label">System Version</td><td>{{machine.info.os_name}} {{machine.info.os_ver}}</td></tr>
<tr><td class="td-label"></td><td><br></td></tr>
<tr><td class="td-label">CPU Name</td><td>{{machine.info.cpu_name}}</td></tr>
<tr><td class="td-label">CPU Flags</td><td><pre>{{machine|cpuflagsBlock}}</pre></td></tr>
<tr><td class="td-label">Logical Cores</td><td>{{machine.info.logical_cores}}</td></tr>
<tr><td class="td-label">Physical Cores</td><td>{{machine.info.physical_cores}}</td></tr>
<tr><td class="td-label">Total RAM (MB)</td><td>{{machine.info.ram_total_mb}}</td></tr>
<tr><td class="td-label">Syzygy WDL-6</td><td>{{machine.info.syzygy_wdl}}</td></tr>
<tr><td class="td-label"></td><td><br></td></tr>
{% if machine.info.tokens|length > 0 %}
<tr><td class="td-label">Tokens</td><td>{{machine.info.tokens|join:" "}}</td></tr>
{% endif %}
{% if machine.info.compilers|length > 0 %}
<tr><td class="td-label">Compilers</td><td><pre>{{machine|compilerBlock}}</pre></td></tr>
{% endif %}
</table>
</div>
{% endblock %}
system_info = {
'compilers' : SYSTEM_COMPILERS, # Key: Engine, Value: (Compiler, Version)
'tokens' : SYSTEM_GIT_TOKENS, # Key: Engine, Value: True, for tokens we have
'cpu_flags' : SYSTEM_CPU_FLAGS, # List of CPU flags found in the Client or Server
}
+7 -5
View File
@@ -10,7 +10,7 @@
<th>#</th>
<th>User</th>
<th>System</th>
<th>Updated</th>
<th>CPU</th>
<th>Workload</th>
<th>Threads</th>
<th>MNPS</th>
@@ -18,16 +18,18 @@
{% for machine in machines %}
<tr>
<td class="numeric">{{machine.id}}</td>
<td class="numeric"><a href="/machines/{{machine.id}}/">{{machine.id}}</a></td>
<td>{{machine.user.username|capfirst}}</td>
<td>{{machine.osname|truncatewords:1|slice:":-2"}}</td>
<td class="timestamp">{{machine.updated|date:'U'}}</td>
<td>{{machine.info.os_name}}</td>
<td>{{machine.info.cpu_name}}</td>
<td> <a href="/test/{{machine.workload.id}}">{{machine.workload.dev.name|prettyName}}</a></td>
<td class="numeric">{{machine.threads}}</td>
<td class="numeric">{{machine.info.concurrency}}</td>
<td class="numeric">{{machine.mnps|twoDigitPrecision}}</td>
</tr>
{% endfor %}
</table>
{% endblock %}