internal CudaDeviceVariable <float> MultiEuclideanDistance(CudaDeviceVariable <float> vector, CUdeviceptr[] compareTo, int size) { CudaDeviceVariable <float> ret = null; var buffer = _cuda.AllocateMemory(8 * compareTo.Length); try { _cuda.CopyToDevice(buffer, compareTo); ret = new CudaDeviceVariable <float>(size * compareTo.Length); _Use(_multiEuclidean, size, compareTo.Length, k => k.Run(0, vector.DevicePointer, buffer, ret.DevicePointer, size, compareTo.Length)); } finally { _cuda.FreeMemory(buffer); } return(ret); }
internal IDeviceMemoryPtr MultiEuclideanDistance(IDeviceMemoryPtr vector, CUdeviceptr[] compareTo, int size) { IDeviceMemoryPtr ret = null; var buffer = _cuda.AllocateMemory(8 * compareTo.Length); try { _cuda.CopyToDevice(buffer, compareTo); ret = Allocate(size * compareTo.Length); _Use(_multiEuclidean, size, compareTo.Length, k => k.Run(0, vector.DevicePointer, buffer, ret.DevicePointer, size, compareTo.Length)); } finally { _cuda.FreeMemory(buffer); } return(ret); }
public void FreeMemory() { lock (locker) { foreach (var kv in pools) { while (kv.Value.Count > 0) { var item = kv.Value.Dequeue(); if (item != null) { context.FreeMemory(item.Pointer); } } } // pools.Clear(); } }
public void FreeMemory(bool callGC = false) { lock (locker) { if (callGC) { GC.Collect(); // GC.WaitForPendingFinalizers(); } foreach (var kv in pools) { while (kv.Value.Count > 0) { var item = kv.Value.Dequeue(); if (item != null) { context.FreeMemory(item.Pointer); } } } } }
public void FreeMemory(bool callGC = false) { lock (locker) { if (callGC) { GC.Collect(); GC.WaitForFullGCComplete(); } foreach (KeyValuePair <long, Queue <IDeviceMemory> > kv in pools) { while (kv.Value.Count > 0) { IDeviceMemory item = kv.Value.Dequeue(); if (item != null) { context.FreeMemory(item.Pointer); } } } } }
public IDeviceMemory Allocate(long byteCount) { var buffer = context.AllocateMemory(byteCount); return(new BasicDeviceMemory(buffer, () => context.FreeMemory(buffer))); }
public void Dispose() { m_context.SetCurrent(); m_context.FreeMemory(m_memPoolPtr); }