Bläddra i källkod

Add modes.cocci, a Coccinelle script that will help converting old code (with the modes specified in the task) to new code (modes specified in the codelet).

Cyril Roelandt 13 år sedan
förälder
incheckning
81bbc06395
2 ändrade filer med 67 tillägg och 0 borttagningar
  1. 41 0
      tools/dev/experimental/modes.cocci
  2. 26 0
      tools/dev/experimental/modes_test.c

+ 41 - 0
tools/dev/experimental/modes.cocci

@@ -0,0 +1,42 @@
+@find_cl@
+identifier c;
+@@
+struct starpu_codelet c =
+{
+};
+
+@find_task depends on find_cl@
+identifier t;
+identifier find_cl.c;
+@@
+t->cl = &c; 
+
+
+/*
+ * Remove task->buffers[id].mode = STARPU_{R,W,RW}
+ * Replace task->buffers[id].handle = handle; by  
+ *      task->handles[id] = handle;
+ */
+@remove_task_mode depends on find_task@
+identifier find_task.t;
+expression E;
+identifier h;
+expression id; 
+identifier find_cl.c;
+@@
+(
+- t->buffers[id].handle = h;
+|
+- t->buffers[id].mode = E;
+)
+
+@has_modes depends on remove_task_mode@
+identifier find_cl.c;
+expression remove_task_mode.id;
+expression remove_task_mode.E;
+@@
+struct starpu_codelet c =
+{
+++	.modes[id] = E,
+};

+ 26 - 0
tools/dev/experimental/modes_test.c

@@ -0,0 +1,26 @@
+/* Dont change anything ! */
+struct starpu_codelet cummy_cl = 
+{
+        .cpu_funcs = { foo, NULL },
+        .nbuffers = 42
+}
+
+/* Now, there is some work to do */
+struct starpu_codelet cl1 = 
+{
+        .cpu_funcs = { foo, bar, NULL },
+        .nbuffers = 2,
+};
+
+int
+foo(void)
+{
+        struct starpu_task *task;
+        task = starpu_task_create();
+        task->cl = &cl1;
+        task->buffers[0].handle = handle1;
+        task->buffers[0].mode = STARPU_R;
+        task->synchronous = 1;
+        task->buffers[1].handle = handle2;
+        task->buffers[1].mode = STARPU_W;
+}