Mercurial > hg > Members > kono > Cerium
view bin/cerium @ 297:f8006660a45c
start task config
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 07 Jun 2009 13:22:58 +0900 |
parents | |
children | 7839cb3e928f |
line wrap: on
line source
#!/usr/bin/perl -w use strict; my $command = shift; my $main = "main.cc"; my $task_config = "tasks.xml"; if ($command =~ /init/) { &init; } elsif ($command =~ /make/) { &make; } elsif ($command =~ /help/) { &help; } else { &help; } exit 0; sub help { print "$0 init ... initialize cerium application\n"; } sub init { # setup initial cerium configuration mkdir "Task"; if (! -e $main ) &make_main; if (! -e $task_config ) &make_task_config; } sub make_main { open(F,">$main") or die("Can't write $main\n"); print F <<"EOFEOF"; #include <stdio.h> #include <stdlib.h> #include <string.h> #include "TaskManager.h" #include "Func.h" extern void task_init(void); const char *usr_help_str = "Usage: ./main [-cpu spe_num] [-count N]\n\ -cpu Number of SPE (default 1) \n\"; int init(int argc, char **argv) { for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-count") == 0) { count = atoi(argv[++i]); } } return 0; } void hello_init(void) { HTask *hello; for (int i = 0; i < count; i++) { /** * Create Task * create_task(Task ID); */ hello = manager->create_task(HELLO_TASK); /** * Select CPU * SPE_0, SPE_1, SPE_2, SPE_3, SPE_4, SPE_5, SPE_ANY * if you do not call this, execute PPE. */ hello->set_cpu(SPE_ANY); /** * Set 32bits parameter * add_param(32bit parameter); */ hello->add_param(i); hello->spawn(); } } int TMmain(int argc, char *argv[]) { if (init(argc, argv) < 0) { return -1; } task_init(); init(); return 0; } EOFEOF } } else { &help; } exit 0; sub help { print "$0 init ... initialize cerium application\n"; } sub init { # setup initial cerium configuration mkdir "Task"; if (! -e $main ) &make_main; if (! -e $task_config ) &make_task_config; } sub make_main { open(F,">$main") or die("Can't write $main\n"); print F <<"EOFEOF"; #include <stdio.h> #include <stdlib.h> #include <string.h> #include "TaskManager.h" #include "Func.h" extern void task_init(void); const char *usr_help_str = "Usage: ./main [-cpu spe_num] [-count N]\n\ -cpu Number of SPE (default 1) \n\"; int init(int argc, char **argv) { for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-count") == 0) { count = atoi(argv[++i]); } } return 0; } void hello_init(void) { HTask *hello; for (int i = 0; i < count; i++) { /** * Create Task * create_task(Task ID); */ hello = manager->create_task(HELLO_TASK); /** * Select CPU * SPE_0, SPE_1, SPE_2, SPE_3, SPE_4, SPE_5, SPE_ANY * if you do not call this, execute PPE. */ hello->set_cpu(SPE_ANY); /** * Set 32bits parameter * add_param(32bit parameter); */ hello->add_param(i); hello->spawn(); } } int TMmain(int argc, char *argv[]) { if (init(argc, argv) < 0) { return -1; } task_init(); init(); return 0; } EOFEOF } sub make { } __END__ =head1 NAME cerium -- Cerium task manager configuration manager =head1 SYNOPSIS cerium init cerium make cerium help =head1 DESCRIPTION cerium init =cut