瀏覽代碼

doc/tutorial: add plugin version of hello world

Nathalie Furmento 12 年之前
父節點
當前提交
e85f57824f
共有 3 個文件被更改,包括 51 次插入2 次删除
  1. 4 1
      doc/tutorial/Makefile
  2. 4 1
      doc/tutorial/README
  3. 43 0
      doc/tutorial/hello_world_plugin.c

+ 4 - 1
doc/tutorial/Makefile

@@ -24,7 +24,7 @@ HAS_OPENCL	=	$(shell pkg-config --libs starpu-1.0 |grep -i opencl)
 %.o: %.cu
 	nvcc $(CFLAGS) $< -c
 
-TARGETS = hello_world vector_scal
+TARGETS = hello_world vector_scal hello_world_plugin
 
 all: $(TARGETS)
 
@@ -42,5 +42,8 @@ endif
 vector_scal: $(VECTOR_SCAL_PREREQUISITES)
 	$(VECTOR_SCAL_COMPILER) $(LDFLAGS) $^ -o $@
 
+hello_world_plugin: hello_world_plugin.c
+	$(CC) $(CFLAGS) -fplugin=`pkg-config starpu-1.0 --variable=gccplugin` $(LDFLAGS) $^ -o $@
+
 clean:
 	rm -f $(TARGETS) *.o

+ 4 - 1
doc/tutorial/README

@@ -1,7 +1,7 @@
 # StarPU --- Runtime system for heterogeneous multicore architectures.
 #
 # Copyright (C) 2009-2011  Université de Bordeaux 1
-# Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+# Copyright (C) 2010, 2011, 2013  Centre National de la Recherche Scientifique
 #
 # Redistribution  and  use  in  source and binary forms, with or without
 # modification,  are  permitted  provided  that the following conditions
@@ -44,3 +44,6 @@ Instructions on how to compile and run StarPU examples
 % STARPU_NCPU=0 ./vector_scal
 % STARPU_NCPU=0 STARPU_NCUDA=0 ./vector_scal
 
+% make hello_world_plugin
+% ./hello_world_plugin
+

+ 43 - 0
doc/tutorial/hello_world_plugin.c

@@ -0,0 +1,43 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2012  INRIA
+ *
+ * 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 <stdio.h>
+
+/* Task declaration. */
+static void my_task (int x) __attribute__ ((task));
+
+/* Definition of the CPU implementation of ‘my task’. */
+static void my_task (int x)
+{
+	printf ("Hello, world! With x = %d\n", x);
+}
+
+int main ()
+{
+/* Initialize StarPU. */
+#pragma starpu initialize
+
+/* Do an asynchronous call to ‘my task’. */
+	my_task (42);
+
+/* Wait for the call to complete. */
+#pragma starpu wait
+
+/* Terminate. */
+#pragma starpu shutdown
+	return 0;
+}
+