Skip to content

Commit 9293c3a

Browse files
committed
Merge commit '4f78e167' into muon-rebased-2
2 parents 11dece9 + 4f78e16 commit 9293c3a

35 files changed

+479
-51
lines changed

.github/workflows/build.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-linux:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y cmake build-essential zlib1g-dev libzip-dev opencl-headers ocl-icd-opencl-dev
24+
25+
- name: Cache CMake build
26+
uses: actions/cache@v4
27+
with:
28+
path: |
29+
cpp/CMakeCache.txt
30+
cpp/CMakeFiles
31+
key: ${{ runner.os }}-cmake-${{ hashFiles('**/CMakeLists.txt') }}
32+
restore-keys: |
33+
${{ runner.os }}-cmake-
34+
35+
- name: Configure CMake
36+
working-directory: cpp
37+
run: |
38+
cmake . -DUSE_BACKEND=OPENCL -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-s"
39+
40+
- name: Build
41+
working-directory: cpp
42+
run: |
43+
make -j$(nproc)
44+
45+
- name: Run tests
46+
working-directory: cpp
47+
run: |
48+
./katago runtests
49+
50+
- name: Upload artifact
51+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: katago-linux-opencl
55+
path: cpp/katago
56+
57+
build-macos:
58+
runs-on: macos-latest
59+
permissions:
60+
contents: read
61+
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v4
65+
66+
- name: Install dependencies
67+
run: |
68+
brew install zlib libzip opencl-headers
69+
- name: Cache CMake build
70+
uses: actions/cache@v4
71+
with:
72+
path: |
73+
cpp/CMakeCache.txt
74+
cpp/CMakeFiles
75+
cpp/build.ninja
76+
cpp/.ninja_deps
77+
cpp/.ninja_log
78+
key: ${{ runner.os }}-cmake-${{ hashFiles('**/CMakeLists.txt') }}
79+
restore-keys: |
80+
${{ runner.os }}-cmake-
81+
- name: Configure CMake
82+
working-directory: cpp
83+
run: |
84+
cmake . -G Ninja -DUSE_BACKEND=OPENCL -DCMAKE_BUILD_TYPE=Release
85+
- name: Build
86+
working-directory: cpp
87+
run: |
88+
ninja
89+
- name: Run tests
90+
working-directory: cpp
91+
run: |
92+
./katago runtests
93+
- name: Upload artifact
94+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: katago-macos-opencl
98+
path: cpp/katago
99+
100+
build-windows:
101+
runs-on: windows-latest
102+
permissions:
103+
contents: read
104+
105+
steps:
106+
- name: Checkout code
107+
uses: actions/checkout@v4
108+
109+
- name: Setup MSVC
110+
uses: microsoft/setup-msbuild@v2
111+
112+
- name: Cache vcpkg packages
113+
uses: actions/cache@v4
114+
with:
115+
path: |
116+
${{ env.VCPKG_INSTALLATION_ROOT }}/installed
117+
${{ env.VCPKG_INSTALLATION_ROOT }}/packages
118+
key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }}-opencl
119+
restore-keys: |
120+
${{ runner.os }}-vcpkg-
121+
122+
- name: Install vcpkg dependencies
123+
run: |
124+
vcpkg install zlib:x64-windows libzip:x64-windows opencl:x64-windows
125+
126+
- name: Configure CMake
127+
working-directory: cpp
128+
run: |
129+
cmake . -G "Visual Studio 17 2022" -A x64 `
130+
-DUSE_BACKEND=OPENCL `
131+
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
132+
133+
- name: Build
134+
working-directory: cpp
135+
run: |
136+
cmake --build . --config Release -j 4
137+
138+
- name: Copy required DLLs
139+
working-directory: cpp
140+
run: |
141+
$vcpkgRoot = $env:VCPKG_INSTALLATION_ROOT
142+
Copy-Item "$vcpkgRoot/installed/x64-windows/bin/*.dll" -Destination "Release/"
143+
144+
- name: Run tests
145+
working-directory: cpp
146+
run: |
147+
Release/katago.exe runtests
148+
149+
- name: Upload artifact
150+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
151+
uses: actions/upload-artifact@v4
152+
with:
153+
name: katago-windows-opencl
154+
path: cpp/Release/

cpp/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,12 @@ elseif(USE_BACKEND STREQUAL "METAL")
114114
set(NEURALNET_BACKEND_SOURCES
115115
neuralnet/metalbackend.cpp
116116
)
117-
_swift_generate_cxx_header_target(
118-
KataGoSwift_Swift_h
117+
add_library(KataGoSwift STATIC
118+
neuralnet/metalbackend.swift)
119+
_swift_generate_cxx_header(
119120
KataGoSwift
120121
"${CMAKE_CURRENT_BINARY_DIR}/include/KataGoSwift/KataGoSwift-swift.h"
121122
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/neuralnet/metalbackend.swift")
122-
add_library(KataGoSwift STATIC
123-
neuralnet/metalbackend.swift)
124-
add_dependencies(KataGoSwift KataGoSwift_Swift_h)
125123
target_include_directories(KataGoSwift PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/include")
126124
set_target_properties(KataGoSwift PROPERTIES Swift_MODULE_NAME "KataGoSwift")
127125
target_compile_options(KataGoSwift PUBLIC

cpp/command/analysis.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct AnalyzeRequest {
3535
bool includeMovesOwnershipStdev;
3636
bool includePolicy;
3737
bool includePVVisits;
38+
bool includeNoResultValue;
3839

3940
bool reportDuringSearch;
4041
double reportDuringSearchEvery;
@@ -238,6 +239,7 @@ int MainCmds::analysis(const vector<string>& args) {
238239
"includeOwnershipStdev",
239240
"includePolicy",
240241
"includePVVisits",
242+
"includeNoResultValue",
241243
"reportDuringSearchEvery",
242244
"firstReportDuringSearchAfter",
243245
"priority",
@@ -323,6 +325,7 @@ int MainCmds::analysis(const vector<string>& args) {
323325
request->includeOwnership,request->includeOwnershipStdev,
324326
request->includeMovesOwnership,request->includeMovesOwnershipStdev,
325327
request->includePVVisits,
328+
request->includeNoResultValue,
326329
ret
327330
);
328331

@@ -536,7 +539,8 @@ int MainCmds::analysis(const vector<string>& args) {
536539
nnEval->clearCache();
537540
if(humanEval != NULL)
538541
humanEval->clearCache();
539-
evalCache->clear();
542+
if(evalCache != nullptr)
543+
evalCache->clear();
540544
pushToWrite(new string(input.dump()));
541545
}
542546
else if(action == "terminate") {
@@ -618,6 +622,7 @@ int MainCmds::analysis(const vector<string>& args) {
618622
rbase.includeMovesOwnershipStdev = false;
619623
rbase.includePolicy = false;
620624
rbase.includePVVisits = false;
625+
rbase.includeNoResultValue = false;
621626
rbase.reportDuringSearch = false;
622627
rbase.reportDuringSearchEvery = 1e30;
623628
rbase.firstReportDuringSearchAfter = 1e30;
@@ -1027,6 +1032,11 @@ int MainCmds::analysis(const vector<string>& args) {
10271032
if(!suc)
10281033
continue;
10291034
}
1035+
if(input.find("includeNoResultValue") != input.end()) {
1036+
bool suc = parseBoolean(input, "includeNoResultValue", rbase.includeNoResultValue, "Must be a boolean");
1037+
if(!suc)
1038+
continue;
1039+
}
10301040
if(input.find("reportDuringSearchEvery") != input.end()) {
10311041
bool suc = parseDouble(input, "reportDuringSearchEvery", rbase.reportDuringSearchEvery, 0.001, 1000000.0, "Must be number of seconds from 0.001 to 1000000.0");
10321042
if(!suc)
@@ -1171,6 +1181,7 @@ int MainCmds::analysis(const vector<string>& args) {
11711181
newRequest->includeMovesOwnershipStdev = rbase.includeMovesOwnershipStdev;
11721182
newRequest->includePolicy = rbase.includePolicy;
11731183
newRequest->includePVVisits = rbase.includePVVisits;
1184+
newRequest->includeNoResultValue = rbase.includeNoResultValue;
11741185
newRequest->reportDuringSearch = rbase.reportDuringSearch;
11751186
newRequest->reportDuringSearchEvery = rbase.reportDuringSearchEvery;
11761187
newRequest->firstReportDuringSearchAfter = rbase.firstReportDuringSearchAfter;

cpp/command/contribute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static void runAndUploadSingleGame(
273273

274274
// Usual analysis response fields
275275
ret["turnNumber"] = hist.moveHistory.size();
276-
search->getAnalysisJson(perspective,analysisPVLen,preventEncore,true,alwaysIncludeOwnership,false,false,false,false,ret);
276+
search->getAnalysisJson(perspective,analysisPVLen,preventEncore,true,alwaysIncludeOwnership,false,false,false,false,false,ret);
277277
std::cout << ret.dump() + "\n" << std::flush; // no endl due to race conditions
278278
}
279279

cpp/command/evalsgf.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ int MainCmds::evalsgf(const vector<string>& args) {
642642
bool includeMovesOwnershipStdev = false;
643643
bool includePVVisits = true;
644644
nlohmann::json ret;
645+
bool includeNoResultValue = false;
645646
bool suc = search->getAnalysisJson(
646647
perspective,
647648
analysisPVLen,
@@ -652,6 +653,7 @@ int MainCmds::evalsgf(const vector<string>& args) {
652653
includeMovesOwnership,
653654
includeMovesOwnershipStdev,
654655
includePVVisits,
656+
includeNoResultValue,
655657
ret
656658
);
657659
if(suc) {

cpp/command/gtp.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ struct GTPEngine {
734734
bool showMovesOwnershipStdev = false;
735735
bool showPVVisits = false;
736736
bool showPVEdgeVisits = false;
737+
bool showNoResultValue = false;
737738
double secondsPerReport = TimeControls::UNLIMITED_TIME_DEFAULT;
738739
vector<int> avoidMoveUntilByLocBlack;
739740
vector<int> avoidMoveUntilByLocWhite;
@@ -875,6 +876,8 @@ struct GTPEngine {
875876
out << " scoreStdev " << data.scoreStdev;
876877
out << " scoreLead " << lead;
877878
out << " scoreSelfplay " << scoreMean;
879+
if(args.showNoResultValue)
880+
out << " noResultValue " << data.noResultValue;
878881
out << " prior " << data.policyPrior;
879882
out << " lcb " << lcb;
880883
out << " utilityLcb " << utilityLcb;
@@ -1712,6 +1715,7 @@ static GTPEngine::AnalyzeArgs parseAnalyzeCommand(
17121715
bool showMovesOwnershipStdev = false;
17131716
bool showPVVisits = false;
17141717
bool showPVEdgeVisits = false;
1718+
bool showNoResultValue = false;
17151719
vector<int> avoidMoveUntilByLocBlack;
17161720
vector<int> avoidMoveUntilByLocWhite;
17171721
bool gotAvoidMovesBlack = false;
@@ -1852,6 +1856,9 @@ static GTPEngine::AnalyzeArgs parseAnalyzeCommand(
18521856
else if(isKata && key == "pvEdgeVisits" && Global::tryStringToBool(value,showPVEdgeVisits)) {
18531857
continue;
18541858
}
1859+
else if(isKata && key == "noResultValue" && Global::tryStringToBool(value,showNoResultValue)) {
1860+
continue;
1861+
}
18551862

18561863
parseFailed = true;
18571864
break;
@@ -1872,6 +1879,7 @@ static GTPEngine::AnalyzeArgs parseAnalyzeCommand(
18721879
args.showMovesOwnershipStdev = showMovesOwnershipStdev;
18731880
args.showPVVisits = showPVVisits;
18741881
args.showPVEdgeVisits = showPVEdgeVisits;
1882+
args.showNoResultValue = showNoResultValue;
18751883
args.avoidMoveUntilByLocBlack = avoidMoveUntilByLocBlack;
18761884
args.avoidMoveUntilByLocWhite = avoidMoveUntilByLocWhite;
18771885
return args;

0 commit comments

Comments
 (0)