Class EnvVars
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
Central, typed accessor for every environment variable NumSharp reads. Each property RETURNS
THE VALUE (not the name), read through the shared Get(string) / GetBool(string, bool)
helpers, so null/blank handling, trimming and boolean parsing live in ONE place. Read-sites
use e.g. if (EnvVars.DebugGuardPages) or var lib = EnvVars.OpenBlasLibrary;
instead of repeating Environment.GetEnvironmentVariable(...) and its parsing.
public static class EnvVars
- Inheritance
-
EnvVars
- Inherited Members
Remarks
Grouped by area. NUMSHARP_* names are NumSharp's own; the discovery section reads
third-party conventions (conda / vcpkg / OpenBLAS / Python.NET) that NumSharp honours. The
build-time variables are normally consumed by MSBuild (the package's
buildTransitive props/targets), not by managed code; their accessors here simply read
whatever is in the current process environment, for completeness and diagnostics.
This type only READS. Setting/clearing a variable is done by NAME through
Environment.SetEnvironmentVariable (e.g. in tests) and is deliberately out of scope.
The retired, now-ignored spellings NUMSHARP_BLAS_BUNDLE_AUTOINSTALL /
NUMSHARP_BLAS_AUTOINSTALL have no accessor — they carry no value.
Properties
BenchNditerSection
Env NUMSHARP_BENCH_NDITER_SECTION: selects a single section of the nditer benchmark to run in its own process. Default: null → callers treat as "all" (run every section). Example: a section name printed by the benchmark's own index.
public static string BenchNditerSection { get; }
Property Value
CondaPrefix
External CONDA_PREFIX: an active conda prefix; its lib / Library\bin / Library\lib are scanned as ambient tooling (below the bundle). Default: null.
public static string CondaPrefix { get; }
Property Value
DebugGuardPages
Opt-in Windows page-heap diagnostic for the unmanaged buffer pool (env
NUMSHARP_DEBUG_GUARD_PAGES=1): every pooled buffer is handed back with its last byte
abutting an inaccessible guard page, so an out-of-bounds access faults INSTANTLY instead of
silently corrupting a neighbour. Default: false (Windows only — no effect
elsewhere).
public static bool DebugGuardPages { get; }
Property Value
NumSharpMultithreading
Whether NumSharp's own multithreaded kernels are enabled at startup — the source of truth
for MultiThread.Enabled / multithreading(bool, int), which override
it in-process. Env NUMSHARP_MULTITHREADING. Default: false (the managed
kernels stay single-threaded, so summation order is unchanged unless opted in).
public static bool NumSharpMultithreading { get; }
Property Value
NumSharpNumThreads
Startup thread cap for NumSharp's own kernels — seeds MultiThread.MaxThreads and the
NumSharp knob of TensorEngine.Threading as the source of truth. Env
NUMSHARP_NUM_THREADS. Default: null (unset → the built-in cap of 8).
public static int? NumSharpNumThreads { get; }
Property Value
- int?
OpenBlasBundleAutoinstall
Whether the module initializer auto-installs the bundled OpenBLAS on load. Env
NUMSHARP_OPENBLAS_BUNDLE_AUTOINSTALL. Default: true; set =0 to
skip it (bind later via OpenBlasEngine.Enable or a discovery variable above).
public static bool OpenBlasBundleAutoinstall { get; }
Property Value
OpenBlasCacheDir
Root of the per-user OpenBLAS cache. At RUNTIME (macOS only) it holds the relocated
copies of the bundled dylib + its vendored Fortran runtime that the loader makes when the
.dylibs folder cannot be materialized next to the dylib (read-only install, or a
RID-specific/single-file publish's flattened layout) — under dyld/<sha256>/;
at BUILD time it is the extracted-library cache of the version override (the
buildTransitive props read the same variable). Env NUMSHARP_OPENBLAS_CACHE_DIR.
Default: null → %LOCALAPPDATA% / $XDG_CACHE_HOME / ~/.cache
NumSharp/openblas, else the temp directory. Example:/var/cache/myapp/openblas.
public static string OpenBlasCacheDir { get; }
Property Value
OpenBlasCoreType
External OPENBLAS_CORETYPE: pins scipy-openblas' DYNAMIC_ARCH kernel (e.g.
Haswell). WARNING: the native library reads this through the CRT at load, and
.NET keeps its own env table — so THIS accessor may not reflect what the native lib saw.
Exposed for diagnostics; to actually pin the kernel, set it through the CRT before load.
public static string OpenBlasCoreType { get; }
Property Value
OpenBlasDelivery
Build-time: delivery mode — none, build, or package. Env NUMSHARP_OPENBLAS_DELIVERY. Default: null → build.
public static string OpenBlasDelivery { get; }
Property Value
OpenBlasDistribution
Build-time: distribution to fetch — 64 (ILP64) or 32 (LP64). Env NUMSHARP_OPENBLAS_DISTRIBUTION. Default: null → the per-RID default.
public static string OpenBlasDistribution { get; }
Property Value
OpenBlasHome
External OPENBLAS_HOME: an explicit OpenBLAS install root; its base, /lib and /bin are searched ABOVE the bundle (not byte-parity with NumPy). Default: null. Example: /opt/OpenBLAS.
public static string OpenBlasHome { get; }
Property Value
OpenBlasLibrary
Absolute path to ONE specific OpenBLAS/CBLAS shared library to bind — a parity pin: the
named binary is used exactly as given and is NEVER silently substituted, not even by the
bundled copy. Env NUMSHARP_OPENBLAS_LIBRARY. Default: null → normal
multi-tier discovery runs.
Value examples (a full path to the library FILE, not a directory):
- Windows:
C:\opt\openblas\scipy_openblas64.dll - Linux:
/usr/lib/x86_64-linux-gnu/libopenblas.so.0 - macOS:
/opt/homebrew/opt/openblas/lib/libopenblas.dylib
public static string OpenBlasLibrary { get; }
Property Value
OpenBlasPypiFeedUrl
Build-time: PyPI mirror base URL for the scipy-openblas wheel (needs a matching OpenBlasSha256). Env NUMSHARP_OPENBLAS_PYPI_FEED_URL. Default: null → the default PyPI feed. Example: https://pypi.org/simple.
public static string OpenBlasPypiFeedUrl { get; }
Property Value
OpenBlasRoot
External OPENBLAS_ROOT: alternate spelling of OpenBlasHome. Default: null.
public static string OpenBlasRoot { get; }
Property Value
OpenBlasSearchPath
Extra, highest-priority (but NON-binding) directories to search for an OpenBLAS library,
tried before the bundled asset; a match here carries no parity guarantee. Env
NUMSHARP_OPENBLAS_SEARCH_PATH. Default: null → no extra search dirs.
Value examples (a directory — or several joined by the platform path
separator: ; on Windows, : elsewhere): C:\opt\openblas\bin,
/opt/openblas/lib. Also read at BUILD time by the buildTransitive targets.
public static string OpenBlasSearchPath { get; }
Property Value
OpenBlasSha256
Build-time: expected sha256 of the extracted OpenBLAS library, verified after download. Env NUMSHARP_OPENBLAS_SHA256. Default: null → the checked-in manifest pin.
public static string OpenBlasSha256 { get; }
Property Value
OpenBlasUseBundled
Whether the bundled OpenBLAS asset participates in discovery as one tier. Env
NUMSHARP_OPENBLAS_USE_BUNDLED. Default: true (the bundle is included —
the parity default); set =0 to drop the bundled tier entirely. A toggle for the
bundled TIER, not a "use ONLY the bundle" switch.
public static bool OpenBlasUseBundled { get; }
Property Value
OpenBlasVersion
Build-time: scipy-openblas version to download and stage over the bundle (e.g. 0.3.31.22.0). Env NUMSHARP_OPENBLAS_VERSION, beats the <OpenBlasVersion> MSBuild property. Default: null → the pinned bundled version.
public static string OpenBlasVersion { get; }
Property Value
PoolGcPacing
Whether the unmanaged buffer pool may PACE the GC — request a forced gen-0 collection when
the pool is starving (a Take misses while enough bytes have been handed out since the last
paced collection). This is NumSharp's stand-in for CPython's refcount-prompt free: dropped,
undisposed result arrays return their native buffers only via finalizers, which run only
after a GC — without pacing a tight allocating loop starves the pool for thousands of calls
and pays a cold alloc + first-touch page faults per op. Env NUMSHARP_POOL_GC_PACING.
Default: true; set =0 to never trigger collections from the pool
(deterministic Dispose/NDScope workloads don't need pacing — they also never
starve, so pacing self-disables there anyway).
public static bool PoolGcPacing { get; }
Property Value
PoolGcPacingMB
The pool-pacing window in MiB — how many bytes the pool hands out between pool-initiated
gen-0 collections (and, equally, the per-bucket resident budget for pooled warm buffers).
Larger = fewer forced collections but a larger warm set and longer starvation bursts.
Env NUMSHARP_POOL_GC_PACING_MB. Default: 16 (clamped to 1..1024).
public static int PoolGcPacingMB { get; }
Property Value
PythonNetPyDll
External PYTHONNET_PYDLL: absolute path to the libpython shared library Python.NET should host. Default: null → the suite probes common interpreters for one that imports numpy. Example: /usr/lib/x86_64-linux-gnu/libpython3.12.so.
public static string PythonNetPyDll { get; }
Property Value
PythonnetRequireEngine
Whether an unavailable Python+numpy engine is a HARD test failure rather than an
Inconclusive skip. Env NUMSHARP_PYTHONNET_REQUIRE_ENGINE. Default: true
— the interop suite exists to exercise the engine, so an absent one means discovery is
broken and must go red, not green-by-skipping. Set =0 / false / no /
off from outside to allow a graceful skip on a machine without Python.
public static bool PythonnetRequireEngine { get; }
Property Value
SystemPath
External PATH: the process search path, swept dead-last for a CBLAS whose file name is not a bare loader name.
public static string SystemPath { get; }
Property Value
VcpkgRoot
External VCPKG_ROOT (Windows): a vcpkg root; its installed{triplet}\bin dirs are scanned as ambient tooling (below the bundle). Default: null.
public static string VcpkgRoot { get; }