[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32150] branches/particles-2010/source/ blender/nodes/intern/simulation/SIM_util.c: read/write/ copy tasks now copy all items in one go.

Lukas Toenne lukas.toenne at googlemail.com
Mon Sep 27 12:53:42 CEST 2010


Revision: 32150
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32150
Author:   lukastoenne
Date:     2010-09-27 12:53:41 +0200 (Mon, 27 Sep 2010)

Log Message:
-----------
read/write/copy tasks now copy all items in one go. doing this in parallel is probably not feasible, since threads would have to wait for the data bus anyway, thus just creating overhead when switching.

Modified Paths:
--------------
    branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c

Modified: branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c	2010-09-27 10:44:46 UTC (rev 32149)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c	2010-09-27 10:53:41 UTC (rev 32150)
@@ -549,11 +549,20 @@
 static void exec_copy_task(void *data, int start, int total)
 {
 	BufferTaskData *td= (BufferTaskData*)data;
+	/* not really necessary, since all items are copied at once */
 	int num_copy= MIN2(td->num, start+total) - start;
 	if (num_copy > 0)
 		memcpy((char*)td->dst + (td->dst_start+start)*td->stride, (char*)td->src + (td->src_start+start)*td->stride, num_copy*td->stride);
 }
 
+/* note: work group size is the same as number of items, since copying is best done in one go.
+ * doing multithreaded memcpys is not feasible, because data bus will block other threads anyway.
+ */
+struct SimTask *enqueue_copy_task(struct SimExecData *execdata, void *data, int totitems, int num_wait_events, struct SimEvent *wait_events, struct SimEvent *event)
+{
+	return sim_enqueue_task(execdata, exec_copy_task, data, totitems, totitems, num_wait_events, wait_events, event);
+}
+
 void sim_enqueue_read_buffer(SimExecData *execdata, SimBuffer *buffer, int blocking, int start, int num, void *dst, int num_wait_events, SimEvent *wait_events, SimEvent *event)
 {
 	if (execdata->error)
@@ -592,7 +601,8 @@
 		td->dst_start = 0;
 		td->num = num;
 		td->stride = buffer->stride;
-		sim_enqueue_task(execdata, exec_copy_task, td, num, 0, num_wait_events, wait_events, &taskevent);
+		/* note: workgroupsize is number of items, so the copy task is only executed once */
+		enqueue_copy_task(execdata, td, num, num_wait_events, wait_events, &taskevent);
 		if (event)
 			*event = taskevent;
 		
@@ -641,7 +651,7 @@
 		td->dst_start = start;
 		td->num = num;
 		td->stride = buffer->stride;
-		sim_enqueue_task(execdata, exec_copy_task, td, num, 0, num_wait_events, wait_events, &taskevent);
+		enqueue_copy_task(execdata, td, num, num_wait_events, wait_events, &taskevent);
 		if (event)
 			*event = taskevent;
 		
@@ -697,7 +707,7 @@
 		td->dst_start = start_dst;
 		td->num = num;
 		td->stride = src->stride;
-		sim_enqueue_task(execdata, exec_copy_task, td, num, 0, num_wait_events, wait_events, event);
+		enqueue_copy_task(execdata, td, num, num_wait_events, wait_events, event);
 
 //		memcpy((char*)dst->data + start_dst * dst->stride, (char*)src->data + start_src * src->stride, num * src->stride);
 	}





More information about the Bf-blender-cvs mailing list