Foundation.OpenCL.Extensions.Intel 1.0.2

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

Foundation.OpenCL ⚡

OpenCL binding for DotNet, idiomatic C#, zero cost abstraction.

NuGet License

Performance Density Matters - 100 kernel chain executes in 18ms

Foundation.OpenCL is a high-performance, modern OpenCL binding for .NET that combines the full power of OpenCL 3.0 with idiomatic C# design patterns. Built from the ground up for performance and reliability.

Foundation.OpenCL.Extensions.Intel

NuGet License

🚀 Why Foundation.OpenCL?

Zero-Cost Abstractions

Get type safety and modern C# features without performance penalties:

// Traditional bindings: clSetKernelArg(kernel, 0, sizeof(cl_mem), &buffer)
// Foundation: Type-safe, zero-overhead
kernel.SetArgBuffer(0, buffer);  // Compiles to optimal native calls

Idiomatic C#

Work with spans, generics, and events instead of raw pointers:

// Modern memory patterns
Span<float> data = stackalloc float[1024];
queue.EnqueueWriteBuffer(buffer, 0, data);

Proven Performance

// 100-kernel chain executes in 18ms
var events = new Event[100];
for (int i = 0; i < 100; i++)
{
    events[i] = queue.EnqueueNdRangeKernel(kernel, globalSize, localSize, 
                 i > 0 ? events[i-1] : default);
}

💡 Quick Start

Installation

dotnet add package Foundation.OpenCL

Your First OpenCL Program in 5 Minutes

using Foundation.OpenCL;

// 1. Discover platforms and devices
var platform = Platform.GetPlatforms()[0];
var device = platform.GetDevices(DeviceType.Gpu)[0];

// 2. Create context and command queue
using var context = platform.CreateContext(new[] { device });
using var queue = context.CreateCommandQueue(device);

// 3. Build kernel from source
string kernelSource = """
__kernel void vector_add(__global const float* a, 
                        __global const float* b, 
                        __global float* c) {
    int i = get_global_id(0);
    c[i] = a[i] + b[i];
}
""";

using var program = context.CreateWithSource(kernelSource);
program.Build(new[] { device });

// 4. Create and execute kernel
using var kernel = program.CreateKernel("vector_add");

// 5. Manage memory with type safety
using var aBuffer = context.CreateBuffer(MemFlags.ReadOnly, 1024 * sizeof(float));
using var bBuffer = context.CreateBuffer(MemFlags.ReadOnly, 1024 * sizeof(float)); 
using var cBuffer = context.CreateBuffer(MemFlags.WriteOnly, 1024 * sizeof(float));

// 6. Execute with proper event synchronization
var kernelEvent = queue.EnqueueNdRangeKernel(kernel, 
    globalSize: new[] { (nuint)1024 },
    localSize: new[] { (nuint)64 });

kernelEvent.Wait(); // Blocks until completion

🎯 Advanced Features

Intel USM Extensions

using Foundation.OpenCL.Extensions.Intel;

// Unified Shared Memory allocation
void* deviceMemory = context.AllocateDeviceMemory(device, 1024 * sizeof(float));

// Set kernel arguments directly from USM pointers
kernel.SetArgMemPointer(0, deviceMemory);

Multi-GPU Ready

var devices = Platform.GetPlatforms().SelectMany(p => p.GetDevices()).ToArray();
var contexts = devices.Select(d => Context.CreateContext(new[] { d })).ToArray();

// Distribute work across all available GPUs
Parallel.For(0, devices.Length, i =>
{
    var queue = contexts[i].CreateCommandQueue(devices[i]);
    queue.EnqueueNdRangeKernel(kernel, globalSize, localSize);
});

Sophisticated Event System

// Multicast event callbacks
var completionEvent = queue.EnqueueNdRangeKernel(kernel, globalSize, localSize);

completionEvent.OnComplete += () => Console.WriteLine("Kernel completed!");
completionEvent.OnRunning += () => Console.WriteLine("Kernel started execution!");

// Complex dependency chains
var eventA = queue.EnqueueKernel(kernelA, size);
var eventB = queue.EnqueueKernel(kernelB, size, waitFor: eventA); 
var eventC = queue.EnqueueKernel(kernelC, size, waitFor: new[] { eventA, eventB });

🏗️ Architecture Benefits

Type-Safe Handles

// Compile-time safety: no mixing of handle types
Handle<Context> contextHandle = context.Handle;
Handle<Device> deviceHandle = device.Handle;

// This won't compile - caught at build time!
// contextHandle = deviceHandle; // Error!

Resource Management

// Automatic reference counting and disposal
using var context = Context.CreateContext(devices);
using var queue = context.CreateCommandQueue(device);
using var buffer = context.CreateBuffer(MemFlags.ReadWrite, size);

// Proper cleanup even with complex object graphs

Performance Optimizations

  • Stack allocation for temporary buffers
  • Aggressive inlining of hot paths
  • Span-based APIs for zero-copy operations
  • Generic specialization for common types

📊 Performance Showcase

Kernel Chaining Benchmark

100 sequential 32x32 gemm kernels with event dependencies Typical result: 18ms on Intel Arc Pro B60

🛠 Installation

Package Manager

Install-Package Foundation.OpenCL
Install-Package Foundation.OpenCL.Extensions.Intel

.NET CLI

dotnet add package Foundation.OpenCL
dotnet add package Foundation.OpenCL.Extensions.Intel

Project Reference

<PackageReference Include="Foundation.OpenCL" Version="1.0.1" />
<PackageReference Include="Foundation.OpenCL.Extensions.Intel" Version="1.0.1" />

🔧 Requirements

  • .NET 9.0 or later
  • OpenCL 1.2+ compatible drivers, full support for OpenCL 3.0
  • Windows/Linux/macOS with GPU support

🤝 Collaboration

This project was developed through human-AI collaboration:

  • Project Lead & Architect: Samuel Alexandre Vidal
  • AI Collaborators:
    • DeepSeek (implementation, code review, technical expertise)
    • Qwen3-Next-80B-A3B (help with native API mapping)
    • Gemini 2.5 (initial concept collaboration)

The entire development process featured continuous collaboration between human expertise and multiple AI systems, each contributing unique strengths to create a production-quality library.

📄 License

MIT License - see LICENSE.txt for details.

🚀 Getting Involved


Ready to accelerate your GPU computing using idiomatic C#? Get started with Foundation.OpenCL today! ⚡

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.0.8 107 1/25/2026
1.0.7 108 1/25/2026
1.0.6 240 12/6/2025
1.0.2 194 11/22/2025
1.0.1 291 11/21/2025

First Release.