Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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();
            }
        }
Exemple #4
0
        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);
                        }
                    }
                }
            }
        }
Exemple #6
0
        public IDeviceMemory Allocate(long byteCount)
        {
            var buffer = context.AllocateMemory(byteCount);

            return(new BasicDeviceMemory(buffer, () => context.FreeMemory(buffer)));
        }
Exemple #7
0
 public void Dispose()
 {
     m_context.SetCurrent();
     m_context.FreeMemory(m_memPoolPtr);
 }