Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deepakkumar1984/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.
https://github.com/deepakkumar1984/Amplifier.NET
compiler cuda-kernels gpgpu gpgpu-computing gpgpu-sim opencl opencl-kernels simd
Last synced: about 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/deepakkumar1984/Amplifier.NET
- Owner: deepakkumar1984
- License: mit
- Created: 2019-06-05T08:06:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T14:51:26.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T02:13:44.102Z (5 months ago)
- Topics: compiler, cuda-kernels, gpgpu, gpgpu-computing, gpgpu-sim, opencl, opencl-kernels, simd
- Language: C#
- Size: 3.65 MB
- Stars: 166
- Watchers: 14
- Forks: 21
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-csharp - Amplifier.NET - Write and compile your own kernel function using C# and Amplifier will take care of running it on your favorite hardware. 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. (Compilers, Transpilers and Languages)
- awesome-dotnet-machine-learning - Amplifier.NET
README
# 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
```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.
```csharp
var compiler = new OpenCLCompiler();
Console.WriteLine("\nList Devices----");
foreach (var item in compiler.Devices)
{
Console.WriteLine(item);
}
```2. Select a device by id and load the Sample kernel created.
```csharp
compiler.UseDevice(0);
compiler.CompileKernel(typeof(SimpleKernels));Console.WriteLine("\nList Kernels----");
foreach (var item in compiler.Kernels)
{
Console.WriteLine(item);
}
```3. Declare variable and do some operation which will run on any hardware selected like Intel CPU/GPU, NVIDIA, AMD etc.
```csharp
Array a = new float[] { 1, 2, 3, 4 };
Array b = new float[4];
Array r = new float[4];var exec = compiler.GetExec();
exec.Fill(b, 0.5f);
exec.add_float(a, b, r);Console.WriteLine("\nResult----");
for(int i = 0;i