Skip to content

Commit

Permalink
Use the native target if available in SF
Browse files Browse the repository at this point in the history
Also deal with the Makefile shell script permission issue on Linux worker.
That should be solved by:
official-stockfish/Stockfish#4803
  • Loading branch information
vondele authored and ppigazzini committed Sep 24, 2023
1 parent 29d30c9 commit a95573d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/fishtest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
on how frequently the main instance flushes its run cache.
"""

WORKER_VERSION = 216
WORKER_VERSION = 217


def validate_request(request):
Expand Down
20 changes: 19 additions & 1 deletion worker/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ def make_targets():
with subprocess.Popen(
["make", "help"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
bufsize=1,
close_fds=not IS_WINDOWS,
Expand All @@ -539,6 +540,11 @@ def make_targets():
targets.append(line.split()[0])
if "Supported archs:" in line:
read_targets = True
for line in iter(p.stderr.readline, ""):
if "native" in targets and "get_native_properties.sh" in line:
targets.remove("native")
break

except (OSError, subprocess.SubprocessError) as e:
print("Exception while executing make help:\n", e, sep="", file=sys.stderr)
raise FatalException("It appears 'make' is not properly installed")
Expand All @@ -556,6 +562,13 @@ def make_targets():
def find_arch(compiler):
"""Find the best arch string based on the cpu/g++ capabilities and Makefile targets"""
targets = make_targets()

# recent SF support a native target
if "native" in targets:
print("Using native target architecture")
return "native"

# older SF will need to fall back to this implementation
props = gcc_props() if compiler == "g++" else clang_props()

if is_64bit():
Expand Down Expand Up @@ -681,7 +694,12 @@ def setup_engine(
# TODO: 'make strip' works fine with the new Makefile,
# 'try' should be safely dropped in the future
try:
subprocess.run("make strip COMP={}".format(comp), shell=True, check=True)
subprocess.run(
"make strip COMP={}".format(comp),
stderr=subprocess.DEVNULL,
shell=True,
check=True,
)
except Exception as e:
print("Exception stripping binary:\n", e, sep="", file=sys.stderr)

Expand Down
2 changes: 1 addition & 1 deletion worker/sri.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"__version": 216, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "+j8t596hJHgRde7jqxJibKLXPvgi1ygjM7cp/hKzEWF97aRCehCBiSEMsgkZkTUo", "games.py": "A1+dhkNt3mfL7rde3srtxVl0gDGDq3EaJNbmrKsQXON20bdCaC1sZSnB1VwLCQlw"}
{"__version": 217, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "cFunWo4iviMvzdV9b/8PTfOLoXbovy4hWwmGR6OI70agi5dkwoCJ07BoYwBU+xjd", "games.py": "pqyY62ZE491mecjnXvByfr1mMuhXU5NDg6BbE6WZ4aKuzR12bSFQUSHrQnDt7374"}
2 changes: 1 addition & 1 deletion worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# Several packages are called "expression".
# So we make sure to use the locally installed one.

WORKER_VERSION = 216
WORKER_VERSION = 217
FILE_LIST = ["updater.py", "worker.py", "games.py"]
HTTP_TIMEOUT = 30.0
INITIAL_RETRY_TIME = 15.0
Expand Down

0 comments on commit a95573d

Please sign in to comment.