Mercurial > hg > Game > Cerium
annotate example/word_count/main.cc @ 2044:66aa91f6f4df draft
merge
author | Shin,ichi Uehara |
---|---|
date | Wed, 25 Mar 2015 19:13:56 +0900 |
parents | 630eef931336 |
children | 476fc75a5e17 |
rev | line source |
---|---|
1584 | 1 #include <stdio.h> |
393 | 2 #include <stdlib.h> |
3 #include <string.h> | |
4 #include <sys/mman.h> | |
5 #include <sys/types.h> | |
6 #include <sys/stat.h> | |
7 #include <fcntl.h> | |
8 #include <unistd.h> | |
1544
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
9 #include <sys/time.h> |
393 | 10 #include "TaskManager.h" |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
11 #include "SchedTask.h" |
393 | 12 #include "Func.h" |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
13 #include "WordCount.h" |
393 | 14 |
1268 | 15 /* ;TODO |
16 * PS3でCPU数が2以上の時に、あまりが計算されてない | |
17 */ | |
18 | |
400 | 19 extern void task_init(); |
1544
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
20 void TMend(TaskManager *); |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
21 static double st_time; |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
22 static double ed_time; |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
23 int all = 0; |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
24 int use_task_array = 1; |
1039
e8ef7f5f22f6
add TaskCreater test funciton..
yutaka@localhost.localdomain
parents:
1021
diff
changeset
|
25 int use_task_creater = 0; |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
26 int use_compat = 0; |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
27 int use_iterate = 0; |
1963
6988e5478a8c
fix CudaScheduler
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1962
diff
changeset
|
28 int array_task_num = 11; |
970
1a4849b2acad
change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
968
diff
changeset
|
29 int spe_num = 1; |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
30 int read_type = MY_MMAP; |
1991 | 31 int t_exec_num = 4; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
32 CPU_TYPE spe_cpu = SPE_ANY; |
1988 | 33 CPU_TYPE read_spe_cpu = IO_0; |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
34 |
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
35 const char *usr_help_str = "Usage: ./word_count [-a -c -s] [-cpu spe_num] [-g] [-file filename] [-br]\n"; |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
36 |
1544
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
37 static double |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
38 getTime() { |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
39 struct timeval tv; |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
40 gettimeofday(&tv, NULL); |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
41 return tv.tv_sec + (double)tv.tv_usec*1e-6; |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
42 } |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
43 |
393 | 44 typedef struct { |
45 caddr_t file_mmap; | |
46 off_t size; | |
47 } st_mmap_t; | |
48 | |
2004 | 49 /*与えられたsizeをfix_byte_sizeの倍数にする(丸め込むっていうのかな?)*/ |
50 static int | |
51 fix_byte(int size,int fix_byte_size) | |
52 { | |
53 size = (size/fix_byte_size)*fix_byte_size + ((size%fix_byte_size)!= 0)*fix_byte_size; | |
54 | |
55 return size; | |
56 } | |
57 | |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
58 static void |
1996
9657434c21a4
change memory allocate function malloc() to manager->allocate in my_read
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1994
diff
changeset
|
59 my_read(char *filename, WordCount *w, TaskManager *manager) |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
60 { |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
61 long fd = w->fd; |
1998 | 62 long r_filesize = w->read_filesize; |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
63 |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
64 if ((fd=open(filename,O_RDONLY,0666))==0) { |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
65 fprintf(stderr,"can't open %s\n",filename); |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
66 } |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
67 |
1996
9657434c21a4
change memory allocate function malloc() to manager->allocate in my_read
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1994
diff
changeset
|
68 w->file_mmap = (char*)manager->allocate(w->read_filesize); |
1998 | 69 |
70 long one_read_size = 1024 * 1024 * 1024; // 1GB | |
71 | |
72 for (int i = 0; 0 < r_filesize; i++) { | |
73 if (r_filesize > one_read_size) { | |
74 pread(fd, w->file_mmap + i*one_read_size, one_read_size,i*one_read_size); | |
75 }else if ((r_filesize < one_read_size) && (r_filesize != 0)) { | |
76 pread(fd, w->file_mmap + i*one_read_size, r_filesize,i*one_read_size); | |
77 } | |
78 r_filesize -= one_read_size; | |
1997 | 79 } |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
80 |
1987
1420e4521b4a
implement my_read in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1986
diff
changeset
|
81 if (w->file_mmap == (caddr_t)-1) { |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
82 fprintf(stderr,"Can't mmap file\n"); |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
83 perror(NULL); |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
84 exit(0); |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
85 } |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
86 |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
87 return ; |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
88 } |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
89 |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
90 static void |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
91 my_mmap(char *filename, WordCount *w) |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
92 { |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
93 /*マッピングだよ!*/ |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
94 int map = MAP_PRIVATE; |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
95 st_mmap_t st_mmap; |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
96 struct stat sb; |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
97 long fd = w->fd; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
98 |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
99 if ((fd=open(filename,O_RDONLY,0666))==0) { |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
100 fprintf(stderr,"can't open %s\n",filename); |
393 | 101 } |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
102 |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
103 if (fstat(fd,&sb)) { |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
104 fprintf(stderr,"can't fstat %s\n",filename); |
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
105 } |
1910
b7b528e9ec5e
Implement divide read in word_count ( but cannot running )
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1897
diff
changeset
|
106 |
2004 | 107 st_mmap.size = fix_byte(sb.st_size,4096); |
108 | |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
109 //madvise(w->file_mmap, w->read_filesize, POSIX_MADV_NORMAL); |
2004 | 110 w->file_mmap = (char*)mmap(NULL,st_mmap.size,PROT_WRITE|PROT_READ,map,fd,(off_t)0); |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
111 |
393 | 112 if (st_mmap.file_mmap == (caddr_t)-1) { |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
113 fprintf(stderr,"Can't mmap file\n"); |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
114 perror(NULL); |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
115 exit(0); |
393 | 116 } |
117 | |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
118 return ; |
1910
b7b528e9ec5e
Implement divide read in word_count ( but cannot running )
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1897
diff
changeset
|
119 } |
393 | 120 |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
121 static void |
1984
7bea670cdba0
divide read flag change enum type
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1981
diff
changeset
|
122 run_tasks(SchedTask *manager, WordCount *w, int task_count, HTaskPtr t_read, HTaskPtr t_next, int size) |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
123 { |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
124 |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
125 if (task_count < array_task_num) { |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
126 array_task_num = task_count; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
127 if (task_count<=0) return; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
128 } |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
129 for (int i = 0; i < task_count; i += array_task_num) { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
130 HTask *task_array; |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
131 if (use_task_array) { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
132 int task_num = (w->size+size-1)/size; |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
133 if (task_num>array_task_num) task_num = array_task_num; |
1836
56692133c5fb
success run wordcount with gpu, but result is wrong
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1835
diff
changeset
|
134 task_array = manager->create_task_array(TASK_EXEC,task_num,1,1,1); |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
135 if (t_read != 0) task_array->wait_for(t_read); |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
136 if (!all) { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
137 t_next->wait_for(task_array); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
138 } else { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
139 w->t_print->wait_for(task_array); |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
140 } |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
141 } |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
142 |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
143 Task *t_exec = 0; |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
144 HTask *h_exec = 0; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
145 for (int j = 0; j < array_task_num; j++) { |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
146 int i = w->task_spawned++; |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
147 if (w->size < size) size = w->size; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
148 if (size==0) break; |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
149 if (use_task_array) { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
150 t_exec = task_array->next_task_array(TASK_EXEC,t_exec); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
151 t_exec->set_inData(0,w->file_mmap + i*w->division_size, size); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
152 t_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size); |
1836
56692133c5fb
success run wordcount with gpu, but result is wrong
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1835
diff
changeset
|
153 t_exec->set_param(0,(long)size); |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
154 } else if (use_compat) { |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
155 h_exec = manager->create_task(TASK_EXEC); |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
156 h_exec->set_inData(0,w->file_mmap + i*w->division_size, size); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
157 h_exec->set_outData(0,w->o_data + i*w->out_size, w->division_out_size); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
158 |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
159 t_next->wait_for(h_exec); |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
160 |
1737 | 161 h_exec->set_cpu(spe_cpu); |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
162 h_exec->spawn(); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
163 } else if (use_iterate) { |
1991 | 164 array_task_num = w->task_num; |
165 use_iterate = 0; | |
166 use_compat = 1; | |
167 | |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
168 w->size -= size*array_task_num; |
1991 | 169 if(w->size < 0) { |
170 array_task_num -= 1; | |
171 w->size += size; | |
172 } | |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
173 h_exec = manager->create_task(TASK_EXEC_DATA_PARALLEL); |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
174 h_exec->flip(); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
175 h_exec->set_inData(0,w->file_mmap,w->file_size); |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
176 h_exec->set_inData(1,w->o_data,w->out_size_); |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
177 h_exec->set_outData(0,w->file_mmap,w->file_size); |
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
178 h_exec->set_outData(1,w->o_data,w->out_size_); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
179 h_exec->set_param(0,(long)i); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
180 h_exec->set_param(1,(long)w->division_size); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
181 h_exec->set_param(2,(long)size); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
182 h_exec->set_param(3,(long)w->out_size); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
183 |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
184 t_next->wait_for(h_exec); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
185 h_exec->set_cpu(spe_cpu); |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
186 h_exec->iterate(array_task_num); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
187 |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
188 w->task_num -= array_task_num; |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
189 w->task_spawned += array_task_num-1; |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
190 |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
191 break; |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
192 } else { |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
193 h_exec = manager->create_task(TASK_EXEC, |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
194 (memaddr)(w->file_mmap + i*w->division_size), size, |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
195 (memaddr)(w->o_data + i*w->out_size), w->division_out_size); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
196 t_next->wait_for(h_exec); |
1737 | 197 h_exec->set_cpu(spe_cpu); |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
198 h_exec->spawn(); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
199 } |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
200 w->size -= size; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
201 w->task_num--; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
202 } |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
203 if (use_task_array) { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
204 task_array->spawn_task_array(t_exec->next()); |
1737 | 205 task_array->set_cpu(spe_cpu); |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
206 task_array->spawn(); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
207 } else { |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
208 //if (!all) t_next->wait_for(h_exec); |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
209 } |
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
210 } |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
211 } |
393 | 212 |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
213 /** |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
214 * このTaskは、PPE上で実行されるので、並列に実行されることはない |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
215 * 二つ実行されていて、Task が足りなくなることがないようにしている。 |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
216 */ |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
217 |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
218 SchedDefineTask1(BREAD_RUN_TASK_BLOCKS,bread_run16); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
219 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
220 static int |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
221 bread_run16(SchedTask *manager, void *in, void *out) |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
222 { |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
223 WordCount *w = *(WordCount **)in; |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
224 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
225 HTaskPtr t_read = manager->create_task(READ_TASK); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
226 w->t_print->wait_for(t_read); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
227 t_read->set_cpu(read_spe_cpu); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
228 t_read->set_param(0,w->fd); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
229 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
230 if (w->task_num < w->task_blocks) { |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
231 t_read->set_param(1,w->task_spawned*w->division_size); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
232 t_read->set_outData(0, w->file_mmap + w->task_spawned * w->division_size, w->task_blocks * w->division_size); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
233 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
234 // last case |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
235 while (w->size >= w->division_size) |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
236 run_tasks(manager,w,w->task_num,t_read,w->t_print, w->division_size); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
237 // remaining data |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
238 while (w->size>0) |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
239 run_tasks(manager,w,1,t_read,w->t_print, w->division_size); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
240 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
241 t_read->set_param(2,w->task_spawned*w->division_size); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
242 t_read->spawn(); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
243 } else { |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
244 HTaskPtr t_next = manager->create_task(BREAD_RUN_TASK_BLOCKS, |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
245 (memaddr)&w->self,sizeof(memaddr),0,0); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
246 w->t_print->wait_for(t_next); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
247 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
248 t_read->set_param(1,w->task_spawned*w->division_size); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
249 t_read->set_outData(0, w->file_mmap + w->task_spawned * w->division_size, w->task_blocks * w->division_size); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
250 |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
251 run_tasks(manager,w, w->task_blocks, t_read, t_next, w->division_size); |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
252 |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
253 t_read->set_param(2,w->task_spawned*w->division_size); |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
254 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
255 t_read->spawn(); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
256 t_next->spawn(); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
257 } |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
258 return 0; |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
259 } |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
260 |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
261 SchedDefineTask1(RUN_TASK_BLOCKS,run16); |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
262 |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
263 static int |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
264 run16(SchedTask *manager, void *in, void *out) |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
265 { |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
266 WordCount *w = *(WordCount **)in; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
267 |
1991 | 268 if(use_iterate) { |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
269 run_tasks(manager, w, w->task_num, 0, w->t_print, w->division_size); |
1897
606f6f6cb784
run wordcount used iterate
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1894
diff
changeset
|
270 } else if (w->task_num < w->task_blocks) { |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
271 // last case |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
272 while (w->size >= w->division_size) |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
273 run_tasks(manager,w,w->task_num,0,w->t_print, w->division_size); |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
274 // remaining data |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
275 while (w->size>0) |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
276 run_tasks(manager,w,1,0, w->t_print, w->size); |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
277 // printf("run16 last %d\n",w->task_num); |
949 | 278 } else { |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
279 HTaskPtr t_next = manager->create_task(RUN_TASK_BLOCKS, |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
280 (memaddr)&w->self,sizeof(memaddr),0,0); |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
281 w->t_print->wait_for(t_next); |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
282 |
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
283 run_tasks(manager,w, w->task_blocks,0, t_next, w->division_size); |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
284 |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
285 t_next->spawn(); |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
286 // printf("run16 next %d\n",w->task_num); |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
287 } |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
288 return 0; |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
289 } |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
290 |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
291 static int blocks = 48; |
1123 | 292 //static int blocks = 31 * 6 * 24; |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
293 static int division = 16; // in Kbyte |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
294 |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
295 static void |
400 | 296 run_start(TaskManager *manager, char *filename) |
393 | 297 { |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
298 long fd = (long)manager->allocate(sizeof(long)); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
299 struct stat *sb = (struct stat*)manager->allocate(sizeof(struct stat)); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
300 HTaskPtr t_exec; |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
301 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
302 if ((fd=open(filename,O_RDONLY,0666))==0) { |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
303 fprintf(stderr,"can't open %s\n",filename); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
304 return ; |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
305 } |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
306 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
307 if (fstat(fd,sb)) { |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
308 fprintf(stderr,"can't fstat %s\n",filename); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
309 return ; |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
310 } |
393 | 311 |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
312 WordCountPtr w = (WordCountPtr)manager->allocate(sizeof(WordCount)); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
313 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
314 w->self = w; |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
315 w->fd = fd; |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
316 w->read_filesize = sb->st_size; |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
317 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
318 |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
319 if (read_type == BLOCKED_READ) { |
1998 | 320 printf("[blocked read mode]\n"); |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
321 w->file_mmap = (char*)manager->allocate(w->read_filesize); |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
322 }else if (read_type == MY_READ) { |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
323 printf("[single read mode]\n"); |
1996
9657434c21a4
change memory allocate function malloc() to manager->allocate in my_read
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1994
diff
changeset
|
324 my_read(filename, w, manager); |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
325 }else if(read_type == MY_MMAP) { |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
326 printf("[mmap mode]\n"); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
327 my_mmap(filename, w); |
2019
630eef931336
add read type flag " BLOCKED_MMAP "
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
2004
diff
changeset
|
328 }else if(read_type == BLOCKED_MMAP) { |
630eef931336
add read type flag " BLOCKED_MMAP "
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
2004
diff
changeset
|
329 printf("[blocked mmap mode]\n"); |
630eef931336
add read type flag " BLOCKED_MMAP "
Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp>
parents:
2004
diff
changeset
|
330 my_mmap(filename, w); |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
331 } |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
332 |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
333 HTaskPtr t_print; |
393 | 334 |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
335 //w->task_blocks = blocks; |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
336 w->self = w; |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
337 w->task_spawned = 0; |
393 | 338 |
1981 | 339 w->size = w->file_size = w->read_filesize; |
949 | 340 printf("w %lx\n",(long)w); |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
341 |
393 | 342 /* 1task分のデータサイズ(byte) */ |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
343 if (w->size >= 1024*division) { |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
344 w->division_size = 1024 * division;/*16kbyte*/ |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
345 } else { |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
346 w->division_size = w->size; |
393 | 347 } |
348 | |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
349 printf("division_size %ld\n",w->division_size); |
393 | 350 |
351 /* "word num" and "line num" */ | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
352 w->status_num = 2; |
393 | 353 /* taskの数 */ |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
354 w->task_num = w->size / w->division_size; |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
355 w->task_num = w->task_num + (w->division_size*w->task_num < w->size); |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
356 int out_task_num = w->task_num; |
394 | 357 |
968 | 358 if(!all) { |
359 w->task_blocks = blocks; | |
360 } else { | |
361 w->task_blocks = w->task_num; | |
362 } | |
363 | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
364 w->out_task_num = out_task_num; |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
365 printf("task_num %ld\n",w->task_num); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
366 printf("out_task_num %ld\n",w->out_task_num); |
394 | 367 |
1007 | 368 /* out用のdivision_size. statusが2つなので、あわせて16byteになるように、long long(4byte)を使用 */ |
393 | 369 |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
370 w->division_out_size = sizeof(unsigned long long)*4; |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
371 int out_size = w->division_out_size*out_task_num; |
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
372 w->o_data = (unsigned long long *)manager->allocate(out_size); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
373 w->out_size_ = out_size; |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
374 w->out_size = 4; |
393 | 375 printf("out size %d\n",out_size); |
376 | |
377 /*各SPEの結果を合計して出力するタスク*/ | |
378 | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
379 t_print = manager->create_task(TASK_PRINT, |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1538
diff
changeset
|
380 (memaddr)&w->self,sizeof(memaddr),0,0); |
1913
53c074e60b08
restore some files
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1912
diff
changeset
|
381 w->t_print = t_print; |
1991 | 382 for(int i=0;i<t_exec_num;i++) { |
1783 | 383 /* Task を task_blocks ずつ起動する Task */ |
384 /* serialize されていると仮定する... */ | |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
385 if (read_type == BLOCKED_READ) { |
1979
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
386 t_exec = manager->create_task(BREAD_RUN_TASK_BLOCKS, |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
387 (memaddr)&w->self,sizeof(memaddr),0,0); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
388 }else { |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
389 t_exec = manager->create_task(RUN_TASK_BLOCKS, |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
390 (memaddr)&w->self,sizeof(memaddr),0,0); |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
391 } |
889472b0e6d5
implement blocked read (not running)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1969
diff
changeset
|
392 |
1783 | 393 t_print->wait_for(t_exec); |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
394 // t_exec->iterate(4); |
1783 | 395 t_exec->spawn(); |
396 } | |
393 | 397 t_print->spawn(); |
398 } | |
399 | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
400 static char* |
393 | 401 init(int argc, char **argv) |
402 { | |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
403 |
394 | 404 char *filename = 0; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
405 |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
406 for (int i = 1; argv[i]; ++i) { |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
407 if (strcmp(argv[i], "-file") == 0) { |
1679
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
408 filename = argv[i+1]; i++; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
409 } else if (strcmp(argv[i], "-division") == 0) { |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
410 division = atoi(argv[i+1]); |
1679
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
411 i++; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
412 } else if (strcmp(argv[i], "-block") == 0) { |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
413 blocks = atoi(argv[i+1]); |
1679
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
414 i++; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
415 } else if (strcmp(argv[i], "-a") == 0) { |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
416 // create task all at once |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
417 all = 1; |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
418 } else if (strcmp(argv[i], "-c") == 0) { |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
419 use_task_array = 0; |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
420 use_compat = 1; |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
421 } else if (strcmp(argv[i], "-s") == 0) { |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
422 use_task_array = 0; |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
423 use_compat = 0; |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
424 } else if (strcmp(argv[i], "-t") == 0) { |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
425 use_task_creater = 1; |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
426 use_task_array = 0; |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
427 use_compat = 0; |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
428 } else if (strcmp(argv[i], "-anum") == 0) { |
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
429 array_task_num = atoi(argv[i+1]); |
1679
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
430 i++; |
1894
b37dfbf3380d
fix GpuTaskManagerFactory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1870
diff
changeset
|
431 } else if (strcmp(argv[i], "-g") == 0) { |
1941
f19885ea776d
add wordcount for cuda. fix CudaScheduler. add makefile
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1913
diff
changeset
|
432 spe_cpu = GPU_0; |
1894
b37dfbf3380d
fix GpuTaskManagerFactory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1870
diff
changeset
|
433 } else if (strcmp(argv[i], "-any") == 0) { |
b37dfbf3380d
fix GpuTaskManagerFactory
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1870
diff
changeset
|
434 spe_cpu = ANY_ANY; |
1799
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
435 } else if (strcmp(argv[i], "-i") == 0) { |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
436 use_iterate = 1; |
d9122ca02431
Exec wordcount by Data Parallel
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1783
diff
changeset
|
437 use_task_array = 0; |
1991 | 438 t_exec_num = 1; |
1980
aa5fabf2d4b2
remove error and warning (not perform check)
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1979
diff
changeset
|
439 } else if (strcmp(argv[i], "-br") == 0) { |
1986
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
440 read_type = BLOCKED_READ; |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
441 } else if (strcmp(argv[i], "-r") == 0) { |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
442 read_type = MY_READ; |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
443 } |
c05e575da760
blocked read flag change enum tyoe in word_count
Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
parents:
1984
diff
changeset
|
444 /* else if (strcmp(argv[i], "-cpu") == 0) { |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
445 spe_num = atoi(argv[i+1]); |
1679
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
446 i++; |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
447 if (spe_num==0) spe_num = 1; |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
448 } else { |
1679
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
449 fprintf(stderr,"%s\n",usr_help_str); |
ff43dc274ec9
word_count fix for GPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1678
diff
changeset
|
450 exit (0); |
1688
705f09f646ac
remove spe_num roop
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1684
diff
changeset
|
451 }*/ |
393 | 452 } |
400 | 453 if (filename==0) { |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
454 puts(usr_help_str); |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
455 exit(1); |
400 | 456 } |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
457 |
393 | 458 return filename; |
459 } | |
460 | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
461 |
393 | 462 int |
400 | 463 TMmain(TaskManager *manager, int argc, char *argv[]) |
393 | 464 { |
465 | |
394 | 466 char *filename = 0; |
467 filename = init(argc, argv); | |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
468 |
393 | 469 if (filename < 0) { |
1538
fac06524090b
add gpu task wordcount. But not work print
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1351
diff
changeset
|
470 return -1; |
393 | 471 } |
472 | |
473 task_init(); | |
1988 | 474 st_time = getTime(); |
400 | 475 run_start(manager, filename); |
1544
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
476 manager->set_TMend(TMend); |
393 | 477 return 0; |
478 } | |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
479 |
1544
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
480 void |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
481 TMend(TaskManager *manager) |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
482 { |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
483 ed_time = getTime(); |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
484 printf("Time: %0.6f\n",ed_time-st_time); |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
485 } |
5c4e3f0d372a
many_task add task array
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1542
diff
changeset
|
486 |
946
852ed17d8af1
unify word count examples....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
797
diff
changeset
|
487 /* end */ |