Skip to content

Commit

Permalink
Refined peer-access implementation of CPUAccelerator.
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rs-mt committed Jan 26, 2023
1 parent c3caf01 commit bdb1a03
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Src/ILGPU/Runtime/CPU/CPUAccelerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -250,12 +251,13 @@ protected override void OnUnbind() { }

/// <summary cref="Accelerator.CanAccessPeerInternal(Accelerator)"/>
protected override bool CanAccessPeerInternal(Accelerator otherAccelerator) =>
otherAccelerator as CPUAccelerator != null;
otherAccelerator is CPUAccelerator ||
otherAccelerator is VelocityAccelerator;

/// <summary cref="Accelerator.EnablePeerAccessInternal(Accelerator)"/>
protected override void EnablePeerAccessInternal(Accelerator otherAccelerator)
{
if (otherAccelerator as CPUAccelerator == null)
if (!CanAccessPeerInternal(otherAccelerator))
{
throw new InvalidOperationException(
RuntimeErrorMessages.CannotEnablePeerAccessToOtherAccelerator);
Expand All @@ -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
Expand Down Expand Up @@ -482,7 +484,7 @@ protected override int EstimateGroupSizeInternal(
#region Page Lock Scope

/// <inheritdoc/>
protected unsafe override PageLockScope<T> CreatePageLockFromPinnedInternal<T>(
protected override PageLockScope<T> CreatePageLockFromPinnedInternal<T>(
IntPtr pinned,
long numElements)
{
Expand Down

0 comments on commit bdb1a03

Please sign in to comment.