Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for AI floats BF16, FP8E4M3, FP8E5M2 #1221

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
29 changes: 15 additions & 14 deletions Samples/BlazorSampleApp/MandelbrotExplorer/MandelbrotBasic.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU Samples
// Copyright (c) 2022 ILGPU Project
// Copyright (c) 2022-2024 ILGPU Project
// www.ilgpu.net
//
// File: MandelbrotBasic.cs
Expand All @@ -18,26 +18,27 @@
using ILGPU.Runtime;
using ILGPU.Runtime.CPU;
using ILGPU.Runtime.Cuda;
using ILGPU.Runtime.Velocity;


namespace BlazorSampleApp.MandelbrotExplorer
{
/// <summary>
/// This loads the scoped dependency injected instance of ILGPU per razor page which is similar coding to a command line application.
///
/// Blazor has difference levels of dependency injection, this should be scoped
///
/// Blazor has difference levels of dependency injection, this should be scoped
/// "services.AddScoped<ILGPU.BlazorSamples.MandelbrotExplorer.IMandelbrotBasic, ILGPU.BlazorSamples.MandelbrotExplorer.MandelbrotBasic>();"
/// in the Blazor server startup file.
/// </summary>

#nullable disable
public class MandelbrotBasic : IMandelbrotBasic, IDisposable
{
private Context _context = null;
private Accelerator _accelerator = null;
private System.Action<Index1D, ArrayView1D<int, Stride1D.Dense>, ArrayView1D<float, Stride1D.Dense>, int, ArrayView<int>> mandelbrot_kernel;


// If we are disposing do not start new processes
private bool _disposing = false;

Expand All @@ -49,10 +50,10 @@ public class MandelbrotBasic : IMandelbrotBasic, IDisposable
public bool IsDisposing { get { return _disposing; } }

public Context ContextInstance {
get
get
{
return _context;
}
}
}


Expand All @@ -66,7 +67,7 @@ public Accelerator AcceleratorInstance

public MandelbrotBasic()
{
_context = Context.CreateDefault();
_context = Context.Create(builder => builder.Default().Velocity());
_accelerator = null;
}

Expand All @@ -78,7 +79,7 @@ public MandelbrotBasic()
public void CompileKernel(Device device)
{
_accelerator?.Dispose();
_accelerator = device.CreateAccelerator(_context);
_accelerator = device.CreateAccelerator(_context);

mandelbrot_kernel = _accelerator.LoadAutoGroupedStreamKernel<
Index1D, ArrayView1D<int, Stride1D.Dense>, ArrayView1D<float, Stride1D.Dense>, int, ArrayView<int>>(MandelbrotExtensions.MandelbrotKernel);
Expand All @@ -105,7 +106,7 @@ private async Task<bool> ComputeFinished()
/// </summary>
public async void Dispose()
{

_disposing = true;

bool computeFinished = await ComputeFinished();
Expand All @@ -114,7 +115,7 @@ public async void Dispose()
mandelbrot_kernel = null;
_accelerator?.Dispose();
_context?.Dispose();

}

/// <summary>
Expand Down Expand Up @@ -219,7 +220,7 @@ public void CalcGPURepeat(ref int[] buffer, int[] dispayPort, float[] viewArea,
/// Clean up compute resources.
/// </summary>
public void CleanupGPURepeat()
{
{
_display?.Dispose();
_display = null;
_area?.Dispose();
Expand All @@ -229,9 +230,9 @@ public void CleanupGPURepeat()

}



}


}
Loading
Loading