Mercurial > hg > Members > kono > Cerium
changeset 297:f8006660a45c
start task config
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 07 Jun 2009 13:22:58 +0900 |
parents | b6d04c2bc758 |
children | 58fd16298954 |
files | TaskManager/Cell/spe/CellScheduler.cc TaskManager/kernel/ppe/HTask.cc bin/cerium example/HelloWorld/Func.h example/task_config/Changes include/TaskManager/TaskManager.h |
diffstat | 6 files changed, 230 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Cell/spe/CellScheduler.cc Sat Jun 06 01:53:29 2009 +0900 +++ b/TaskManager/Cell/spe/CellScheduler.cc Sun Jun 07 13:22:58 2009 +0900 @@ -6,7 +6,7 @@ // ユーザプログラムで定義 // なんだけど、それは微妙じゃね? -extern void task_init(void); +// extern void task_init(void); void CellScheduler::init_impl(void) @@ -15,7 +15,8 @@ mainMemNum = 0; - task_init(); + // task_init(); User 側で既に呼んでいる... + // Fifo では呼んでないし... } void*
--- a/TaskManager/kernel/ppe/HTask.cc Sat Jun 06 01:53:29 2009 +0900 +++ b/TaskManager/kernel/ppe/HTask.cc Sun Jun 07 13:22:58 2009 +0900 @@ -4,14 +4,14 @@ /*! - manager->set_task_depend(task1, task2); // task2 は task1 の終了を待つ + manager->set_task_depend(task1, task2); // task2 task1 腟篋緇 - ってやるより + c task2->set_depend(task1); - ってやったほうがわかりやすいよねー的な話し合いで - 下のようなAPIを作りました + cc祉主荅宴 + 筝API篏障 */ void @@ -21,12 +21,12 @@ } /*! - @brief この Task が待ち合わせする Task を指定する - @param[in] master この Task が終了待ち合わせをする相手の Task + @brief Task 緇≦ Task 絎 + @param[in] master Task 腟篋緇≦御 Task - 繰り返し使用する事で複数の Task を待ち合わせする事ができる。 + 膵違菴篏睡篋ц違 Task 緇≦篋с - wait_for している Task の入力バッファにこの Task から書き込みできる機能があると良い + wait_for Task ュ< Task 吾莨若帥с罘純 */ void
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/cerium Sun Jun 07 13:22:58 2009 +0900 @@ -0,0 +1,206 @@ +#!/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 +
--- a/example/HelloWorld/Func.h Sat Jun 06 01:53:29 2009 +0900 +++ b/example/HelloWorld/Func.h Sun Jun 07 13:22:58 2009 +0900 @@ -3,4 +3,3 @@ RUN_FINISH, }; -#define DATA_NUM 12