Преглед на файлове

gcc: Add support for `#pragma starpu shutdown'.

* gcc-plugin/src/starpu.c (handle_pragma_shutdown): New function.
  (register_pragmas): Register it.

* gcc-plugin/tests/Makefile.am (gcc_tests): Add `shutdown-errors.c'.

* gcc-plugin/tests/base.c (main): Use `#pragma starpu shutdown'.

* gcc-plugin/tests/lib.h (starpu_shutdown): New function.

* gcc-plugin/tests/shutdown-errors.c: New file.
Ludovic Courtès преди 14 години
родител
ревизия
47cab03561
променени са 5 файла, в които са добавени 56 реда и са изтрити 1 реда
  1. 19 0
      gcc-plugin/src/starpu.c
  2. 2 1
      gcc-plugin/tests/Makefile.am
  3. 3 0
      gcc-plugin/tests/base.c
  4. 9 0
      gcc-plugin/tests/lib.h
  5. 23 0
      gcc-plugin/tests/shutdown-errors.c

+ 19 - 0
gcc-plugin/src/starpu.c

@@ -327,6 +327,23 @@ handle_pragma_initialize (struct cpp_reader *reader)
   add_stmt (init);
 }
 
+/* Process `#pragma starpu shutdown'.  */
+
+static void
+handle_pragma_shutdown (struct cpp_reader *reader)
+{
+  static tree shutdown_fn;
+  LOOKUP_STARPU_FUNCTION (shutdown_fn, "starpu_shutdown");
+
+  tree token;
+  if (pragma_lex (&token) != CPP_EOF)
+    error_at (cpp_peek_token (reader, 0)->src_loc,
+	      "junk after %<starpu shutdown%> pragma");
+  else
+    /* Call `starpu_shutdown ()'.  */
+    add_stmt (build_call_expr (shutdown_fn, 0));
+}
+
 static void
 handle_pragma_wait (struct cpp_reader *reader)
 {
@@ -587,6 +604,8 @@ register_pragmas (void *gcc_data, void *user_data)
 				    handle_pragma_acquire);
   c_register_pragma_with_expansion (STARPU_PRAGMA_NAME_SPACE, "unregister",
 				    handle_pragma_unregister);
+  c_register_pragma (STARPU_PRAGMA_NAME_SPACE, "shutdown",
+		     handle_pragma_shutdown);
 }
 
 

+ 2 - 1
gcc-plugin/tests/Makefile.am

@@ -26,7 +26,8 @@ gcc_tests =					\
   task-errors.c					\
   scalar-tasks.c				\
   pointer-tasks.c				\
-  no-initialize.c
+  no-initialize.c				\
+  shutdown-errors.c
 
 dist_noinst_HEADERS = lib.h
 

+ 3 - 0
gcc-plugin/tests/base.c

@@ -85,5 +85,8 @@ main (int argc, char *argv[])
 
   assert (tasks_submitted == 9);
 
+#pragma starpu shutdown
+  assert (initialized == 0);
+
   return EXIT_SUCCESS;
 }

+ 9 - 0
gcc-plugin/tests/lib.h

@@ -281,3 +281,12 @@ starpu_init (struct starpu_conf *config)
   initialized++;
   return 0;
 }
+
+
+/* Shutdown.  */
+
+void
+starpu_shutdown (void)
+{
+  initialized--;
+}

+ 23 - 0
gcc-plugin/tests/shutdown-errors.c

@@ -0,0 +1,23 @@
+/* GCC-StarPU
+   Copyright (C) 2011 Institut National de Recherche en Informatique et Automatique
+
+   GCC-StarPU is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   GCC-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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC-StarPU.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int
+main (int argc, char *argv[])
+{
+#pragma starpu initialize
+#pragma starpu shutdown foo bar /* (error "junk after") */
+  return 0;
+}