view example/Null/main.cc @ 1439:20e935f170c1 draft

add Makefile for gpu
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Sat, 07 Apr 2012 11:43:05 +0900
parents e38a4f3e238d
children
line wrap: on
line source

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "TaskManager.h"
#include "Func.h"

extern void task_init(void);
extern TaskManager *manager;

static long task_num = 10;

/* help文章 */
const char *usr_help_str = "Usage: ./null [-cpu spe_num] [-num N]\n\
							-cpu    Number of SPE (default 1) \n\
							-num 	Task Num (default 10)";

	int
init(int argc, char **argv)
{
	for (int i = 1; argv[i]; ++i) {
		if (strcmp(argv[i], "-num") == 0) {
			task_num = atoi(argv[++i]);
		}
	}
	return 0;
}

	void
null_init(TaskManager *manager)
{

	// Create Task
	for (long i = 0; i < task_num; i++) {
		HTask *null = manager->create_task(NullTask);
		null->set_cpu(SPE_ANY);
		null->spawn();
	}

}

	int
TMmain(TaskManager *manager, int argc, char *argv[])
{
	if (init(argc, argv) < 0) {
		return -1;
	}

	task_init();
	null_init(manager);

	return 0;
}