Browse Source

Add a test ensuring that we can call starpu_data_release from a callback (this
currently fails!).

Cédric Augonnet 14 years ago
parent
commit
7619f09fc9
2 changed files with 51 additions and 0 deletions
  1. 6 0
      tests/Makefile.am
  2. 45 0
      tests/datawizard/acquire_cb.c

+ 6 - 0
tests/Makefile.am

@@ -111,6 +111,7 @@ check_PROGRAMS += 				\
 	core/declare_deps_after_submission	\
 	core/declare_deps_after_submission_synchronous	\
 	core/get_current_task			\
+	datawizard/acquire_cb			\
 	datawizard/acquire_release		\
 	datawizard/acquire_release2		\
 	datawizard/data_implicit_deps		\
@@ -276,6 +277,11 @@ core_get_current_task_SOURCES =			\
 	core/get_current_task.c
 
 testbin_PROGRAMS +=				\
+	datawizard/acquire_cb
+datawizard_acquire_cb_SOURCES =			\
+	datawizard/acquire_cb.c
+
+testbin_PROGRAMS +=				\
 	datawizard/acquire_release
 datawizard_acquire_release_SOURCES =		\
 	datawizard/acquire_release.c

+ 45 - 0
tests/datawizard/acquire_cb.c

@@ -0,0 +1,45 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2011  Université de Bordeaux 1
+ *
+ * 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
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#include <starpu.h>
+
+#define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
+
+unsigned token = 0;
+starpu_data_handle token_handle;
+
+void callback(void *arg __attribute__ ((unused)))
+{
+	token = 42;
+        starpu_data_release(token_handle);
+}
+
+int main(int argc, char **argv)
+{
+        starpu_init(NULL);
+
+	starpu_variable_data_register(&token_handle, 0, (uintptr_t)&token, sizeof(unsigned));
+        starpu_data_acquire_cb(token_handle, STARPU_RW, callback, NULL);
+
+	starpu_data_unregister(token_handle);
+
+        FPRINTF(stderr, "Token: %d\n", token);
+        STARPU_ASSERT(token == 42);
+
+	starpu_shutdown();
+
+	return 0;
+}