Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ endif()

# Include directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) # For proto/ includes
if(USE_METAL AND METAL_CPP_AVAILABLE)
include_directories(${METAL_CPP_DIR})
endif()
Expand Down Expand Up @@ -277,7 +278,26 @@ endif()
set(MCTS_SOURCES
src/mcts/position_adapter.cpp src/mcts/position_classifier.cpp
src/mcts/ab_integration.cpp src/mcts/thread_safe_mcts.cpp
src/mcts/parallel_hybrid_search.cpp src/mcts/apple_silicon_mcts.cpp)
src/mcts/parallel_hybrid_search.cpp src/mcts/apple_silicon_mcts.cpp
src/mcts/nn_mcts_evaluator.cpp)

# Neural Network source files (Lc0-compatible inference)
# Note: This is a stub implementation. Full implementation requires ~95k lines
# See src/nn/README.md and IMPLEMENTATION_GUIDE.md for details
#
# Current status: Protobuf schema + policy tables + position encoding compiled
# Stub files in src/nn/ are copied from lc0 but NOT adapted yet:
# - encoder.cpp, encoder.h, loader.cpp, loader.h, network.h
# These will NOT compile until adapted (see IMPLEMENTATION_GUIDE.md)
set(NN_SOURCES
proto/net.pb.cc
src/nn/tables/policy_utils.cpp
src/nn/position_encoder.cpp)
# TODO: Add when implemented and adapted:
# src/nn/loader.cpp
# TODO: Metal backend when implemented:
# src/nn/metal/metal_backend.mm
# src/nn/metal/network_graph.mm

# Metal GPU acceleration (macOS only)
if(USE_METAL AND METAL_CPP_AVAILABLE)
Expand Down Expand Up @@ -328,17 +348,19 @@ set(SOURCES
${UCI_SOURCES}
${SYZYGY_SOURCES}
${GPU_SOURCES}
${MCTS_SOURCES})
${MCTS_SOURCES}
${NN_SOURCES})

# Create executable
if(USE_CUDA AND CUDA_AVAILABLE)
# CUDA executable with mixed source files
add_executable(metalfish ${SOURCES} ${CUDA_SOURCES})
set_target_properties(metalfish PROPERTIES CUDA_SEPARABLE_COMPILATION ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON)
target_link_libraries(metalfish ${CUDA_LINK_LIBRARIES})
target_link_libraries(metalfish ${CUDA_LINK_LIBRARIES} protobuf)
else()
add_executable(metalfish ${SOURCES})
target_link_libraries(metalfish protobuf)
endif()

# Add shader dependency if available
Expand Down Expand Up @@ -408,7 +430,8 @@ if(BUILD_TESTS)
tests/test_gpu_module.cpp
tests/test_metal.cpp
tests/test_gpu_nnue.cpp
tests/test_cuda.cpp)
tests/test_cuda.cpp
tests/test_nn_comparison.cpp)

if(USE_CUDA AND CUDA_AVAILABLE)
# CUDA test executable
Expand All @@ -422,12 +445,13 @@ if(BUILD_TESTS)
${SYZYGY_SOURCES}
${GPU_SOURCES}
${MCTS_SOURCES}
${NN_SOURCES}
${CUDA_SOURCES})
set_target_properties(
metalfish_tests PROPERTIES CUDA_SEPARABLE_COMPILATION ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON)
target_link_libraries(metalfish_tests Threads::Threads
${CUDA_LINK_LIBRARIES})
${CUDA_LINK_LIBRARIES} protobuf)
else()
add_executable(
metalfish_tests
Expand All @@ -438,8 +462,9 @@ if(BUILD_TESTS)
${UCI_SOURCES}
${SYZYGY_SOURCES}
${GPU_SOURCES}
${MCTS_SOURCES})
target_link_libraries(metalfish_tests Threads::Threads)
${MCTS_SOURCES}
${NN_SOURCES})
target_link_libraries(metalfish_tests Threads::Threads protobuf)
endif()

if(APPLE
Expand Down
Loading