Add Windows CMake build + workaround NVIDIA OpenCL #include bug (enables Blackwell sm_120) - #77
Open
Dalailalama wants to merge 3 commits into
Open
Conversation
When clBuildProgram fails, the existing code calls malloc(logsize) without +1 for null termination, prints with no fflush, then exit(-1). On platforms where the OpenCL implementation returns logsize=0 (notably NVIDIA driver bug with #include directives in kernel source), this is undefined behavior: printf reads past the allocated buffer and prints garbage like 'log:C', giving the user no actionable diagnostic. Fixes: - Print the clBuildProgram error code explicitly - malloc(logsize+1) and explicit null terminator - fflush(stdout) at every print site to defeat stdio buffering before exit - Mirror log to opencl_build_log.txt as backup against pipe-buffering edge cases
…driver bug NVIDIA's OpenCL ICD (driver 595.97+ on Linux, 596.36+ on Windows; confirmed broken on Blackwell sm_120 RTX 50-series) fails clBuildProgram with CL_OUT_OF_HOST_MEMORY (err=-6) and zero build-log bytes whenever the kernel source contains a #include directive. The driver parser dies silently before emitting any diagnostic. Reference: https://forums.developer.nvidia.com/t/bug-opencl-include-directive-causes-cl-out-of-host-memory-on-driver-595-97/366719 Workaround: inline kernel2.h's contents directly into code_head.cl. NVIDIA's OpenCL compiler handles the literal content fine; only the #include keyword triggers the bug. AMD and Intel OpenCL drivers are unaffected. Verified by docking tolvaptan into PDB 9HAP (V2R receptor) on an RTX 5050 Laptop GPU (Blackwell sm_120). Mode-1 score: -9.7 kcal/mol (consistent with CPU AutoDock Vina baselines at equivalent search effort), 2 seconds wall time with cached kernels.
….x / Boost 1.83+) Upstream ships only a Linux Makefile and a README describing manual Visual Studio project creation. This adds a CMakeLists.txt that builds out of the box with VS2022 + MSVC 19.44 + Boost 1.83 + CUDA 13.x on Windows. Key features: - CMake 3.20+ compatible (works with CMake 4.x which removed legacy FindBoost) - Boost found via CONFIG mode (BoostConfig.cmake) as required by CMake 4.x - OpenCL.lib auto-detected from CUDA toolkit install - All Makefile preprocessor definitions ported (NVIDIA_PLATFORM, OPENCL_2_0/3_0, WINDOWS, SMALL_BOX, BUILD_KERNEL_FROM_SOURCE, etc.) - /Zc:preprocessor flag for CUDA 13.x CCCL header compatibility - _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING (main.cpp uses <experimental/filesystem>) - BOOST_ALL_DYN_LINK to match DLL Boost variants shipped by the standard installer Usage: cmake -B build -G 'Visual Studio 17 2022' -A x64 then cmake --build build --config Release. Produces build/bin/AutoDock-Vina-GPU-2-1.exe. Boost path overridable via -DBOOST_ROOT=...; CUDA path via -DCUDA_ROOT=...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds three independent but related improvements that together enable Vina-GPU 2.1 on Windows + NVIDIA Blackwell GPUs (RTX 50-series, sm_120):
Native Windows CMake build system (
CMakeLists.txt) — upstream ships only a Linux Makefile and a README describing manual Visual Studio project setup. This commit adds a CMake build that works with VS2022 + MSVC 19.44 + Boost 1.83 + CUDA 13.x out of the box. CMake 4.x compatible.Workaround for NVIDIA OpenCL
#includedriver bug (code_head.cl) — NVIDIA's OpenCL driver (595.97+ on Linux, 596.36+ on Windows; confirmed on Blackwell sm_120) silently failsclBuildProgramwithCL_OUT_OF_HOST_MEMORY(err=-6) and zero log bytes when kernel source contains a#includedirective. This affects every Vina-GPU 2.1 user on a current NVIDIA driver becausecode_head.clbegins with#include "kernel2.h". Workaround: inline kernel2.h content directly. AMD/Intel drivers continue to work as before.Reference: https://forums.developer.nvidia.com/t/bug-opencl-include-directive-causes-cl-out-of-host-memory-on-driver-595-97/366719
Verbose OpenCL build log on failure (
wrapcl.cpp) — existing error handling has a buffer-overrun bug (malloc(logsize)without+1for null terminator) and stdio buffering issues (nofflush(stdout)beforeexit(-1)). On platforms where the OpenCL driver returnslogsize=0, the existing code prints uninitialized memory likelog:C. Fixed by adding null termination, fflush at every print site, explicitly printing the clBuildProgram error code, and mirroring the log toopencl_build_log.txtas backup against pipe-buffering edge cases.Validation
Tested with a representative docking benchmark (drug-like ligand + GPCR receptor from the PDB) on:
Result:
GPU utilization observed at 100% during dock (nvidia-smi sample, 126 MiB VRAM, 51W). Output PDBQT is in standard AutoDock Vina format.
Impact
To the best of my knowledge this is the first documented successful Vina-GPU 2.1 run on an RTX 50-series (Blackwell) GPU. Prior to these patches, on the same hardware:
CL_OUT_OF_HOST_MEMORY, no log) due to the NVIDIA#includedriver bug.All three commits are independent — each can be cherry-picked separately if preferred.
Notes
-DBOOST_ROOT=...and-DCUDA_ROOT=...(not tested by me, but the build script is platform-agnostic).code_head.clon Windows is git's standardautocrlfnormalization (harmless; content stored as LF in the repo).