Supprocom.CSharp2CUDA 0.3.2

dotnet add package Supprocom.CSharp2CUDA --version 0.3.2
                    
NuGet\Install-Package Supprocom.CSharp2CUDA -Version 0.3.2
                    
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="Supprocom.CSharp2CUDA" Version="0.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Supprocom.CSharp2CUDA" Version="0.3.2" />
                    
Directory.Packages.props
<PackageReference Include="Supprocom.CSharp2CUDA" />
                    
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 Supprocom.CSharp2CUDA --version 0.3.2
                    
#r "nuget: Supprocom.CSharp2CUDA, 0.3.2"
                    
#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 Supprocom.CSharp2CUDA@0.3.2
                    
#: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=Supprocom.CSharp2CUDA&version=0.3.2
                    
Install as a Cake Addin
#tool nuget:?package=Supprocom.CSharp2CUDA&version=0.3.2
                    
Install as a Cake Tool

CSharp2CUDA

Regular C# static methods can become CUDA code. CSharp2CUDA lets you reuse existing numerical algorithms and translate the sections that benefit from GPU acceleration without first rewriting those algorithms in CUDA or requiring a C# developer to learn CUDA syntax.

CSharp2CUDA is intentionally selective. It is useful for moving bounded, value-oriented parts of a C# program onto a GPU; it is not intended to become the default way to maintain a large application or to reproduce the managed .NET runtime on a device.

Translate an existing algorithm

Keep the reusable algorithm as ordinary C#. A small adapter supplies the CUDA entry point and its pointer-based launch boundary.

using System;
using Supprocom.CSharp2CUDA;

internal static class ExistingAlgorithm
{
    public static float Apply(float value, float scale)
    {
        float positive = MathF.Max(value, 0.0f);
        return positive * scale;
    }
}

[TranspileToCUDA]
internal static unsafe class ApplyOnGpu
{
    [CudaGlobal(Name = "apply_values")]
    private static void Kernel(float* input, float* output, int count, float scale)
    {
        int index = Cuda.BlockIdx.X * Cuda.BlockDim.X + Cuda.ThreadIdx.X;
        if (index < count)
            output[index] = ExistingAlgorithm.Apply(input[index], scale);
    }
}

Roslyn checks both methods as C#. CSharp2CUDA follows the call from Kernel, emits ExistingAlgorithm.Apply as a CUDA device helper, and emits Kernel as the apply_values global function. The CPU version remains directly callable from ordinary managed code.

Add the package

<PropertyGroup>
  <TargetFramework>net10.0</TargetFramework>
  <LangVersion>14.0</LangVersion>
  <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Supprocom.CSharp2CUDA" Version="0.3.2" />
</ItemGroup>

Build normally with dotnet build. A marked class keeps the managed assembly and adds a .cu output; a dedicated transpilation project can instead set <TranspileToCUDA>true</TranspileToCUDA>.

The package emits CUDA C++ source. Your application still chooses a CUDA toolchain, owns device memory, and launches kernels.

Where to go next

  • Getting started explains project selection, generated files, diagnostics, and manual Roslyn APIs.
  • Portable C# profile lists supported C# features, restrictions, traps, lifetime rules, and examples.
  • CUDA interop covers intrinsics, shared and constant storage, ABI rules, and external CUDA linkage.
  • Tool package explains when to use Supprocom.CSharp2CUDA.Tool instead of the build-integrated package.
  • Contributing covers repository builds and tests.

CSharp2CUDA fails closed: when a construct cannot be translated with the required C# semantics, it reports a diagnostic and returns no partial CUDA source.

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.

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.2 95 9/28/2026
0.3.1 310 9/20/2026
0.3.0 96 9/20/2026
0.2.1 539 8/12/2026
0.2.0 114 8/11/2026
0.1.3 127 8/12/2026
0.1.2 114 8/11/2026
0.1.1 120 8/11/2026
0.1.0 115 8/9/2026

Clean up analyzer findings and establish warning-free compiler, package, and test builds. No new CUDA language features.