• Stars
    star
    171
  • Rank 221,245 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

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.

More Repositories

1

MxNet.Sharp

.NET Standard bindings for Apache MxNet with Imperative, Symbolic and Gluon Interface for developing, training and deploying Machine Learning models in C#. https://mxnet.tech-quantum.com/
C#
148
star
2

sia-cog

Various cognitive api for machine learning, vision, language intent alalysis. Covers traditional as well as deep learning model design and training.
Python
34
star
3

XrmToolBoxPlugins

Tools for Dynamics CRM
C#
33
star
4

ASP.NET-Core-with-Vue-JS

ASP.NET Core with Vue JS
C#
6
star
5

SuperchargedArray

A super accelerated array extension for C# supported to run on multiple hardware: CPU, GPU (NVIDIA, AMD, Intel) to achieve accelerated speed
C#
5
star
6

QuickGraph.NETStandard

QuickGraph provides generic directed/undirected graph datastructures and algorithms for .Net
C#
5
star
7

OpenBLAS.NET

OpenBLAS is an open source implementation of the BLAS (Basic Linear Algebra Subprograms) API with many hand-crafted optimizations for specific processor types.
C#
3
star
8

Route-Planner-API

Route Planner API to solve travelling saleperson problem
C#
3
star
9

AmadeusSdk

Amadeus SDK for C# .NET
C#
2
star
10

Image-Resizer

A tool to recreate image of various sizes
C#
2
star
11

Arithmetica

This is a simple library to build and simulate your own quantum computing algorithms in C#, yes in C#.
C#
2
star
12

XtlSharp

xTensor.NET is a C# binding for xtensor library meant for numerical analysis with multi-dimensional array expressions.
C++
2
star
13

Math-Expression-Generator

Build random math expression for creating sample exam papers
JavaScript
1
star
14

RL.NET

A toolkit for developing and comparing reinforcement learning algorithms.
C#
1
star
15

Armadillo.NET

CSharp binding of Armadillo (C++ library for linear algebra & scientific computing)
C#
1
star
16

Design-Patterns

C#
1
star