Commit afa887d4 by xiaotong

better use of enum in cuda

parent bb278bfa
......@@ -161,7 +161,7 @@ cublasHandle_t * XDevice::GetCublasHandle()
MUTEX_LOCK(cublasMutex);
int devIDBackup = 0;
ProtectCudaDev(devID, devIDBackup);
CheckNTErrors(cublasCreate(&cublasHandle) == cudaSuccess,
CheckNTErrors(cublasCreate(&cublasHandle) == CUBLAS_STATUS_SUCCESS,
"Cannot create the cublas handle.");
isHandleReady = true;
BacktoCudaDev(devID, devIDBackup);
......
......@@ -139,8 +139,8 @@ void XMem::Initialize(int myDevID, MEMPOOL_MODE myMode, MTYPE myBlockSize, int m
CheckNTErrors(cudaMalloc((void **)&buf, myBufSize) == cudaSuccess, "Cannot allocate the memory.");
CheckNTErrors(cudaMemset(buf, 0, myBufSize) == cudaSuccess, "Cannot update the memory.");
CheckNTErrors(curandCreateGenerator(&randGen, CURAND_RNG_PSEUDO_DEFAULT) == cudaSuccess, "Cannot make the cuda random number generator!");
CheckNTErrors(curandSetPseudoRandomGeneratorSeed(randGen, (unsigned)time(NULL)) == cudaSuccess, "Cannot generate the seed!");
CheckNTErrors(curandCreateGenerator(&randGen, CURAND_RNG_PSEUDO_DEFAULT) == CURAND_STATUS_SUCCESS, "Cannot make the cuda random number generator!");
CheckNTErrors(curandSetPseudoRandomGeneratorSeed(randGen, (unsigned)time(NULL)) == CURAND_STATUS_SUCCESS, "Cannot generate the seed!");
SetDevice(devIDBackup);
......@@ -292,7 +292,7 @@ void XMem::SetComputationMode(bool myIsForComputation)
if(!myIsForComputation && devID >= 0 && cublasHandle != NULL)
cublasDestroy(cublasHandle);
if(myIsForComputation)
CheckNTErrors(cublasCreate(&cublasHandle) == cudaSuccess, "Cannot create the cublas handle.");
CheckNTErrors(cublasCreate(&cublasHandle) == CURAND_STATUS_SUCCESS, "Cannot create the cublas handle.");
SetDevice(devIDBackup);
#endif
......@@ -1321,12 +1321,12 @@ void XMem::CreateBLASHandle()
{
#ifdef USE_CUDA
if(cublasHandle != NULL){
CheckNTErrors(cublasDestroy(cublasHandle) == cudaSuccess,
"Cannot destroy the cublas handle.");
CheckNTErrors(cublasDestroy(cublasHandle) == CUBLAS_STATUS_SUCCESS,
"Cannot destroy the cublas handle.");
}
CheckNTErrors(cublasCreate(&cublasHandle) == cudaSuccess,
"Cannot create the cublas handle.");
CheckNTErrors(cublasCreate(&cublasHandle) == CURAND_STATUS_SUCCESS,
"Cannot create the cublas handle.");
#endif
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论