ParallelGpu 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ParallelGpu --version 0.1.0
                    
NuGet\Install-Package ParallelGpu -Version 0.1.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.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ParallelGpu" Version="0.1.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.1.0
                    
#r "nuget: ParallelGpu, 0.1.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.1.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.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ParallelGpu&version=0.1.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 for the selected device, transfers the data, and copies results back before the call returns.

The library targets .NET Standard 2.1 and uses ILGPU 1.5.3.

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(...) also provides a static API.

Backend selection

The default backend is Auto. It tries CUDA first, then OpenCL. CPU fallback is disabled by default; enable it explicitly when an application should also run without a compatible GPU:

using var gpu = new Gpu(new GpuOptions
{
    Backend = GpuBackend.Auto,
    AllowCpuFallback = true
});
Backend Requirements and behavior
Auto Tries available GPUs in CUDA-first order; CPU fallback requires AllowCpuFallback = true.
Cuda Requires an NVIDIA GPU and a compatible CUDA driver.
OpenCL Requires a compatible GPU and OpenCL runtime with OpenCL C 2.0 or newer and generic address-space support. An OpenCL 3.0 version label alone is insufficient.
Cpu Uses the ILGPU CPU accelerator for debugging and correctness checks.

Explicit Cuda and OpenCL selections never fall back to CPU. Use GpuOptions.DeviceIndex to select a device, and inspect gpu.Backend, gpu.DeviceName, and gpu.IsGpu after initialization.

Capabilities

  • Automatic transfers for arrays of any rank, jagged arrays, fixed-size lists, and supported memory views, with shared storage preserved.
  • Automatic value mappings for numeric types, bool, char, enums, supported structures, and nullable values.
  • Device buffers via Upload<T> and Allocate<T> to retain data between kernels.
  • Explicit value kernels through IGpuForKernel and IGpuForEachKernel<T>.
  • Reductions, atomic operations, and bounded append buffers for variable output.
  • Host collection adapters and explicit object-graph adapters for custom data models.

Execution requirements and limitations

The automatic lambda API requires runtime code generation (Reflection.Emit) and access to method IL. It is not supported in Native AOT applications.

Loop iterations are unordered. Use independent writes, atomics, or reductions to avoid races. Scalars captured by a lambda are read-only; collection elements may be writable, but collection sizes and array topology cannot change during execution.

Loop bodies and their helpers must be device-compatible. Arbitrary .NET methods, managed allocation, boxing, reflection, exception handlers, and checked integer arithmetic are unsupported. Automatic structure mappings cannot contain managed references, native pointers, or explicit layout. Direct device buffers and explicit value kernels require public unmanaged ILGPU-compatible types.

Automatic loops transfer captured collections on every call. For repeated operations, keep data in device buffers and download results when needed. Transfers and kernel compilation can outweigh the benefit of GPU execution for small or inexpensive workloads.

Calls on one Gpu instance are serialized. Avoid modifying transferred host collections concurrently, and dispose the executor and its buffers when finished. Floating-point reduction results may differ from sequential CPU results and between devices.

Documentation and examples

See the ParallelGpu repository for the full API guide, supported math operations, collection and object-graph examples, 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.
  • .NETStandard 2.1

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