Inference engine, OpenAI/Anthropic API on localhost, optional image input, one-file setup (START-HERE.bat / setup.sh). Model files are downloaded from Hugging Face by the setup.
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
// src/platform/memory_test.cpp - plan v0.3 P0.1: lock_resident on a 256 MiB region (CPU only, no GPU, no model).
|
|
#include "strata/platform/memory.hpp"
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
|
|
#if defined(_WIN32)
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#define NOMINMAX
|
|
#include <windows.h>
|
|
#include <psapi.h>
|
|
#pragma comment(lib, "psapi.lib")
|
|
#endif
|
|
|
|
int main() {
|
|
const uint64_t bytes = 256ull << 20;
|
|
void* p = std::malloc(bytes);
|
|
if (p == nullptr) return 2;
|
|
std::memset(p, 1, bytes);
|
|
const strata::platform::LockResult r = strata::platform::lock_resident(p, bytes);
|
|
std::printf("lock_resident: ok=%d locked=%llu MiB (%s)\n", (int) r.ok, (unsigned long long) (r.locked_bytes >> 20),
|
|
r.note.c_str());
|
|
int fail = !(r.ok && r.locked_bytes == bytes);
|
|
#if defined(_WIN32)
|
|
PROCESS_MEMORY_COUNTERS pmc{};
|
|
GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof pmc);
|
|
std::printf("working set %llu MiB\n", (unsigned long long) (pmc.WorkingSetSize >> 20));
|
|
fail |= pmc.WorkingSetSize < bytes;
|
|
#endif
|
|
strata::platform::unlock_resident(p, bytes);
|
|
std::free(p);
|
|
std::printf("platform_memory_test: %s\n", fail ? "FAILED" : "OK");
|
|
return fail;
|
|
}
|