| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 | 
							- /* StarPU --- Runtime system for heterogeneous multicore architectures.
 
-  *
 
-  * Copyright (C) 2013, 2015 Université Bordeaux
 
-  *
 
-  * 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 <unistd.h>
 
- #include <starpu.h>
 
- #include <starpu_scheduler.h>
 
- #include "../helper.h"
 
- #ifdef STARPU_QUICK_CHECK
 
- #define NTASKS 10
 
- #else
 
- #define NTASKS 1000
 
- #endif
 
- /*
 
-  * Task1 must be executed before task0, even if task0 is submitted first.
 
-  * Applies to : all schedulers.
 
-  */
 
- void
 
- A(void *buffers[], void *args)
 
- {
 
- 	(void) buffers;
 
- 	(void) args;
 
- 	FPRINTF(stdout,"A");
 
- 	usleep(1000);
 
- }
 
- void
 
- B(void *buffers[], void *args)
 
- {
 
- 	(void) buffers;
 
- 	(void) args;
 
- 	FPRINTF(stdout,"B");
 
- 	usleep(1000);
 
- }
 
- static int
 
- run(struct starpu_sched_policy *policy)
 
- {
 
- 	int ret;
 
- 	struct starpu_conf conf;
 
- 	int i;
 
- 	starpu_conf_init(&conf);
 
- 	conf.sched_policy = policy;
 
- 	ret = starpu_init(&conf);
 
- 	if (ret != 0)
 
- 		exit(STARPU_TEST_SKIPPED);
 
- 	starpu_profiling_status_set(1);
 
- 	struct starpu_codelet clA =
 
- 	{
 
- 		.cpu_funcs = {A},
 
- 		.cpu_funcs_name = {"A"},
 
- 		.opencl_funcs = {A},
 
- 		.cuda_funcs = {A},
 
- 		.nbuffers = 0
 
- 	};
 
- 	struct starpu_codelet clB =
 
- 	{
 
- 		.cpu_funcs = {B},
 
- 		.cpu_funcs_name = {"B"},
 
- 		.opencl_funcs = {B},
 
- 		.cuda_funcs = {B},
 
- 		.nbuffers = 0
 
- 	};
 
-         starpu_srand48(0);
 
- 	for (i = 0; i < NTASKS; i++)
 
- 	{
 
- 		struct starpu_task *task = starpu_task_create();
 
- 		if (((int)(starpu_drand48()*2))%2)
 
- 		{
 
- 			task->cl = &clA;
 
- 			task->priority=STARPU_MIN_PRIO;
 
- 		}
 
- 		else
 
- 		{
 
- 			task->cl = &clB;
 
- 			task->priority=STARPU_MAX_PRIO;
 
- 		}
 
- 		task->detach=1;
 
- 		ret = starpu_task_submit(task);
 
- 		if (ret == -ENODEV) goto enodev;
 
- 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 
- 	}
 
- 	starpu_task_wait_for_all();
 
- 	FPRINTF(stdout,"\n");
 
- 	starpu_shutdown();
 
- 	return 0;
 
- enodev:
 
- 	starpu_shutdown();
 
- 	return -ENODEV;
 
- }
 
- int
 
- main(void)
 
- {
 
- 	struct starpu_sched_policy **policies;
 
- 	struct starpu_sched_policy **policy;
 
- 	policies = starpu_sched_get_predefined_policies();
 
- 	for(policy=policies ; *policy!=NULL ; policy++)
 
- 	{
 
- 		int ret;
 
- 		FPRINTF(stderr, "Running with policy %s.\n", (*policy)->policy_name);
 
- 		ret = run(*policy);
 
- 		if (ret == -ENODEV)
 
- 			return STARPU_TEST_SKIPPED;
 
- 		if (ret == 1)
 
- 			return EXIT_FAILURE;
 
- 	}
 
- 	return EXIT_SUCCESS;
 
- }
 
 
  |