Selaa lähdekoodia

SOCL: fix some memory leaks

Sylvain Henry 13 vuotta sitten
vanhempi
commit
b88b8f21db
3 muutettua tiedostoa jossa 25 lisäystä ja 3 poistoa
  1. 17 2
      socl/src/cl_enqueuendrangekernel.c
  2. 2 0
      socl/src/command_queue.c
  3. 6 1
      socl/src/event.c

+ 17 - 2
socl/src/cl_enqueuendrangekernel.c

@@ -97,9 +97,24 @@ static void cleaning_task_callback(void *args) {
 
 	free(cmd->buffers);
 
-	void * co = cmd->codelet;
+	free(cmd->codelet);
 	cmd->codelet = NULL;
-	free(co);
+
+	if (cmd->global_work_offset != NULL) {
+	  free((void*)cmd->global_work_offset);
+	  cmd->global_work_offset = NULL;
+	}
+
+	if (cmd->global_work_size != NULL) {
+	  free((void*)cmd->global_work_size);
+	  cmd->global_work_size = NULL;
+	}
+
+	if (cmd->local_work_size != NULL) {
+	  free((void*)cmd->local_work_size);
+	  cmd->local_work_size = NULL;
+	}
+
 }
 
 static struct starpu_perfmodel perf_model = {

+ 2 - 0
socl/src/command_queue.c

@@ -129,6 +129,8 @@ void command_queue_dependencies(
 	memcpy(evs, implicit_events, sizeof(cl_event) * implicit_num_events);
 	memcpy(&evs[implicit_num_events], events, sizeof(cl_event) * num_events);
 
+	free(implicit_events);
+
 	*ret_num_events = ndeps;
 	*ret_events = evs;
 }

+ 6 - 1
socl/src/event.c

@@ -48,6 +48,7 @@ static void release_callback_event(void * e) {
   cl_event event = (cl_event)e;
 
   cl_command_queue cq = event->cq;
+  cl_command cmd = event->command;
 
   /* Remove from command queue */
   if (cq != NULL) {
@@ -59,7 +60,7 @@ static void release_callback_event(void * e) {
       cq->barrier = NULL;
 
     /* Remove from the list of out-of-order commands */
-    cq->commands = command_list_remove(cq->commands, event->command);
+    cq->commands = command_list_remove(cq->commands, cmd);
 
     /* Unlock command queue */
     pthread_mutex_unlock(&cq->mutex);
@@ -67,6 +68,10 @@ static void release_callback_event(void * e) {
     gc_entity_unstore(&cq);
   }
 
+  free(cmd->events);
+  cmd->events = NULL;
+  cmd->num_events = 0;
+
   /* Destruct object */
   //FIXME: we cannot release tag because it makes StarPU crash
   //starpu_tag_remove(event->id);