GPUSharp 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package GPUSharp --version 0.1.0
                    
NuGet\Install-Package GPUSharp -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="GPUSharp" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GPUSharp" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="GPUSharp" />
                    
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 GPUSharp --version 0.1.0
                    
#r "nuget: GPUSharp, 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 GPUSharp@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=GPUSharp&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GPUSharp&version=0.1.0
                    
Install as a Cake Tool

GPUSharp

Write GPU kernels in C# and run them on NVIDIA GPUs.

Mark a scalar method with [GpuKernel]. GPUSharp compiles that method and generates an array API next to it. The scalar method remains a normal .NET method. The generated companion runs the kernel over arrays.

public static class Calculator
{
    [GpuKernel]
    public static float Add(float a, float b)
    {
        return a + b;
    }
}

float[] result = CalculatorGpu.Add(a, b);

Install

GPUSharp targets .NET 10. Building a [GpuKernel] project requires Linux, cargo oxide 0.2.1, the CUDA toolkit, and LLVM 21. Running the kernel requires an NVIDIA GPU (Ampere, sm_80, or newer).

dotnet add package GPUSharp --version 0.1.0

The published package includes a Windows compiler frontend. That frontend cannot compile these kernels. Build them on Linux with cargo oxide on PATH.

Example

On a Linux machine with an NVIDIA GPU:

dotnet run --project samples/AddArrays

That runs Calculator.Add over two 5-element arrays and prints 11, 22, 33, 44, 55.

How it works

src/GPUSharp defines [GpuKernel]. src/GPUSharp.Generator finds marked methods at build time and emits the array companion. rust/gpusharp-compiler compiles each method into a cuda-oxide kernel and a host library that launches it.

Development

  • samples/AddArrays — console app that adds two arrays through CalculatorGpu.Add.
  • src/GPUSharp — .NET 10 package and [GpuKernel].
  • src/GPUSharp.Generator — Roslyn source generator for the array companion.
  • rust/gpusharp-compiler — kernel compiler. dll --out <so> <export-name> <method.cs> compiles one kernel with cargo oxide.

cargo test checks the emitted kernel. It does not need a GPU or the CUDA toolkit. dotnet build compiles the sample kernel and needs the Linux toolchain above. dotnet run launches it and needs a GPU.

From the repository root:

cargo test --manifest-path rust/gpusharp-compiler/Cargo.toml
cargo fmt --manifest-path rust/gpusharp-compiler/Cargo.toml --check
cargo clippy --manifest-path rust/gpusharp-compiler/Cargo.toml --all-targets -- -D warnings
dotnet build GPUSharp.slnx

cargo fmt and cargo clippy require the rustfmt and clippy components (rustup component add rustfmt clippy). GPUSHARP_CUDA_ARCH overrides the default sm_80 target.

License

GPUSharp is licensed under the Apache License 2.0.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

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.3.0 67 11/30/2026
0.2.0 77 11/12/2026
0.1.0 66 11/12/2026