Sfoglia il codice sorgente

tests/main/codelet_null_callback.c: add more testcases, keep out STARPU_PROLOGUE_CALLBACK_POP for now as it seems to be broken

Nathalie Furmento 11 anni fa
parent
commit
08f294077a
1 ha cambiato i file con 48 aggiunte e 4 eliminazioni
  1. 48 4
      tests/main/codelet_null_callback.c

+ 48 - 4
tests/main/codelet_null_callback.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2013  Centre National de la Recherche Scientifique
+ * Copyright (C) 2013, 2014  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -18,17 +18,33 @@
 #include "../helper.h"
 
 static
+int expected_x=40;
+static
+int expected_y=12;
+
+static
 void callback(void *ptr)
 {
      int *x = (int *)ptr;
      FPRINTF(stderr, "x=%d\n", *x);
-     STARPU_ASSERT(*x == 42);
+     STARPU_ASSERT_MSG(*x == expected_x, "%d != %d\n", *x, expected_x);
+     (*x)++;
+}
+
+static
+void prologue_callback(void *ptr)
+{
+     int *y = (int *)ptr;
+     FPRINTF(stderr, "y=%d\n", *y);
+     STARPU_ASSERT_MSG(*y == expected_y, "%d != %d\n", *y, expected_y);
+     (*y)++;
 }
 
 int main(int argc, char **argv)
 {
 	int ret;
-	int x=42;
+	int x=40;
+	int y=12;
 
 	ret = starpu_initialize(NULL, &argc, &argv);
 	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
@@ -39,7 +55,35 @@ int main(int argc, char **argv)
 				 0);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
 
-	starpu_task_wait_for_all();
+	expected_x ++;
+	ret = starpu_task_insert(NULL,
+				 STARPU_CALLBACK, callback,
+				 STARPU_CALLBACK_ARG, &x,
+				 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
+
+	expected_x ++;
+	STARPU_ASSERT_MSG(x == expected_x, "x should be equal to %d and not %d\n", expected_x, x);
+
+	ret = starpu_task_insert(NULL,
+				 STARPU_PROLOGUE_CALLBACK, prologue_callback,
+				 STARPU_PROLOGUE_CALLBACK_ARG, &y,
+				 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
+
+#warning the following code should work
+#if 0
+	expected_y ++;
+	ret = starpu_task_insert(NULL,
+				 STARPU_PROLOGUE_CALLBACK_POP, prologue_callback,
+				 STARPU_PROLOGUE_CALLBACK_ARG, &y,
+				 0);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert");
+#endif
+
+	expected_y ++;
+	STARPU_ASSERT_MSG(y == expected_y, "y should be equal to %d and not %d\n", expected_y, y);
+
 	starpu_shutdown();
 
 	return EXIT_SUCCESS;