Browse Source

examples: new example just creating and deleting sched contexts

Nathalie Furmento 6 years ago
parent
commit
faabee7892
2 changed files with 45 additions and 0 deletions
  1. 1 0
      examples/Makefile.am
  2. 44 0
      examples/sched_ctx/sched_ctx_delete.c

+ 1 - 0
examples/Makefile.am

@@ -248,6 +248,7 @@ STARPU_EXAMPLES +=				\
 	scheduler/heteroprio_test		\
 	sched_ctx/sched_ctx			\
 	sched_ctx/sched_ctx_empty		\
+	sched_ctx/sched_ctx_delete		\
 	sched_ctx/two_cpu_contexts		\
 	sched_ctx/dummy_sched_with_ctx		\
 	worker_collections/worker_tree_example  \

+ 44 - 0
examples/sched_ctx/sched_ctx_delete.c

@@ -0,0 +1,44 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2018                                     CNRS
+ *
+ * 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>
+#include <stdlib.h>
+
+int main(void)
+{
+	int ret;
+	int nprocs = 0;
+	int procs[STARPU_NMAXWORKERS];
+	unsigned sched_ctx1, sched_ctx2;
+
+	ret = starpu_init(NULL);
+	if (ret == -ENODEV) return 77;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
+	nprocs = starpu_worker_get_count_by_type(STARPU_ANY_WORKER);
+	starpu_worker_get_ids_by_type(STARPU_ANY_WORKER, procs, nprocs);
+
+	sched_ctx1 = starpu_sched_ctx_create(procs, nprocs, "ctx1", 0);
+	sched_ctx2 = starpu_sched_ctx_create(procs, nprocs, "ctx2", 0);
+
+	starpu_sched_ctx_set_inheritor(sched_ctx2, sched_ctx1);
+
+	starpu_sched_ctx_delete(sched_ctx1);
+	starpu_sched_ctx_delete(sched_ctx2);
+
+	starpu_shutdown();
+	return 0;
+}