From bdb1a039b5f6944e899cbb3433a9d303012a4ae0 Mon Sep 17 00:00:00 2001 From: Marcel Koester Date: Thu, 26 Jan 2023 20:48:41 +0100 Subject: [PATCH] Refined peer-access implementation of CPUAccelerator. --- Src/ILGPU/Runtime/CPU/CPUAccelerator.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Src/ILGPU/Runtime/CPU/CPUAccelerator.cs b/Src/ILGPU/Runtime/CPU/CPUAccelerator.cs index 62d75ba2ea..c54d57b4a1 100644 --- a/Src/ILGPU/Runtime/CPU/CPUAccelerator.cs +++ b/Src/ILGPU/Runtime/CPU/CPUAccelerator.cs @@ -12,6 +12,7 @@ using ILGPU.Backends; using ILGPU.Backends.IL; using ILGPU.Resources; +using ILGPU.Runtime.Velocity; using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; @@ -250,12 +251,13 @@ protected override void OnUnbind() { } /// protected override bool CanAccessPeerInternal(Accelerator otherAccelerator) => - otherAccelerator as CPUAccelerator != null; + otherAccelerator is CPUAccelerator || + otherAccelerator is VelocityAccelerator; /// protected override void EnablePeerAccessInternal(Accelerator otherAccelerator) { - if (otherAccelerator as CPUAccelerator == null) + if (!CanAccessPeerInternal(otherAccelerator)) { throw new InvalidOperationException( RuntimeErrorMessages.CannotEnablePeerAccessToOtherAccelerator); @@ -266,7 +268,7 @@ protected override void EnablePeerAccessInternal(Accelerator otherAccelerator) protected override void DisablePeerAccessInternal( Accelerator otherAccelerator) => Debug.Assert( - otherAccelerator is CPUAccelerator, + CanAccessPeerInternal(otherAccelerator), "Invalid EnablePeerAccess method"); #endregion @@ -482,7 +484,7 @@ protected override int EstimateGroupSizeInternal( #region Page Lock Scope /// - protected unsafe override PageLockScope CreatePageLockFromPinnedInternal( + protected override PageLockScope CreatePageLockFromPinnedInternal( IntPtr pinned, long numElements) {