-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathP2PBackend.cs
More file actions
55 lines (48 loc) · 1.78 KB
/
Copy pathP2PBackend.cs
File metadata and controls
55 lines (48 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using ILGPU;
using ILGPU.Backends;
using ILGPU.Backends.EntryPoints;
using ILGPU.Runtime;
namespace SpawnDev.ILGPU.P2P;
/// <summary>
/// P2P backend — wraps kernel entry point metadata for serialization to remote peers.
/// Peers compile locally with their own backends. IR is the common language.
/// </summary>
public class P2PBackend : Backend
{
public P2PBackend(Context context)
: base(context, new P2PCapabilityContext(), BackendType.Wasm, new P2PArgumentMapper(context))
{
// BackendType.Wasm is a placeholder — P2P doesn't have its own type in the enum.
// We just need a valid Backend to satisfy the framework.
}
/// <inheritdoc/>
protected override CompiledKernel Compile(
EntryPoint entryPoint,
in BackendContext backendContext,
in KernelSpecialization specialization)
{
// P2P doesn't compile to a shader — it wraps the entry point
// for serialization to remote peers who compile locally.
return new P2PCompiledKernel(Context, entryPoint, null);
}
}
/// <summary>
/// Compiled kernel for P2P — holds entry point metadata for serialization.
/// </summary>
public class P2PCompiledKernel : CompiledKernel
{
public P2PCompiledKernel(Context context, EntryPoint entryPoint, KernelInfo? info)
: base(context, entryPoint, info)
{
}
}
/// <summary>
/// Argument mapper for P2P kernel parameters.
/// </summary>
public class P2PArgumentMapper : ArgumentMapper
{
public P2PArgumentMapper(Context context) : base(context) { }
protected override Type MapViewType(Type viewType, Type elementType) => viewType;
protected override void MapViewInstance<TILEmitter, TSource, TTarget>(
in TILEmitter emitter, Type viewType, in TSource source, in TTarget target) { }
}