int main(int argc, char **argv)
{
	int ret;
	unsigned loop, nloops=NLOOPS;

	ret = starpu_initialize(NULL, &argc, &argv);
	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");

	struct starpu_task *taskA, *taskB;

	for (loop = 0; loop < nloops; loop++)
	{
		taskA = create_dummy_task();
		taskB = create_dummy_task();

		/* By default, dynamically allocated tasks are destroyed at
		 * termination, we cannot declare a dependency on something
		 * that does not exist anymore. */
		taskA->destroy = 0;
		taskA->synchronous = 1;

		ret = starpu_task_submit(taskA);
		if (ret == -ENODEV) goto enodev;
		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");

		starpu_task_declare_deps_array(taskB, 1, &taskA);

		taskB->synchronous = 1;

		ret = starpu_task_submit(taskB);
		if (ret == -ENODEV) goto enodev;
		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");

		starpu_task_destroy(taskA);
	}

	ret = starpu_task_wait_for_all();
	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");

	starpu_shutdown();

	return EXIT_SUCCESS;

enodev:
	fprintf(stderr, "WARNING: No one can execute this task\n");
	/* yes, we do not perform the computation but we did detect that no one
 	 * could perform the kernel, so this is not an error from StarPU */
	starpu_shutdown();
	return STARPU_TEST_SKIPPED;
}
Ejemplo n.º 2
0
int main(int argc, char **argv)
{
	double timing;
	struct timeval start;
	struct timeval end;

	parse_args(argc, argv);

	starpu_init(NULL);

	fprintf(stderr, "#tasks : %d\n", ntasks);

	gettimeofday(&start, NULL);

	unsigned i;
	for (i = 0; i < ntasks; i++)
	{
		struct starpu_task *task = starpu_task_create();

		task->cl = &dummy_codelet;
		task->cl_arg = NULL;
		task->callback_func = NULL;
		task->callback_arg = NULL;

		task->destroy = 0;
		
      starpu_event event;
		int ret = starpu_task_submit(task, &event);
		STARPU_ASSERT(!ret);

		ret = starpu_event_wait(event);
		STARPU_ASSERT(!ret);

      starpu_event_release(event);

		starpu_task_destroy(task);
	}

	gettimeofday(&end, NULL);

	timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec));

	fprintf(stderr, "Total: %lf secs\n", timing/1000000);
	fprintf(stderr, "Per task: %lf usecs\n", timing/ntasks);

	starpu_shutdown();

	return 0;
}
int
main(int argc, char **argv)
{
	int ret;
	struct starpu_task *task;

	ret = starpu_initialize(NULL, &argc, &argv);
	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;

	task = starpu_task_create();
	task->cl = &cl;
	task->destroy = 0;
	task->sched_ctx = 0;

	cl.can_execute = NULL;
	ret = _starpu_worker_exists(task);
	if (!ret)
	{
		FPRINTF(stderr, "failure with can_execute=NULL\n");
		return EXIT_FAILURE;
	}

	cl.can_execute = can_always_execute;
	ret = _starpu_worker_exists(task);
	if (!ret)
	{
		FPRINTF(stderr, "failure with can_always_execute\n");
		return EXIT_FAILURE;
	}

	cl.can_execute = can_never_execute;
	ret = _starpu_worker_exists(task);
	if (ret)
	{
		FPRINTF(stderr, "failure with can_never_execute\n");
		return EXIT_FAILURE;
	}

	starpu_task_destroy(task);
	starpu_shutdown();

	return EXIT_SUCCESS;
}