Skip to main content

Attributes & Annotations Reference

This reference documents all Hybridizer attributes used to control code generation and kernel behavior.

Core Attributes

[EntryPoint]

Marks a method as a GPU entry point (CUDA __global__).

[EntryPoint]
public static void MyKernel(float[] data, int N)
{
// ...
}
PropertyTypeDescription
NamestringOverride generated function name

[Kernel]

Marks a method as a device function (CUDA __device__).

[Kernel]
public static float Helper(float x)
{
return x * x;
}

Kernels are called from entry points or other kernels.

Template & Generics Attributes

[HybridTemplateConcept]

Marks an interface as a C++ template concept for performance.

[HybridTemplateConcept]
public interface IArray
{
float this[int i] { get; set; }
}

[HybridRegisterTemplate]

Registers a template specialization.

[HybridRegisterTemplate(Specialize = typeof(MyAlgorithm<MyArray>))]
public struct MyArray : IArray
{
// ...
}
PropertyTypeDescription
SpecializeTypeType to specialize for

Intrinsic Attributes

[IntrinsicConstant]

Maps a property to a backend constant.

public static class ThreadIdx
{
[IntrinsicConstant("threadIdx.x")]
public static int X { get; }
}

[IntrinsicFunction]

Maps a method to a backend function.

[IntrinsicFunction("__syncthreads")]
public static void SyncThreads() { }

[IntrinsicFunction("__expf")]
public static float FastExp(float x) => 0;

Memory Attributes

[SharedMemory]

Declares shared memory allocation.

[SharedMemory(typeof(float), 256)]
public static float[] SharedBuffer;

[ConstantMemory]

Declares constant memory (read-only, cached).

[ConstantMemory]
public static readonly float[] LookupTable;

Configuration Attributes

[HybridVectorWidth]

Specifies vector width for AVX backends.

[HybridVectorWidth(8)]  // AVX-256 for float
public class MyProcessor { }

[InlineHint]

Suggests inlining to the backend compiler.

[Kernel]
[InlineHint(InlinePolicy.Always)]
public static float FastOp(float x) => x * x;
ValueBehavior
AlwaysForce inline
NeverPrevent inline
DefaultCompiler decides

Assembly-Level Attributes

[HybridAssembly]

Configures assembly-wide settings.

[assembly: HybridAssembly(
GenerateLineInfo = true,
TargetFlavors = new[] { "CUDA", "AVX" }
)]

Attribute Summary Table

AttributeTargetPurpose
[EntryPoint]MethodMark as kernel entry
[Kernel]MethodMark as device function
[HybridTemplateConcept]InterfaceTemplate constraint
[HybridRegisterTemplate]Struct/ClassTemplate specialization
[IntrinsicConstant]PropertyMap to backend constant
[IntrinsicFunction]MethodMap to backend function
[SharedMemory]FieldShared memory allocation
[ConstantMemory]FieldConstant memory
[HybridVectorWidth]ClassVector width hint
[InlineHint]MethodInlining control

Unsupported Patterns

The following patterns are not supported with attributes:

PatternReason
async/awaitNo async on device
dynamicNo runtime dispatch
string operationsNo heap allocation
ref struct parametersMarshalling limitations

Next Steps