ParallelGpu 0.7.0
dotnet add package ParallelGpu --version 0.7.0
NuGet\Install-Package ParallelGpu -Version 0.7.0
<PackageReference Include="ParallelGpu" Version="0.7.0" />
<PackageVersion Include="ParallelGpu" Version="0.7.0" />
<PackageReference Include="ParallelGpu" />
paket add ParallelGpu --version 0.7.0
#r "nuget: ParallelGpu, 0.7.0"
#:package ParallelGpu@0.7.0
#addin nuget:?package=ParallelGpu&version=0.7.0
#tool nuget:?package=ParallelGpu&version=0.7.0
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/MathFoperations.
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 | Versions 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. |
-
.NETStandard 2.1
- ILGPU (>= 1.5.3)
- ILGPU.Algorithms (>= 1.5.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.