From 5ee37a22eb028d5d143afc07796cbfb4eef48a45 Mon Sep 17 00:00:00 2001 From: raver119 Date: Tue, 21 Apr 2020 07:31:57 +0300 Subject: [PATCH] Workspace ID fix (#400) Signed-off-by: raver119 --- .../src/main/java/org/nd4j/jita/workspace/CudaWorkspace.java | 2 +- .../nd4j/linalg/cpu/nativecpu/workspace/CpuWorkspace.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/workspace/CudaWorkspace.java b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/workspace/CudaWorkspace.java index 048a6d4c5..e8d9b2d18 100644 --- a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/workspace/CudaWorkspace.java +++ b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/workspace/CudaWorkspace.java @@ -413,7 +413,7 @@ public class CudaWorkspace extends Nd4jWorkspace { @Override public String getUniqueId() { - return "Workspace_" + getId(); + return "Workspace_" + getId() + "_" + Nd4j.getDeallocatorService().nextValue(); } @Override diff --git a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/linalg/cpu/nativecpu/workspace/CpuWorkspace.java b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/linalg/cpu/nativecpu/workspace/CpuWorkspace.java index b773b7964..0f83c0445 100644 --- a/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/linalg/cpu/nativecpu/workspace/CpuWorkspace.java +++ b/nd4j/nd4j-backends/nd4j-backend-impls/nd4j-native/src/main/java/org/nd4j/linalg/cpu/nativecpu/workspace/CpuWorkspace.java @@ -62,7 +62,7 @@ public class CpuWorkspace extends Nd4jWorkspace implements Deallocatable { public String getUniqueId() { - return "Workspace_" + getId(); + return "Workspace_" + getId() + "_" + Nd4j.getDeallocatorService().nextValue(); } @Override @@ -93,9 +93,10 @@ public class CpuWorkspace extends Nd4jWorkspace implements Deallocatable { isInit.set(true); - if (isDebug.get()) + //if (isDebug.get()) log.info("Allocating [{}] workspace of {} bytes...", id, currentSize.get()); + workspace.setHostPointer(new PagedPointer(memoryManager.allocate(currentSize.get() + SAFETY_OFFSET, MemoryKind.HOST, true))); AllocationsTracker.getInstance().markAllocated(AllocationKind.WORKSPACE, 0, currentSize.get() + SAFETY_OFFSET); }