Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="length"></param>
 /// <param name="needCpuMem"></param>
 public CudaPieceFloat(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 float[size];
     }
     if (needGpuMem)
     {
         if ((Int64)(cudaPiecePointer = Cudalib.CudaAllocFloat(size)) == 0)
         {
             throw new Exception("Out of GPU Memo, use a smaller model!");
         }
     }
 }