From 0499f8f7bed1a3f7a8d116ec2dac59dfd6406fb2 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Wed, 7 Oct 2026 01:33:44 +0200 Subject: [PATCH] engine: a Windows HIP engine says when the runtime in use is not the bundled one beside it (#1261) The report shows the bundled amdhip64_7.dll next to strata.exe and the System32 copy (a different build) in use, with the prompt GEMMs failing. The import is bound before main, so the engine cannot swap it; it now prints a WARNING naming the bundled file when the loaded one is another, so the log carries the fact. Nothing else changes. The fix itself (loading the bundled runtime by full path, or a delay-loaded import) needs a Windows AMD machine to test and is not in this commit. --- src/program/generate.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/program/generate.cpp b/src/program/generate.cpp index db6e97d0..68e8f89b 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -3872,8 +3872,24 @@ int main(int argc, char** argv) { // #468 #461: which HIP runtime was loaded - the bundled one beside the exe, or an AMD driver's System32 copy if (HMODULE h = GetModuleHandleA("amdhip64_7.dll")) { char path[MAX_PATH] = {}; - if (GetModuleFileNameA(h, path, MAX_PATH) > 0) + if (GetModuleFileNameA(h, path, MAX_PATH) > 0) { std::fprintf(stderr, "strata generate: HIP runtime %s\n", path); + // #1261: the bundled runtime sits beside the exe, but Windows bound the import to another copy (the AMD + // driver's, in System32, was seen with a different build): kernels of this engine can then fail + // (hipErrorInvalidDeviceFunction in the prompt GEMMs). Said, not changed - the import is bound before main. + char exe[MAX_PATH] = {}; + if (GetModuleFileNameA(nullptr, exe, MAX_PATH) > 0) { + std::string beside(exe); + const size_t cut = beside.find_last_of("\\/"); + beside = (cut == std::string::npos ? std::string() : beside.substr(0, cut + 1)) + "amdhip64_7.dll"; + if (GetFileAttributesA(beside.c_str()) != INVALID_FILE_ATTRIBUTES && + _stricmp(beside.c_str(), path) != 0) + std::fprintf(stderr, "strata generate: WARNING: the HIP runtime in use is not the bundled one beside " + "the engine (%s): if prompts fail with hipErrorInvalidDeviceFunction, tell the " + "maintainers with this log (#1261)\n", + beside.c_str()); + } + } } #endif #else