From 35e7f72d8b1187c61f795216352f6c9e8a8a8906 Mon Sep 17 00:00:00 2001 From: Marcel Koester Date: Sat, 26 Nov 2022 18:40:29 -0500 Subject: [PATCH] Refined peer-access implementation of CPUAccelerator. --- Src/ILGPU/Runtime/CPU/CPUAccelerator.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Src/ILGPU/Runtime/CPU/CPUAccelerator.cs b/Src/ILGPU/Runtime/CPU/CPUAccelerator.cs index c502ff3308..18c46c4e5a 100644 --- a/Src/ILGPU/Runtime/CPU/CPUAccelerator.cs +++ b/Src/ILGPU/Runtime/CPU/CPUAccelerator.cs @@ -1,6 +1,6 @@ // --------------------------------------------------------------------------------------- // ILGPU -// Copyright (c) 2016-2021 ILGPU Project +// Copyright (c) 2016-2022 ILGPU Project // www.ilgpu.net // // File: 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.Reflection; @@ -240,12 +241,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); @@ -256,7 +258,7 @@ protected override void EnablePeerAccessInternal(Accelerator otherAccelerator) protected override void DisablePeerAccessInternal( Accelerator otherAccelerator) => Debug.Assert( - otherAccelerator is CPUAccelerator, + CanAccessPeerInternal(otherAccelerator), "Invalid EnablePeerAccess method"); #endregion @@ -472,7 +474,7 @@ protected override int EstimateGroupSizeInternal( #region Page Lock Scope /// - protected unsafe override PageLockScope CreatePageLockFromPinnedInternal( + protected override PageLockScope CreatePageLockFromPinnedInternal( IntPtr pinned, long numElements) {