annotate example/MemList/main.cc @ 1407:976f7b77f0bf draft

fix Makefile
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Fri, 17 Feb 2012 17:42:50 +0900
parents 278db3ca751d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
364
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
1 #include <stdio.h>
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
2 #include <stdlib.h>
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
3 #include <string.h>
370
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
4 #include <assert.h>
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
5 #include <strings.h>
364
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
6 #include "TaskManager.h"
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
7 #include "Func.h"
368
1a80a2aa696c change TaskManager
aaa
parents: 366
diff changeset
8 #include "MemList.h"
1a80a2aa696c change TaskManager
aaa
parents: 366
diff changeset
9 #include "MemorySegment.h"
364
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
10
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
11
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
12 const char *usr_help_str = "Usage: ./hello [-cpu spe_num] [-count N]\n\
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
13 -cpu Number of SPE (default 1) \n \
364
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
14 -count Number of task is print \"Hello, World!!\"";
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
15
395
208ba3551474 chain on SPE
game@localhost.localdomain
parents: 373
diff changeset
16
370
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
17 void
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 395
diff changeset
18 test1(TaskManager *manager, MemList* active, MemList* freelist, uint32 size, uint32 count)
370
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
19 {
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
20 /*!
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
21 active からランダムに要素を取り出してそこの size の領域を書き潰す
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
22 そこを moveToFirst を繰り返すテスト
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
23 */
370
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
24 for (uint32 i = 0; i < count; i++) {
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
25 int index = manager->get_random()%count;
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
26 MemorySegment* e = active->get(index);
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
27 active->moveToFirst(e);
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
28 bzero(e->data, size);
370
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
29 }
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
30 printf("test1\n");
370
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
31 }
364
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
32
395
208ba3551474 chain on SPE
game@localhost.localdomain
parents: 373
diff changeset
33
364
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
34 int
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 395
diff changeset
35 TMmain(TaskManager *manager, int argc, char *argv[])
364
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
36 {
366
0251d06467de rename include/TaskManager/* and add memory
aaa
parents: 364
diff changeset
37 uint32 size = 128;
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
38 uint32 count = 64;
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
39
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
40 MemList* active = manager->createMemList(size, 0);
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
41 MemList* freelist = manager->createMemList(size, count);
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
42
366
0251d06467de rename include/TaskManager/* and add memory
aaa
parents: 364
diff changeset
43 // 配列!
370
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
44 uint32 i = 0;
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
45 for (;; i++) {
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
46 MemorySegment* m = freelist->poll();
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
47 if (m == 0) {
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
48 break;
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
49 }
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
50 active->addFirst(m);
370
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
51 }
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
52
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
53 assert(i==count);
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
54 printf("count = %d\n", i);
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
55
400
984e7890db0c Fix examples.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 395
diff changeset
56 test1(manager, active, freelist, size, count);
370
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
57 delete active;
4748fd7dcd89 change TaskManger & memory/* & Random
aaa
parents: 369
diff changeset
58 delete freelist;
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 370
diff changeset
59
366
0251d06467de rename include/TaskManager/* and add memory
aaa
parents: 364
diff changeset
60 return 0;
364
fd0c819bab53 uint32 to memaddr(uint64)
tkaito@localhost.localdomain
parents:
diff changeset
61 }
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
62
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 400
diff changeset
63 /* end */