Пример #1
0
 public void EraseAll()
 {
     lock (Mutex)
     {
         foreach (var item in Stacks)
         {
             if (item.Value != null)
             {
                 foreach (var arr in item.Value)
                 {
                     if (this.Device.Type == DeviceType.NvidiaGPU)
                     {
                         CudaManagement.SetDevice(this.Device.ID);
                         CudaManagement.Free(arr.Ptr);
                     }
                     else if (this.Device.Type == DeviceType.Host)
                     {
                         GC.RemoveMemoryPressure((long)item.Key);
                         MKL.MKL_free(arr.Ptr);
                     }
                     else
                     {
                         throw new Exception("Uknown Device in ArrayPool!");
                     }
                 }
                 item.Value.Clear();
             }
         }
         Stacks.Clear();
     }
 }