ParallelGpu 0.7.0

dotnet add package ParallelGpu --version 0.7.0
                    
NuGet\Install-Package ParallelGpu -Version 0.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ParallelGpu" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ParallelGpu" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="ParallelGpu" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ParallelGpu --version 0.7.0
                    
#r "nuget: ParallelGpu, 0.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ParallelGpu@0.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ParallelGpu&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=ParallelGpu&version=0.7.0
                    
Install as a Cake Tool

ParallelGpu

Synchronous C# loops on CUDA or OpenCL, powered by ILGPU. Write a lambda over captured collections; the library compiles it, transfers the data, and copies results back before returning.

Installation

dotnet add package ParallelGpu

Quick start

using ParallelGpu;

using var gpu = new Gpu();
int[] input = { 1, 2, 3 };
int[] output = new int[input.Length];

gpu.For(0, input.Length, i => output[i] = input[i] * 2);
// output: 2, 4, 6

Reuse a Gpu instance to retain the accelerator and compiled kernels. GpuParallel.For(...) provides a static alternative.

Backend selection

Backend Requirements and behavior
Auto (default) Tries CUDA, then OpenCL. Set AllowCpuFallback = true in GpuOptions to allow CPU fallback.
Cuda Requires an NVIDIA GPU and a compatible CUDA driver.
OpenCL Requires a GPU runtime with OpenCL C 2.0 or newer and generic address spaces; an OpenCL 3.0 version label alone is insufficient.
Cpu Uses the ILGPU CPU accelerator for debugging and correctness checks.

Select a backend with new Gpu(new GpuOptions { Backend = GpuBackend.Cuda }). Explicit Cuda and OpenCL selections never fall back to CPU. gpu.Backend and gpu.DeviceName identify the selected device.

The test suite passes on CPU and CUDA. OpenCL has not been verified in the current test environment.

Capabilities

  • Arrays of any rank, jagged arrays, fixed-size list operations, and supported memory views, preserving shared storage.
  • Numeric types, bool, char, enums, supported value structures, and nullable values.
  • Persistent device buffers, explicit value kernels, reductions, atomics, and bounded append buffers.
  • Custom collection and object-graph adapters, plus supported .NET 8 Math/MathF operations.

Execution requirements and limitations

The automatic lambda API requires runtime code generation (Reflection.Emit) and access to method IL. Use an ordinary void Method(int) delegate; Native AOT and DynamicMethod delegates are unsupported.

Loop iterations are unordered. Use independent writes, atomics, or reductions to avoid races. Captured scalars are read-only snapshots. Collection elements may be writable, but sizes and references between arrays cannot change during a loop.

Loop bodies and their helpers must be device-compatible. Arbitrary .NET methods, managed allocation, boxing, reflection, exception handlers, and checked integer arithmetic are unsupported. Value structures must satisfy the supported type rules; device buffers and explicit kernels have stricter ILGPU type requirements.

Automatic loops transfer captured collections on every call. For repeated operations, keep data in device buffers. Transfers and compilation can outweigh GPU gains for small workloads.

GpuView<T> borrows device memory: keep its owner alive and use valid indices. Detected loop errors prevent automatic collection copyback, but device buffer writes and host callback effects are not rolled back.

Calls on one Gpu instance are serialized. Avoid concurrent host changes to transferred collections, and dispose the executor and its buffers when finished. Floating-point results may differ between devices; transcendental functions and reductions require suitable numerical tolerances.

Documentation and examples

See the API guide, supported math operations, and sample applications.

License

Licensed under MIT.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.7.0 41 10/14/2026
0.6.0 82 10/13/2026
0.5.0 85 10/12/2026
0.4.0 82 10/12/2026
0.3.0 86 10/12/2026
0.2.0 84 10/11/2026
0.1.0 81 10/10/2026