public static void CudaStop() { if (_cuda != null) { _cudaTest.Dispose(); _cuda.Dispose(); _cuda = null; } }
/// <summary> /// Dispose all object used by CUDA /// </summary> private void DisposeCuda() { if (cuda != null) { //free all resources cuda.Free(valsCSRPtr); cuda.Free(valsCSCPtr); valsCSRPtr.Pointer = IntPtr.Zero; valsCSCPtr.Pointer = IntPtr.Zero; cuda.Free(idxCSRPtr); cuda.Free(idxCSCPtr); idxCSRPtr.Pointer = IntPtr.Zero; idxCSCPtr.Pointer = IntPtr.Zero; cuda.Free(vecLenghtCSRPtr); cuda.Free(vecLenghtCSCPtr); vecLenghtCSRPtr.Pointer = IntPtr.Zero; vecLenghtCSCPtr.Pointer = IntPtr.Zero; cuda.Free(qdPtr); qdPtr.Pointer = IntPtr.Zero; // cuda.Free(diagPtr); diagPtr.Pointer = IntPtr.Zero; cuda.Free(alphaPtr); alphaPtr.Pointer = IntPtr.Zero; cuda.Free(gradPtr); gradPtr.Pointer = IntPtr.Zero; cuda.Free(deltasPtr); deltasPtr.Pointer = IntPtr.Zero; cuda.DestroyTexture(cuDeltasTexRef); cuda.Free(labelsPtr); labelsPtr.Pointer = IntPtr.Zero; cuda.DestroyTexture(cuLabelsTexRef); cuda.Free(mainVecPtr); mainVecPtr.Pointer = IntPtr.Zero; cuda.DestroyTexture(cuMainVecTexRef); cuda.UnloadModule(cuModule); cuda.Dispose(); cuda = null; } }
private void DisposeCuda() { if (cuda != null) { //free all resources cuda.Free(valsCSRPtr); cuda.Free(valsCSCPtr); valsCSRPtr.Pointer = IntPtr.Zero; valsCSCPtr.Pointer = IntPtr.Zero; cuda.Free(idxCSRPtr); cuda.Free(idxCSCPtr); idxCSRPtr.Pointer = IntPtr.Zero; idxCSCPtr.Pointer = IntPtr.Zero; cuda.Free(vecLenghtCSRPtr); cuda.Free(vecLenghtCSCPtr); vecLenghtCSRPtr.Pointer = IntPtr.Zero; vecLenghtCSCPtr.Pointer = IntPtr.Zero; cuda.Free(gradPtr); gradPtr.Pointer = IntPtr.Zero; cuda.Free(gradOldPtr); gradOldPtr.Pointer = IntPtr.Zero; cuda.Free(alphaPtr); alphaPtr.Pointer = IntPtr.Zero; cuda.Free(alphaTmpPtr); alphaTmpPtr.Pointer = IntPtr.Zero; cuda.Free(alphaOldPtr); alphaOldPtr.Pointer = IntPtr.Zero; cuda.Free(wVecPtr); wVecPtr.Pointer = IntPtr.Zero; cuda.Free(wTempVecPtr); wTempVecPtr.Pointer = IntPtr.Zero; cuda.Free(reduceBBAlphaPtr); reduceBBAlphaPtr.Pointer = IntPtr.Zero; cuda.Free(reduceBBGradPtr); reduceBBGradPtr.Pointer = IntPtr.Zero; cuda.Free(reduceBBAlphaGradPtr); reduceBBAlphaGradPtr.Pointer = IntPtr.Zero; cuda.Free(reduceObjAlphaPtr); reduceObjAlphaPtr.Pointer = IntPtr.Zero; cuda.Free(reduceObjWPtr); reduceObjWPtr.Pointer = IntPtr.Zero; cuda.Free(reduceGradMaxNormPtr); reduceGradMaxNormPtr.Pointer = IntPtr.Zero; //cuda.Free(diagPtr); //diagPtr.Pointer =IntPtr.Zero; //cuda.Free(stepBBPtr); //stepBBPtr.Pointer =IntPtr.Zero; cuda.Free(deltasPtr); deltasPtr.Pointer = IntPtr.Zero; cuda.DestroyTexture(cuDeltasTexRef); cuda.Free(labelsPtr); labelsPtr.Pointer = IntPtr.Zero; cuda.DestroyTexture(cuLabelsTexRef); cuda.DestroyTexture(cuWVecTexRef); cuda.UnloadModule(cuModule); cuda.Dispose(); cuda = null; } }