瀏覽代碼

tests/perfmodels: add testcase to test memory is properly cleaned on
shutdown (specifically when setting a cost function for a model which
is not going to be used by the application)

Nathalie Furmento 10 年之前
父節點
當前提交
034274135d
共有 2 個文件被更改,包括 65 次插入0 次删除
  1. 1 0
      tests/Makefile.am
  2. 64 0
      tests/perfmodels/memory.c

+ 1 - 0
tests/Makefile.am

@@ -234,6 +234,7 @@ noinst_PROGRAMS =				\
 	perfmodels/user_base			\
 	perfmodels/valid_model			\
 	perfmodels/value_nan			\
+	perfmodels/memory			\
 	sched_policies/data_locality            \
 	sched_policies/execute_all_tasks        \
 	sched_policies/prio        		\

+ 64 - 0
tests/perfmodels/memory.c

@@ -0,0 +1,64 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 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
+ * 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 <config.h>
+#include <starpu.h>
+#include <core/perfmodel/perfmodel.h>
+#include "../helper.h"
+
+void func(void *descr[], void *arg)
+{
+}
+
+static struct starpu_perfmodel my_model =
+{
+	.type = STARPU_HISTORY_BASED,
+	.symbol = "my_model",
+};
+
+static struct starpu_codelet my_codelet =
+{
+	.cpu_funcs = {func, NULL},
+	.model = &my_model
+};
+
+double cuda_cost_function(struct starpu_task *t, struct starpu_perfmodel_arch *a, unsigned i)
+{
+	t;
+	a;
+	return (double)i;
+}
+
+int main(int argc, char **argv)
+{
+	int ret;
+
+	ret = starpu_init(NULL);
+	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
+	starpu_perfmodel_init(NULL, &my_model);
+	starpu_perfmodel_set_per_devices_cost_function(&my_model, 0, cuda_cost_function, STARPU_CUDA_WORKER, 0, 1, -1);
+
+	ret = starpu_task_insert(&my_codelet, 0);
+	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
+
+	starpu_task_wait_for_all();
+	starpu_shutdown();
+
+	return EXIT_SUCCESS;
+}