cuda fixes by Carlos and other diverse (fact init, configure).

This commit is contained in:
Vítor Santos Costa
2013-10-12 12:46:01 +01:00
parent 0dc78f106b
commit 691e977a68
10 changed files with 124 additions and 24 deletions

View File

@@ -187,13 +187,21 @@ void reservar(int **ptr, int size)
//cudaMemGetInfo( &free, &total );
// cerr << "R " << free << " " << size << endl;
if (size == 0) {
*ptr = NULL;
return;
}
while(avmem < size)
limpiar("not enough memory");
while(cudaMalloc(ptr, size) == cudaErrorMemoryAllocation)
limpiar("error in memory allocation");
if (! *ptr )
exit(0);
if (! *ptr ) {
size_t free, total;
cudaMemGetInfo( &free, &total );
cerr << "Could not allocate " << size << " bytes, only " << free << " avaliable from total of " << total << " !!!" << endl;
cerr << "Exiting CUDA...." << endl;
exit(1);
}
// cerr << *ptr << " " << size;
avmem -= size;