Mercurial > hg > Game > Cerium
changeset 2050:26dd777ba95d draft
add User API
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 28 Jan 2016 15:43:36 +0900 |
parents | 674ac7887dae |
children | b79a250b4f99 |
files | TaskManager/ManyCore/FileMapReduce.cc TaskManager/ManyCore/FileMapReduce.h |
diffstat | 2 files changed, 33 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/ManyCore/FileMapReduce.cc Thu Jan 28 14:54:25 2016 +0900 +++ b/TaskManager/ManyCore/FileMapReduce.cc Thu Jan 28 15:43:36 2016 +0900 @@ -7,7 +7,6 @@ #include <unistd.h> #include <sys/time.h> #include <sys/mman.h> -#include "SchedTask.h" /* ;TODO * PS3でCPU数が2以上の時に、あまりが計算されてない @@ -31,6 +30,11 @@ FileMapReduce::FileMapReduce(TaskManager *manager,const char* filename,int TASK_EXEC,int TASK_PRINT) { task_init(); + run_start(manager,filename); +} + +FileMapReduce::~FileMapReduce() { + } #ifdef __CERIUM_GPU__ @@ -46,6 +50,7 @@ SchedExternTask(Exec); SchedExternTask(Print); SchedExternTask(RUN_TASK_BLOCKS); + void task_init(void) { @@ -75,7 +80,7 @@ } static void -my_read(char *filename, WordCount *w, TaskManager *manager) +my_read(const char *filename, WordCount *w, TaskManager *manager) { long fd = w->fd; long r_filesize = w->read_filesize; @@ -105,7 +110,7 @@ } static void -my_mmap(char *filename, WordCount *w) +my_mmap(const char *filename, WordCount *w) { /*マッピングだよ!*/ int map = MAP_PRIVATE; @@ -310,7 +315,7 @@ static int division = 16; // in Kbyte static void -run_start(TaskManager *manager, char *filename) +run_start(TaskManager *manager, const char *filename) { long fd = (long)manager->allocate(sizeof(long)); struct stat *sb = (struct stat*)manager->allocate(sizeof(struct stat)); @@ -395,7 +400,7 @@ t_print = manager->create_task(TASK_PRINT, (memaddr)&w->self,sizeof(memaddr),0,0); - w->t_print = t_print; + w->t_print = t_print; for(int i=0;i<t_exec_num;i++) { /* Task を task_blocks ずつ起動する Task */ /* serialize されていると仮定する... */ @@ -408,9 +413,14 @@ } t_print->wait_for(t_exec); - // t_exec->iterate(4); t_exec->spawn(); } t_print->spawn(); } -/* end */ + +void +start() +{ + t_exec->spawn(); + t_print->spawn(); +}
--- a/TaskManager/ManyCore/FileMapReduce.h Thu Jan 28 14:54:25 2016 +0900 +++ b/TaskManager/ManyCore/FileMapReduce.h Thu Jan 28 15:43:36 2016 +0900 @@ -1,6 +1,8 @@ #include <sys/types.h> #include "TaskManager.h" +#include "SchedTask.h" +#include "HTask.h" typedef struct wordCount { struct wordCount *self; @@ -55,6 +57,20 @@ } st_mmap_t; class FileMapReduce { +public: + /* constructor */ FileMapReduce(TaskManager *manager,const char* filename,int TASK_EXEC,int TASK_PRINT); + ~FileMapReduce(); + + /* User API */ + static void run_start(TaskManager *manager, const char *filename); void start(); + +private: + static void my_read(const char *filename, WordCount *w, TaskManager *manager); + static void my_mmap(const char *filename, WordCount *w); + + /* variable */ + HTaskPtr t_exec; + HTaskPtr t_print; };