|
@@ -0,0 +1,108 @@
|
|
|
|
+
|
|
|
|
+ *
|
|
|
|
+ * Copyright (C) 2009, 2010-2011 Université de Bordeaux 1
|
|
|
|
+ * Copyright (C) 2010, 2011, 2012 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 <starpu.h>
|
|
|
|
+#include <pthread.h>
|
|
|
|
+#include <sys/time.h>
|
|
|
|
+
|
|
|
|
+static unsigned niter = 50;
|
|
|
|
+#define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
|
|
|
|
+
|
|
|
|
+#warning todo: fix cuda and opencl
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void cpu_codelet(void *descr[], __attribute__ ((unused)) void *_args)
|
|
|
|
+{
|
|
|
|
+ float *val = (float *)STARPU_VECTOR_GET_PTR(descr[0]);
|
|
|
|
+
|
|
|
|
+ val[0] += 1.0f; val[1] += 1.0f;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int main(int argc, char **argv)
|
|
|
|
+{
|
|
|
|
+ int ret = 0;
|
|
|
|
+
|
|
|
|
+ ret = starpu_init(NULL);
|
|
|
|
+ STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
|
|
|
|
+
|
|
|
|
+ float float_array[4] __attribute__ ((aligned (16))) = { 0.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
+
|
|
|
|
+ starpu_data_handle_t float_array_handle;
|
|
|
|
+ starpu_vector_data_register(&float_array_handle, 0 ,
|
|
|
|
+ (uintptr_t)&float_array, 4, sizeof(float));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ struct starpu_codelet cl;
|
|
|
|
+ starpu_codelet_init(&cl);
|
|
|
|
+ cl.where = STARPU_CPU;
|
|
|
|
+ cl.cpu_funcs[0] = cpu_codelet;
|
|
|
|
+ cl.cpu_funcs[1] = NULL;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ cl.nbuffers = 1;
|
|
|
|
+ cl.modes[0] = STARPU_RW;
|
|
|
|
+
|
|
|
|
+ unsigned i;
|
|
|
|
+ for (i = 0; i < niter; i++)
|
|
|
|
+ {
|
|
|
|
+ struct starpu_task *task = starpu_task_create();
|
|
|
|
+ task->cl = &cl;
|
|
|
|
+ task->handles[0] = float_array_handle;
|
|
|
|
+
|
|
|
|
+ ret = starpu_task_submit(task);
|
|
|
|
+ if (STARPU_UNLIKELY(ret == -ENODEV))
|
|
|
|
+ {
|
|
|
|
+ FPRINTF(stderr, "No worker may execute this task\n");
|
|
|
|
+ exit(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ starpu_task_wait_for_all();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ starpu_data_unregister(float_array_handle);
|
|
|
|
+
|
|
|
|
+ FPRINTF(stderr, "array -> %f, %f, %f, %f\n", float_array[0],
|
|
|
|
+ float_array[1], float_array[2], float_array[3]);
|
|
|
|
+
|
|
|
|
+ if (float_array[0] != niter || float_array[0] != float_array[1] + float_array[2] + float_array[3])
|
|
|
|
+ {
|
|
|
|
+ FPRINTF(stderr, "Incorrect result\n");
|
|
|
|
+ ret = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ starpu_shutdown();
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|