Esempio n. 1
0
 public CudaPieceInt(int length, bool needCpuMem, bool needGpuMem)
 {
     // the input is given assuming MATH_LIB = gpu
     // So if cpu is used, we will overwrite
     if (ParameterSetting.MATH_LIB == MathLibType.cpu)
     {
         needCpuMem = true;
         needGpuMem = false;
     }
     size = length;
     if (needCpuMem)
     {
         cpuMemArray = new int[size];
     }
     if (needGpuMem)
     {
         if ((Int64)(cudaPiecePointer = Cudalib.CudaAllocInt(size)) == 0)
         {
             throw new Exception("Out of GPU Memo, use a smaller model!");
         }
     }
 }