Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Kernelium.Test/DeviceOperationsTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
using Kernelium.Enums;
using Kernelium.Execution;

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<InvalidOperationException>(() =>
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)
Expand Down
2 changes: 1 addition & 1 deletion Kernelium/Execution/DeviceOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Kernelium/Kernelium.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>true</IsPackable>
<PackageId>Kernelium</PackageId>
<Version>0.3.0</Version>
<Version>0.3.1</Version>
<Authors>Raphael Hinterdorfer</Authors>
<Description>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.</Description>
<PackageTags>gpu gpu-computing gpu-acceleration gpgpu csharp dotnet ilgpu cuda opencl parallel-computing</PackageTags>
Expand Down
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Loading