eliminate leak and fix memory tracking
This commit is contained in:
@@ -112,7 +112,7 @@ void limpiar(const char s[])
|
||||
|
||||
if(GPUmem.size() == 0)
|
||||
{
|
||||
// cerr << s << ": not enough GPU memory: have " << avmem << endl;
|
||||
// DEBUG_MEM cerr << s << ": not enough GPU memory: have " << avmem << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void liberar(int *ptr, int size)
|
||||
//cout << "L " << avmem << " " << size;
|
||||
|
||||
cudaFree(ptr);
|
||||
// cerr << "- " << ptr << " " << size << endl;
|
||||
// DEBUG_MEM cerr << "- " << ptr << " " << size << endl;
|
||||
avmem += size;
|
||||
|
||||
//cout << " " << avmem << endl;
|
||||
@@ -186,7 +186,7 @@ void reservar(int **ptr, int size)
|
||||
{
|
||||
//size_t free, total;
|
||||
//cudaMemGetInfo( &free, &total );
|
||||
// // cerr << "- " << free << " " << size << endl;
|
||||
// cerr << "? " << free << " " << size << endl;
|
||||
|
||||
if (size == 0) {
|
||||
*ptr = NULL;
|
||||
@@ -199,8 +199,8 @@ void reservar(int **ptr, int size)
|
||||
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;
|
||||
cerr << "Could not allocate " << size << " bytes, only " << free << " avaliable from total of " << total << " !!!" << endl;
|
||||
cerr << "Exiting CUDA...." << endl;
|
||||
exit(1);
|
||||
}
|
||||
avmem -= size;
|
||||
@@ -277,7 +277,7 @@ int cargar(int name, int num_rows, int num_columns, int is_fact, int *address_ho
|
||||
}
|
||||
size = num_rows * num_columns * sizeof(int);
|
||||
reservar(&temp, size);
|
||||
// cerr << "+ " << temp << " temp " << size << endl;
|
||||
// DEBUG_MEM cerr << "+ " << temp << " temp " << size << endl;
|
||||
cudaMemcpyAsync(temp, address_host_table, size, cudaMemcpyHostToDevice);
|
||||
registrar(name, num_columns, temp, num_rows, itr, 0);
|
||||
*ptr = temp;
|
||||
@@ -297,7 +297,7 @@ int cargar(int name, int num_rows, int num_columns, int is_fact, int *address_ho
|
||||
}
|
||||
size = totalrows * num_columns * sizeof(int);
|
||||
reservar(&temp, size);
|
||||
// cerr << "+ " << temp << " temp 2 " << size << endl;
|
||||
// DEBUG_MEM cerr << "+ " << temp << " temp 2 " << size << endl;
|
||||
for(x = 1; x < numgpu; x++)
|
||||
{
|
||||
cudaMemcpyAsync(temp + temp_storage[x-1].size, temp_storage[x].dev_address, temp_storage[x].size, cudaMemcpyDeviceToDevice);
|
||||
@@ -340,7 +340,7 @@ int cargafinal(int name, int cols, int **ptr)
|
||||
}
|
||||
|
||||
reservar(&temp, cont * cols * sizeof(int));
|
||||
// cerr << "+ " << temp << " temp 3 " << cont * cols * sizeof(int) << endl;
|
||||
// DEBUG_MEM cerr << "+ " << temp << " temp 3 " << cont * cols * sizeof(int) << endl;
|
||||
ini = temp;
|
||||
|
||||
pos = gpu;
|
||||
@@ -463,7 +463,7 @@ void resultados(vector<rulenode>::iterator first, vector<rulenode>::iterator las
|
||||
cout << endl;
|
||||
}
|
||||
cudaFree(gpu->dev_address);
|
||||
// cerr << "- " << gpu->dev_address << " gpu->dev_address" << endl;
|
||||
// DEBUG_MEM cerr << "- " << gpu->dev_address << " gpu->dev_address" << endl;
|
||||
free(temp);
|
||||
gpu++;
|
||||
}
|
||||
@@ -495,7 +495,7 @@ void clear_memory()
|
||||
{
|
||||
if (ini->isrule) {
|
||||
cudaFree(ini->dev_address);
|
||||
// cerr << "- " << ini->dev_address << " ini->dev_address" << endl;
|
||||
// DEBUG_MEM cerr << "- " << ini->dev_address << " ini->dev_address" << endl;
|
||||
ini = GPUmem.erase(ini);
|
||||
} else {
|
||||
ini++;
|
||||
|
||||
Reference in New Issue
Block a user