Amplifier.NET 0.4.4

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package Amplifier.NET --version 0.4.4
NuGet\Install-Package Amplifier.NET -Version 0.4.4
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="Amplifier.NET" Version="0.4.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Amplifier.NET --version 0.4.4
#r "nuget: Amplifier.NET, 0.4.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Amplifier.NET as a Cake Addin
#addin nuget:?package=Amplifier.NET&version=0.4.4

// Install Amplifier.NET as a Cake Tool
#tool nuget:?package=Amplifier.NET&version=0.4.4

Amplifier.NET

Amplifier allows .NET developers to easily run complex applications with intensive mathematical computation on Intel CPU/GPU, NVIDIA, AMD without writing any additional C kernel code. Write your function in .NET and Amplifier will take care of running it on your favorite hardware.

Below is the sample Kernel you can write in CSharp

[OpenCLKernel]
void add_float([Global]float[] a, [Global] float[] b, [Global]float[] r)
{
    int i = get_global_id(0);
    b[i] = 0.5f * b[i];
    r[i] = a[i] + b[i];
}

[OpenCLKernel]
void Fill([Global] float[] x, float value)
{
    int i = get_global_id(0);

    x[i] = value;
}

Now this kernel will be converted to C99 format which is specific instruction for OpenCL. Let's do some magic to execute the kernel using OpenCL

  1. Create an instance of OpenCL compiler. You can list all the available devices.
var compiler = new OpenCLCompiler();
Console.WriteLine("\nList Devices----");
foreach (var item in compiler.Devices)
{
    Console.WriteLine(item);
}
  1. Select a device by id and load the Sample kernel created.
compiler.UseDevice(0);
compiler.CompileKernel(typeof(SimpleKernels));

Console.WriteLine("\nList Kernels----");
foreach (var item in compiler.Kernels)
{
    Console.WriteLine(item);
}
  1. Declare variable and do some operation which will run on any hardware selected like Intel CPU/GPU, NVIDIA, AMD etc.
Array a = new float[] { 1, 2, 3, 4 };
Array b = new float[4];
Array r = new float[4];

var exec = compiler.GetExec<float>();
exec.Fill(b, 0.5f);
exec.add_float(a, b, r);

Console.WriteLine("\nResult----");
for(int i = 0;i<r.Length;i++)
{
    Console.Write(r.GetValue(i) + " ");
}

Result:

Documentation

Any contribution is welcome

Please fork the code and suggest improvements by raising PR. Raise issues so that I can make this library robust.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Amplifier.NET:

Package Downloads
SuperchargedArray

An extended version of the Array to accelerate operation, easy to use, multi dimensional. With SuperchargedArray.Accelerated namespace you will unlock SIMD potential to run the Array operation on any hardware like Intel CPU/GPU, NVIDIA, AMD etc.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 197 8/15/2022
1.0.8 877 6/12/2020
0.5.0 1,106 12/30/2019
0.4.7 1,080 6/14/2019
0.4.6 446 6/13/2019
0.4.5 450 6/12/2019
0.4.4 422 6/11/2019
0.4.2 690 6/7/2019
0.4.0 568 6/7/2019