Files
Niko1221 1d295787b3 engine: WIN32_LEAN_AND_MEAN before every <windows.h> include that does not define it (a Windows CUDA build blocker: small is #define small char from rpcndr.h)
engine/src/program/generate.cpp has `const int64_t small = old_rule();` (and two more). Without WIN32_LEAN_AND_MEAN, <windows.h> pulls in <rpc.h> / <rpcndr.h>, which
define `small`. In 0.2.15 the first <windows.h> of that translation unit came through gguf_reader.hpp, which defines the lean macro; now conversation_spill.hpp (line 38)
and platform/commit.hpp (line 18) reach it first and define only NOMINMAX. Each include below now gets, next to NOMINMAX, the guarded
`#ifndef WIN32_LEAN_AND_MEAN / #define WIN32_LEAN_AND_MEAN / #endif` (inside the same `#if defined(_WIN32)` block, so a Linux build never sees it): include/strata/core/
conversation_spill.hpp, include/strata/platform/commit.hpp; src/core/{conversation_memory, conversation_memory_test, device_main, pinned.cu, pinned_alias_test,
pinned_shared_win_test, verify}; src/program/generate.cpp; sycl/include/{dpct/device, dpct/kernel, dpct/memory, strata/runtime_files}.hpp, sycl/src/core/{copy_queue, pinned.dp}.cpp,
sycl/src/program/generate.cpp; tests/platform/io_priority_test.cpp (18 includes; the other 25 sites already define it earlier in their file). None of these files uses an API the
lean macro leaves out (winsock, shell, RPC / OLE, multimedia): checked by grep. Not covered: the SYCL Windows build also takes dpct/bindless_images.hpp (d3d11.h, which
reaches rpcndr.h by itself), and sycl/src/program/generate.cpp has the same `small` name; no Windows SYCL package is built in 0.2.16 (the release assets are Linux SYCL).
2026-11-17 17:40:25 +01:00

47 lines
2.1 KiB
C++

// io_priority_test (#4733): on Windows a process that starts at Low I/O priority is put back to Normal; elsewhere the call does nothing.
#include "strata/platform/io_priority.hpp"
#include <cstdio>
#include <cstdlib>
#if defined(_WIN32)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
static unsigned long io_prio() {
using Query = LONG(NTAPI*)(HANDLE, ULONG, PVOID, ULONG, PULONG);
auto q = reinterpret_cast<Query>(reinterpret_cast<void*>(GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "NtQueryInformationProcess")));
ULONG v = 99, r = 0;
return q != nullptr && q(GetCurrentProcess(), 33, &v, sizeof v, &r) == 0 ? v : 99;
}
static bool set_io_prio(ULONG v) {
using Set = LONG(NTAPI*)(HANDLE, ULONG, PVOID, ULONG);
auto s = reinterpret_cast<Set>(reinterpret_cast<void*>(GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "NtSetInformationProcess")));
return s != nullptr && s(GetCurrentProcess(), 33, &v, sizeof v) == 0;
}
#endif
int main() {
#if defined(_WIN32)
int bad = 0;
// 1. started at Low: back to Normal, and the call reports what it found
if (!set_io_prio(1)) { std::printf("io_priority_test: SKIP (cannot lower the I/O priority here)\n"); return 77; }
int was = strata::platform::restore_normal_io_priority(stderr);
if (was != 1 || io_prio() != 2) { std::printf("FAIL lowered: was=%d now=%lu\n", was, io_prio()); ++bad; }
// 2. already Normal: untouched, reported as 2
was = strata::platform::restore_normal_io_priority(nullptr);
if (was != 2 || io_prio() != 2) { std::printf("FAIL normal: was=%d now=%lu\n", was, io_prio()); ++bad; }
// 3. STRATA_KEEP_IO_PRIORITY=1 leaves a low value alone
_putenv("STRATA_KEEP_IO_PRIORITY=1");
set_io_prio(1);
was = strata::platform::restore_normal_io_priority(nullptr);
if (was != -1 || io_prio() != 1) { std::printf("FAIL keep: was=%d now=%lu\n", was, io_prio()); ++bad; }
std::printf(bad == 0 ? "io_priority_test: OK\n" : "io_priority_test: %d FAILED\n", bad);
return bad == 0 ? 0 : 1;
#else
std::printf("io_priority_test: SKIP (Windows only)\n");
return 77;
#endif
}