Commit 89ad96e6 by xuchen

fix the bug about device reset

parent e84a764b
......@@ -191,18 +191,17 @@ void XDevice::Clear()
void XDevice::Reset()
{
Clear();
XMem * mem = GMems.GetMem(devID);
mem->Free();
if (!isInitialized)
return;
int devIDReset = devID;
Clear();
for (int i = 0; i < MAX_CPU_MEM_NUM; i++)
delete GMems.GetMem(devID);
#ifdef USE_CUDA
if (devID >= 0) {
if (devIDReset >= 0) {
int devIDBackup = -1;
cudaGetDevice(&devIDBackup);
cudaSetDevice(devID);
cudaSetDevice(devIDReset);
cudaDeviceReset();
......
......@@ -176,8 +176,9 @@ void XMem::Initialize(int myDevID, MEMPOOL_MODE myMode, MTYPE myBlockSize, int m
/* free memory */
void XMem::Free()
{
for(int i = 0; i < blockNum; i++){
Free(devID, blocks[i].mem);
for (int i = 0; i < blockNum; i++) {
if (blocks != NULL)
Free(devID, blocks[i].mem);
}
delete[] blocks;
blocks = NULL;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论