Browse Source

SOCL: fix segfaults with entity management

Sylvain Henry 13 years ago
parent
commit
3a17c864a5
5 changed files with 11 additions and 10 deletions
  1. 2 2
      socl/src/cl_enqueuendrangekernel.c
  2. 3 0
      socl/src/command_queue.c
  3. 1 2
      socl/src/gc.c
  4. 0 2
      socl/src/socl.h
  5. 5 4
      socl/src/task.c

+ 2 - 2
socl/src/cl_enqueuendrangekernel.c

@@ -78,7 +78,6 @@ void soclEnqueueNDRangeKernel_task(void *descr[], void *args) {
 
 
    /* Waiting for kernel to terminate */
    /* Waiting for kernel to terminate */
    clWaitForEvents(1, &event);
    clWaitForEvents(1, &event);
-   clReleaseEvent(event);
 }
 }
 
 
 static void cleaning_task_callback(void *args) {
 static void cleaning_task_callback(void *args) {
@@ -97,6 +96,7 @@ static void cleaning_task_callback(void *args) {
 		gc_entity_unstore(&cmd->buffers[i]);
 		gc_entity_unstore(&cmd->buffers[i]);
 
 
 	free(cmd->buffers);
 	free(cmd->buffers);
+
 	void * co = cmd->codelet;
 	void * co = cmd->codelet;
 	cmd->codelet = NULL;
 	cmd->codelet = NULL;
 	free(co);
 	free(co);
@@ -160,7 +160,7 @@ cl_int command_ndrange_kernel_submit(command_ndrange_kernel cmd) {
 
 
 	/* Enqueue a cleaning task */
 	/* Enqueue a cleaning task */
 	//FIXME: execute this in the callback?
 	//FIXME: execute this in the callback?
-	starpu_task cleaning_task = task_create_cpu(cleaning_task_callback, cmd,1);
+	starpu_task cleaning_task = task_create_cpu(cleaning_task_callback, cmd,0);
 	cl_event ev = command_event_get(cmd);
 	cl_event ev = command_event_get(cmd);
 	task_depends_on(cleaning_task, 1, &ev);
 	task_depends_on(cleaning_task, 1, &ev);
 	task_submit(cleaning_task, cmd);
 	task_submit(cleaning_task, cmd);

+ 3 - 0
socl/src/command_queue.c

@@ -160,6 +160,9 @@ void command_queue_enqueue_ex(cl_command_queue cq, cl_command cmd, cl_uint num_e
 	cmd->num_events = all_num_events;
 	cmd->num_events = all_num_events;
 	cmd->events = all_events;
 	cmd->events = all_events;
 
 
+	/* Increment event ref count */
+	gc_entity_retain(cmd->event);
+
 	/* Insert command in the queue */
 	/* Insert command in the queue */
 	command_queue_insert(cq, cmd, is_barrier);
 	command_queue_insert(cq, cmd, is_barrier);
 
 

+ 1 - 2
socl/src/gc.c

@@ -61,8 +61,7 @@ static void * gc_thread_routine(void *UNUSED(arg)) {
 
 
       /* Release entity */
       /* Release entity */
       entity next = r->next;
       entity next = r->next;
-#warning FIXME: free memory
-//      free(r);
+      free(r);
 
 
       r = next;
       r = next;
     }
     }

+ 0 - 2
socl/src/socl.h

@@ -100,14 +100,12 @@ struct _cl_platform_id {};
 	if ((blocking) == CL_TRUE) {\
 	if ((blocking) == CL_TRUE) {\
 		cl_event ev = command_event_get(cmd);\
 		cl_event ev = command_event_get(cmd);\
 		soclWaitForEvents(1, &ev);\
 		soclWaitForEvents(1, &ev);\
-		gc_entity_release(ev);\
 	}
 	}
 
 
 #define MAY_BLOCK_CUSTOM(blocking,event) \
 #define MAY_BLOCK_CUSTOM(blocking,event) \
 	if ((blocking) == CL_TRUE) {\
 	if ((blocking) == CL_TRUE) {\
 		cl_event ev = (event);\
 		cl_event ev = (event);\
 		soclWaitForEvents(1, &ev);\
 		soclWaitForEvents(1, &ev);\
-		gc_entity_release(ev);\
 	}
 	}
 
 
 /* Constants */
 /* Constants */

+ 5 - 4
socl/src/task.c

@@ -113,13 +113,14 @@ static void cputask_task(__attribute__((unused)) void *descr[], void *args) {
 
 
   arg->callback(arg->arg);
   arg->callback(arg->arg);
 
 
-#warning FIXME: free memory
-/*
-  if (arg->free_arg)
+  if (arg->free_arg) {
+    assert(arg->arg != NULL);
     free(arg->arg);
     free(arg->arg);
+    arg->arg = NULL;
+  }
 
 
   free(arg);
   free(arg);
-*/
+
 }
 }
 
 
 static struct starpu_codelet cputask_codelet = {
 static struct starpu_codelet cputask_codelet = {