Bladeren bron

Free memory

Samuel Thibault 13 jaren geleden
bovenliggende
commit
4c9c4d484b
3 gewijzigde bestanden met toevoegingen van 19 en 4 verwijderingen
  1. 10 2
      examples/lu/lu_example.c
  2. 4 1
      examples/lu/xlu_implicit_pivot.c
  3. 5 1
      examples/lu/xlu_pivot.c

+ 10 - 2
examples/lu/lu_example.c

@@ -132,7 +132,7 @@ void copy_blocks_into_matrix(void)
 				A_blocks[bi+nblocks*bj][i + j * blocksize];
 		}
 
-		/* free(A_blocks[bi+nblocks*bj]); */
+		starpu_free(A_blocks[bi+nblocks*bj]);
 	}
 }
 
@@ -285,6 +285,10 @@ static void check_result(void)
 
 	if (residual/(matnorm*size) > 1e-5)
 		exit(-1);
+
+	free(L);
+	free(U);
+	free(A_saved);
 }
 
 int main(int argc, char **argv)
@@ -391,12 +395,16 @@ int main(int argc, char **argv)
 	if (check)
 	{
 		FPRINTF(stderr, "Checking result\n");
-		if (pivot)
+		if (pivot) {
 			pivot_saved_matrix(ipiv);
+			free(ipiv);
+		}
 
 		check_result();
 	}
 
+	starpu_free(A);
+
 	FPRINTF(stderr, "Shutting down\n");
 	starpu_helper_cublas_shutdown();
 

+ 4 - 1
examples/lu/xlu_implicit_pivot.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2010-2012  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
@@ -232,6 +232,8 @@ void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size
 	/* gather all the data */
 	starpu_data_unpartition(dataA, 0);
 	starpu_data_unregister(dataA);
+
+	free(piv_description);
 }
 
 
@@ -284,4 +286,5 @@ void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, un
 	{
 		starpu_data_unregister(dataAp[bi+nblocks*bj]);
 	}
+	free(dataAp);
 }

+ 5 - 1
examples/lu/xlu_pivot.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
+ * Copyright (C) 2009-2012  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -90,6 +90,7 @@ static void create_task_pivot(starpu_data_handle_t *dataAp, unsigned nblocks,
 
 			/* perhaps we could do better ... :/  */
 			starpu_tag_declare_deps_array(PIVOT(k, i), (nblocks-k), tags);
+			free(tags);
 		}
 	}
 
@@ -307,6 +308,7 @@ static double dw_codelet_facto_pivot(starpu_data_handle_t *dataAp,
 	/* stall the application until the end of computations */
 	starpu_tag_wait_array(ndeps, tags);
 /*	starpu_task_wait_for_all(); */
+	free(tags);
 
 	gettimeofday(&end, NULL);
 
@@ -381,6 +383,7 @@ void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size
 
 	/* gather all the data */
 	starpu_data_unpartition(dataA, 0);
+	free(piv_description);
 }
 
 
@@ -436,4 +439,5 @@ void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, un
 	{
 		starpu_data_unregister(dataAp[bi+nblocks*bj]);
 	}
+	free(dataAp);
 }