Enum KernelLanguage
- Namespace
- Orleans.GpuBridge.Abstractions.Enums.Compilation
- Assembly
- Orleans.GpuBridge.Abstractions.dll
Defines the supported source languages for GPU kernel compilation.
public enum KernelLanguage
Fields
CSharp = 0C# source code compiled to GPU kernels.
Represents C# code that is transpiled or compiled to GPU-executable code. This allows .NET developers to write GPU kernels using familiar C# syntax and constructs, with automatic translation to the target GPU language.
Advantages: - Familiar syntax for .NET developers - Type safety and IntelliSense support - Integration with .NET tooling and debugging - Automatic memory management translation
Limitations: - Not all C# constructs are supported on GPU - May have performance overhead from translation - Limited to subset of .NET API surface
CUDA = 1CUDA C/C++ source code for NVIDIA GPUs.
CUDA (Compute Unified Device Architecture) is NVIDIA's parallel computing platform and programming model. CUDA kernels are written in an extended C/C++ language with special syntax for GPU programming.
Advantages: - Native performance on NVIDIA GPUs - Extensive optimization support - Rich ecosystem of libraries and tools - Fine-grained control over GPU resources
Limitations: - NVIDIA GPU exclusive - Requires CUDA SDK and compatible drivers - Platform-specific code
HLSL = 3HLSL (High-Level Shading Language) source code.
HLSL is Microsoft's shading language used primarily for graphics programming but increasingly used for general-purpose compute shaders. Commonly used with DirectX and D3D12 compute pipelines.
Advantages: - Well-integrated with DirectX ecosystem - Good tooling support in Visual Studio - Suitable for graphics and compute workloads - Strong Windows platform integration
Limitations: - Primarily Windows/DirectX focused - Limited cross-platform support - Graphics-oriented language design
MSL = 4MSL (Metal Shading Language) source code for Apple platforms.
MSL is Apple's shading language used for GPU programming on iOS, macOS, and other Apple platforms. Based on C++14 with GPU-specific extensions and optimizations.
Advantages: - Optimized for Apple hardware (M-series, A-series chips) - Excellent integration with Apple development tools - High performance on Apple platforms - Modern C++-based syntax
Limitations: - Apple platforms exclusive - Limited cross-platform portability - Requires Metal framework support
OpenCL = 2OpenCL C source code for cross-platform GPU computing.
OpenCL (Open Computing Language) is an open standard for parallel computing across heterogeneous platforms including CPUs, GPUs, and other accelerators. OpenCL C is based on C99 with extensions for parallel programming.
Advantages: - Cross-platform compatibility (NVIDIA, AMD, Intel) - Industry standard with broad support - Works on CPUs and other accelerators - Portable across vendors
Limitations: - More verbose than vendor-specific solutions - May not expose all hardware-specific features - Can have performance variations across implementations
PTX = 6PTX (Parallel Thread Execution) assembly code for NVIDIA GPUs.
PTX is NVIDIA's low-level parallel thread execution instruction set architecture. It serves as a portable assembly language that is compiled to native GPU code at runtime or installation time.
Advantages: - Low-level control over GPU execution - Portable across NVIDIA GPU generations - Enables hand-optimized critical code paths - Direct access to hardware features
Limitations: - NVIDIA GPU exclusive - Assembly-level programming complexity - Requires deep GPU architecture knowledge - Platform-specific instruction set
SPIRV = 5SPIR-V (Standard Portable Intermediate Representation) bytecode.
SPIR-V is a binary intermediate language for graphics and compute kernels. It serves as a portable compilation target that can be consumed by various GPU drivers and runtimes.
Advantages: - Vendor-neutral intermediate representation - Portable across different GPU APIs (Vulkan, OpenCL) - Enables offline compilation and caching - Compact binary format
Limitations: - Binary format, not human-readable - Requires specialized tools for generation/inspection - Abstraction may limit access to vendor-specific features
Remarks
This enumeration represents the various programming languages and intermediate representations that can be compiled into GPU kernels. Different GPU backends may support different subsets of these languages.
The availability of specific languages depends on: - The GPU backend implementation (CUDA, OpenCL, etc.) - Runtime environment capabilities - Driver and compiler toolchain support
When selecting a kernel language, consider: - Target GPU architecture compatibility - Performance characteristics and optimization support - Development tools and debugging capabilities - Portability requirements across different GPU vendors