Skip to content

Commit

Permalink
Extended VelocityDevice to support 128bit vectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rs-mt committed May 3, 2024
1 parent 96f9aa5 commit ad922e1
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Src/ILGPU/Runtime/Velocity/VelocityDevice.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ---------------------------------------------------------------------------------------
// ILGPU
// Copyright (c) 2022-2023 ILGPU Project
// Copyright (c) 2022-2024 ILGPU Project
// www.ilgpu.net
//
// File: VelocityDevice.cs
Expand All @@ -11,6 +11,9 @@

using ILGPU.Backends.Velocity;
using ILGPU.Backends.Velocity.Scalar;
#if NET7_0_OR_GREATER
using ILGPU.Backends.Velocity.Vec128;
#endif
using ILGPU.Util;
using System;

Expand All @@ -25,6 +28,15 @@ public enum VelocityDeviceType
/// Scalar operations to simulate two lanes per warp.
/// </summary>
Scalar2,

#if NET7_0_OR_GREATER
/// <summary>
/// 128bit vector operations to simulate four lanes per warp using hardware
/// acceleration via AdvSimd and SSE/AVX.
/// </summary>
Vector128,

#endif
}

/// <summary>
Expand All @@ -38,7 +50,10 @@ public sealed class VelocityDevice : Device

private static readonly Type[] VelocitySpecializers = new Type[]
{
typeof(Scalar)
typeof(Scalar),
#if NET7_0_OR_GREATER
typeof(Vec128),
#endif
};

#endregion
Expand All @@ -56,6 +71,11 @@ public VelocityDevice(VelocityDeviceType deviceType)
case VelocityDeviceType.Scalar2:
// Scalar is always supported
break;
#if NET7_0_OR_GREATER
case VelocityDeviceType.Vector128:
// Vector always runs using software in the worst case
break;
#endif
default:
throw new ArgumentOutOfRangeException(nameof(deviceType));
}
Expand Down

0 comments on commit ad922e1

Please sign in to comment.