Orleans.GpuBridge.Generators 0.3.0

dotnet add package Orleans.GpuBridge.Generators --version 0.3.0
                    
NuGet\Install-Package Orleans.GpuBridge.Generators -Version 0.3.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="Orleans.GpuBridge.Generators" Version="0.3.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Orleans.GpuBridge.Generators" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Orleans.GpuBridge.Generators">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 Orleans.GpuBridge.Generators --version 0.3.0
                    
#r "nuget: Orleans.GpuBridge.Generators, 0.3.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 Orleans.GpuBridge.Generators@0.3.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=Orleans.GpuBridge.Generators&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Orleans.GpuBridge.Generators&version=0.3.0
                    
Install as a Cake Tool

Orleans.GpuBridge.Generators

Roslyn source generators for GPU-native actor code generation in Orleans GPU Bridge.

Overview

Orleans.GpuBridge.Generators provides compile-time code generation for GPU-native actors. It automatically generates message structs, kernel implementations, and grain wrappers from annotated interfaces, enabling seamless GPU acceleration with minimal boilerplate.

Key Features

  • Automatic Message Struct Generation: Generates GPU-friendly message structures
  • Kernel Code Generation: Creates CUDA/OpenCL kernel boilerplate
  • Grain Implementation Generation: Generates Orleans grain implementations
  • Compile-Time Validation: Catches configuration errors during build
  • Message Size Calculation: Automatic sizing for GPU memory allocation

Installation

dotnet add package Orleans.GpuBridge.Generators

Quick Start

Define a GPU-Native Actor Interface

using Orleans.GpuBridge.Abstractions;

[GpuNativeActor]
public interface IVectorMathActor : IGrainWithIntegerKey
{
    [GpuOperation]
    Task<float[]> AddAsync(float[] a, float[] b);

    [GpuOperation]
    Task<float> DotProductAsync(float[] a, float[] b);
}

Generated Code

The generator automatically produces:

  1. Message Struct (VectorMathActorMessages.g.cs)
[StructLayout(LayoutKind.Sequential)]
public struct AddMessage
{
    public int ALength;
    public int BLength;
    // ... GPU-aligned data layout
}
  1. Kernel Boilerplate (VectorMathActorKernels.g.cs)
public static class VectorMathActorKernels
{
    public static readonly string AddKernel = @"
        __global__ void Add(AddMessage* msg, float* result) {
            // ... generated kernel code
        }
    ";
}
  1. Grain Implementation (VectorMathActorGrain.g.cs)
public partial class VectorMathActorGrain : Grain, IVectorMathActor
{
    public async Task<float[]> AddAsync(float[] a, float[] b)
    {
        // ... generated GPU dispatch code
    }
}

Attributes

[GpuNativeActor]

Marks an interface for GPU-native actor generation.

[GpuNativeActor(
    QueueCapacity = 1024,
    UsePersistentKernel = true)]
public interface IMyActor : IGrainWithIntegerKey
{
    // ...
}

[GpuOperation]

Marks a method for GPU execution.

[GpuOperation(
    KernelName = "CustomKernel",
    SharedMemorySize = 4096)]
Task<TResult> MethodAsync(TInput input);

Analyzers and Diagnostics

The generator includes analyzers that report issues during compilation:

ID Severity Description
GPUGEN001 Error Invalid return type for GPU operation
GPUGEN002 Error Unsupported parameter type
GPUGEN003 Warning Message size exceeds recommended limit
GPUGEN004 Warning Operation missing async suffix

Architecture

Analysis Pipeline

  1. ActorInterfaceAnalyzer: Scans for [GpuNativeActor] interfaces
  2. MessageSizeCalculator: Computes GPU-aligned message sizes
  3. GpuNativeActorGenerator: Orchestrates code generation

Code Builders

  • MessageStructBuilder: Generates GPU-friendly data structures
  • KernelCodeBuilder: Creates CUDA/OpenCL kernel templates
  • GrainImplementationBuilder: Produces Orleans grain implementations

Configuration

MSBuild Properties

<PropertyGroup>
  
  <GpuBridge_GenerateMessages>true</GpuBridge_GenerateMessages>
  <GpuBridge_GenerateKernels>true</GpuBridge_GenerateKernels>
  <GpuBridge_GenerateGrains>true</GpuBridge_GenerateGrains>

  
  <GpuBridge_DiagnosticSeverity>Warning</GpuBridge_DiagnosticSeverity>
</PropertyGroup>

Dependencies

  • Microsoft.CodeAnalysis.CSharp (>= 4.5.0)
  • Microsoft.CodeAnalysis.Common (>= 4.5.0)

Requirements

  • .NET Standard 2.0 (for analyzer compatibility)
  • C# 10.0+ source code

Troubleshooting

Generated code not appearing

  1. Ensure the package is referenced correctly
  2. Check for analyzer errors in the Error List
  3. Rebuild the solution

Compilation errors in generated code

  1. Verify interface methods have supported parameter types
  2. Check that all GPU operations return Task<T>
  3. Review diagnostic warnings

License

MIT License - Copyright (c) 2025 Michael Ivertowski


For more information, see the Orleans.GpuBridge.Core Documentation.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.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 202 2/9/2026
0.2.1 477 12/8/2025
0.2.0 220 12/5/2025
0.1.0 375 11/30/2025