annotate example/word_count_test/WordCount.h @ 839:1001c4bea1a0 draft

if unnecessary
author Yutaka_Kinjyo
date Fri, 28 May 2010 03:24:52 +0900
parents 54f0180cea0f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
800
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
1 #include "TaskManager.h"
670
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 typedef struct wordCount {
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 struct wordCount *self;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 int size; // remaining file size
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 int division_size; // for each word count task
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 int division_out_size;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 int out_size;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 int task_num; // remaining task count
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 int task_blocks; // spawn task one at a time
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 int status_num;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 int task_spwaned;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 unsigned long long *o_data;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 unsigned long long *head_tail_flag;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 int out_task_num;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 int pad;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 char * file_mmap;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 HTaskPtr t_print;
800
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
19 int waiting;
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
20 int pipeline_count;
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
21 HTaskPtr *wait_list;
670
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 } WordCount;
87040ec6b5f6 add header.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
800
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
24 static inline HTask *
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
25 next_wait_task(WordCount *w, HTask *next)
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
26 {
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
27 w->waiting = (w->waiting+1)%w->pipeline_count;
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
28 HTask *wait = w->wait_list[w->waiting];
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
29 w->wait_list[w->waiting] = next;
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
30 return wait;
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
31 }
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
32
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
33 static inline void
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
34 set_pipeline_count(WordCount *w, TaskManager *m, int p)
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
35 {
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
36 w->pipeline_count = p;
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
37 w->wait_list = (HTaskPtr *)m->allocate(sizeof(HTaskPtr)*p);
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
38 bzero(w->wait_list,sizeof(HTaskPtr)*p);
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
39 }
54f0180cea0f run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 670
diff changeset
40