From 337fcede53817cccf02d5168b2609eb0a3abc5e3 Mon Sep 17 00:00:00 2001 From: sepp4122 Date: Sat, 28 Nov 2026 22:32:35 +0100 Subject: [PATCH] Prepare Kernelium 0.3.1 release --- Kernelium.Test/DeviceOperationsTests.cs | 17 +++++++++++++++++ Kernelium/Execution/DeviceOperations.cs | 2 +- Kernelium/Kernelium.csproj | 2 +- README.md | 20 +++++++++----------- llms.txt | 4 ++-- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/Kernelium.Test/DeviceOperationsTests.cs b/Kernelium.Test/DeviceOperationsTests.cs index 0a545fb..aebe2d0 100644 --- a/Kernelium.Test/DeviceOperationsTests.cs +++ b/Kernelium.Test/DeviceOperationsTests.cs @@ -1,3 +1,4 @@ +using Kernelium.Enums; using Kernelium.Execution; namespace Kernelium.Test; @@ -5,6 +6,22 @@ namespace Kernelium.Test; [TestFixture] internal static class DeviceOperationsTests { + [Test] + public static void AsyncCpuWorkRejectsAnUnsafeDefaultStream() + { + using var gpu = new GPU(new() { HardwareType = HardwareType.Cpu }); + var operations = new DeviceOperations(gpu.Accelerator); + var defaultStream = operations.GetClaims(useDefaultStream: true).TakeAccess() + .Single(claim => claim.Value).Key; + defaultStream.UnsafeToUse = true; + + var error = Assert.ThrowsAsync(() => + operations.RunAsync(operations.GetClaims(useDefaultStream: false), [], + _ => Assert.Fail("Work reached an unsafe stream."))); + + Assert.That(error!.Message, Does.Contain("could not establish stream completion")); + } + [TestCase(true)] [TestCase(false)] public static void FailedFinalDrainPreservesRetainedWork(bool hasRetainedWork) diff --git a/Kernelium/Execution/DeviceOperations.cs b/Kernelium/Execution/DeviceOperations.cs index d8cb507..1aa9aa0 100644 --- a/Kernelium/Execution/DeviceOperations.cs +++ b/Kernelium/Execution/DeviceOperations.cs @@ -39,7 +39,7 @@ internal OperationScheduler.Claims GetClaims(bool useDefaultStream) { var claims = new OperationScheduler.Claims(); claims.Add(Lifetime, write: false); - if (useDefaultStream) + if (useDefaultStream || isCpu) claims.Add(defaultStream, write: true); return claims; } diff --git a/Kernelium/Kernelium.csproj b/Kernelium/Kernelium.csproj index 4534fcd..62105ba 100644 --- a/Kernelium/Kernelium.csproj +++ b/Kernelium/Kernelium.csproj @@ -7,7 +7,7 @@ true true Kernelium - 0.3.0 + 0.3.1 Raphael Hinterdorfer GPU computing for C# and .NET 10. Compile and launch ILGPU kernels on CUDA, OpenCL, or CPU with automatic array transfers and reusable device buffers. gpu gpu-computing gpu-acceleration gpgpu csharp dotnet ilgpu cuda opencl parallel-computing diff --git a/README.md b/README.md index 717e9d5..d09872c 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ Kernelium is MIT licensed and targets .NET 10. ## Install -This README documents Kernelium 0.3.0. Install the package from NuGet: +This README documents Kernelium 0.3.1. Install the package from NuGet: ```sh -dotnet add package Kernelium --version 0.3.0 +dotnet add package Kernelium --version 0.3.1 ``` To build against the checkout, add a project reference to `Kernelium/Kernelium.csproj`. @@ -80,15 +80,8 @@ At 4096², Kernelium CUDA completed Mandelbrot in 12.11 ms versus 333.79 ms for native-threaded C#. For 4096² vector addition split into two batches, CUDA async submission averaged 11.44 ms versus 14.43 ms for serial submission. The CUDA timings include output downloads. The run covered CUDA and CPU. -[Full benchmark results](benchmarks/results/2026-11-28.md) - -The workspace project at `examples/Kernelium.Benchmarks` compares two serial -launches, two async launches submitted together, and two async launches -submitted from dedicated host threads. Run `dotnet run -c Release -- --filter "*Batches"` -from that project directory for timings that include downloads. Use -`--gpu-only` for the CUDA and GPU-backed OpenCL suite and -`--cuda-async-throughput` to compare CUDA serial and async launches with data -kept on the device. +The benchmark harness was run from a separate local workspace. +[Full benchmark results](https://github.com/Hinterdorfer-Raphael/Kernelium/blob/main/benchmarks/results/2026-11-28.md) ## API Documentation @@ -264,6 +257,11 @@ CUDA and OpenCL have two async streams per GPU and can overlap independent workl when the device and driver support it. Overlap depends on the resources each kernel uses. ILGPU runs one kernel at a time per CPU accelerator. +On CUDA, each active stream can cache up to 128 MiB of pinned host staging +memory on demand. The default stream and two async streams can cache up to +384 MiB per GPU instance in total, with additional temporary staging possible +when a transfer exceeds the available cache budget. + ### Launch a 2D workload Call `Execute2D(width, height, ...)` to let Kernelium choose a group shape diff --git a/llms.txt b/llms.txt index bfdf5c3..d3acc9b 100644 --- a/llms.txt +++ b/llms.txt @@ -4,7 +4,7 @@ ## Install and check the version -- This file documents Kernelium 0.3.0. Install it with `dotnet add package Kernelium --version 0.3.0`. To build against the checkout, add a project reference to `Kernelium/Kernelium.csproj`. +- This file documents Kernelium 0.3.1. Install it with `dotnet add package Kernelium --version 0.3.1`. To build against the checkout, add a project reference to `Kernelium/Kernelium.csproj`. ## Quickstart @@ -73,7 +73,7 @@ await Task.WhenAll( ## Benchmarks -- The workspace project at `examples/Kernelium.Benchmarks` measures serial, async, and dedicated-thread async submission of two batches with the same readbacks. From the project directory, run `dotnet run -c Release -- --filter "*Batches"`. Use `--gpu-only` for the CUDA and GPU-backed OpenCL suite, or `--cuda-async-throughput` to compare CUDA serial and async execution with device-resident data. The November 28 release report covers 72 cases, including CPU and CUDA batch submission with output readback and synchronous comparisons against native C# and raw ILGPU. OpenCL was outside the scope of this run. [Benchmark results](https://github.com/Hinterdorfer-Raphael/Kernelium/blob/main/benchmarks/results/2026-11-28.md) +- The November 28 report covers 72 cases, including serial and async CPU and CUDA batch submission with output readback and synchronous comparisons against native C# and raw ILGPU. The benchmark harness was run from a separate local workspace. OpenCL was outside the scope of this run. [Benchmark results](https://github.com/Hinterdorfer-Raphael/Kernelium/blob/main/benchmarks/results/2026-11-28.md) ## Documentation