Commit 1fada737 by xiaotong

fix the bug of incorrect pointer to the head of memory pieces

parent cb9c88cb
......@@ -685,13 +685,16 @@ void * XMem::AllocStandard(int myDevID, MTYPE mySize, bool myIsRebuiltIndex)
int bi;
for(bi = 0; bi < blockNum; bi++){
XMemBlock * block = blocks + bi;
if(block->mem == NULL){
if (block->mem != NULL && (block->head != NULL || block->size < mySize + 2 * MY_PITCH))
continue;
if (block->mem == NULL) {
block->size = MAX(maxBlockSize, mySize + 2 * MY_PITCH);
if (myDevID < 0) {
block->mem = new char[block->size];
memset(block->mem, 0, block->size);
}
else{
else {
#ifdef USE_CUDA
int devIDBackup = -1;
cudaGetDevice(&devIDBackup);
......@@ -706,6 +709,7 @@ void * XMem::AllocStandard(int myDevID, MTYPE mySize, bool myIsRebuiltIndex)
ShowNTErrors("Please specify USE_CUDA for compiling this program.");
#endif
}
}
curBlockID = MAX(curBlockID, bi);
......@@ -731,7 +735,6 @@ void * XMem::AllocStandard(int myDevID, MTYPE mySize, bool myIsRebuiltIndex)
result = AllocStandard(myDevID, mySize, myIsRebuiltIndex);
break;
}
}
CheckNTErrors(bi < blockNum, "No enough memory is available!");
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论