changeset 2003:7dc90c83a787 draft

change set_last(t to next). run test at compilation time
author Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
date Mon, 05 May 2014 22:11:49 +0900
parents bbc8802bb0fd
children 8aff72ad65de
files TaskManager/Makefile TaskManager/kernel/ppe/HTask.cc example/Bulk/Makefile example/Bulk/Makefile.macosx example/Bulk/main.cc example/fft/Makefile example/fft/Makefile.macosx example/word_count/Makefile example/word_count/Makefile.macosx
diffstat 9 files changed, 61 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Makefile	Fri May 02 20:44:05 2014 +0900
+++ b/TaskManager/Makefile	Mon May 05 22:11:49 2014 +0900
@@ -3,6 +3,7 @@
 TAGS       = gtags
 TAGSOPTION = 
 TAGSFILE   = GPATH GRTAGS GSYMS GTAGS
+EXAM = ../example
 
 default: parallel
 
@@ -31,6 +32,14 @@
 	-mkdir -p ../include/TaskManager
 	rsync `find . -name Test -prune -or -name '*.h' -print` ../include/TaskManager
 
+parallel-test:
+	@echo "Bulk"
+	@cd $(EXAM)/Bulk;make clean;make parallel-test
+	@echo "FFT"
+	@cd $(EXAM)/fft;make clean;make parallel-test
+	@echo "WordCount"
+	@cd $(EXAM)/word_count;make clean;make parallel-test
+
 distclean: clean
 	rm -f $(TAGSFILE)
 	$(MAKE) -f Makefile.cell celldistclean
--- a/TaskManager/kernel/ppe/HTask.cc	Fri May 02 20:44:05 2014 +0900
+++ b/TaskManager/kernel/ppe/HTask.cc	Mon May 05 22:11:49 2014 +0900
@@ -178,8 +178,8 @@
 Task *
 HTask::get_nextTaskArea(Task *t, TaskList *tl, int task_size) {
     Task *next = t->next();
-    if (((char*)(tl->last()))-((char*)(next)) < task_size) {
-        tl->set_last(t);
+    if (((char*)tl->last())-((char*)next) < task_size) {
+        tl->set_last(next);
         TaskListPtr nextTaskList =  mimpl->createTaskList();
         nextTaskList->prev = tl;
         tl->next = nextTaskList;
--- a/example/Bulk/Makefile	Fri May 02 20:44:05 2014 +0900
+++ b/example/Bulk/Makefile	Mon May 05 22:11:49 2014 +0900
@@ -27,9 +27,12 @@
 FORCE:
 
 test:
-	./twice 
+	./twice
 	./twice -task_array_num 10
 
+parallel-test: macosx
+	@$(MAKE) -f Makefile.macosx test
+
 clean:
 	@$(MAKE) -f Makefile.macosx clean
 	@$(MAKE) -f Makefile.linux clean
--- a/example/Bulk/Makefile.macosx	Fri May 02 20:44:05 2014 +0900
+++ b/example/Bulk/Makefile.macosx	Mon May 05 22:11:49 2014 +0900
@@ -34,6 +34,10 @@
 debug: $(TARGET)
 	sudo gdb ./$(TARGET) 
 
+test:
+	./$(TARGET)  -no_print
+	./$(TARGET) -task_array_num 10 -no_print
+
 clean:
 	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
 	rm -f *~ \#*
--- a/example/Bulk/main.cc	Fri May 02 20:44:05 2014 +0900
+++ b/example/Bulk/main.cc	Mon May 05 22:11:49 2014 +0900
@@ -12,6 +12,7 @@
 static int task = 3;
 static int task_array_num = 3;
 static long block_num = 3;
+static int print = 1;
 
 const char *usr_help_str = "Usage: ./twice [-length data_length] [-task_array_num task_num]\n\
   -task_array_num Number of data in a block (default 16)\n\
@@ -23,13 +24,27 @@
 static void
 print_data(int *data, int size, const char *title)
 {
-    printf("%s ---\n", title);
-    for (int i = 0; i < size; i++) {
-	printf("%2d ", data[i]);
+    if (print == 1) {
+        printf("%s ---\n", title);
+        for (int i = 0; i < size; i++) {
+            printf("%2d ", data[i]);
+        }
+        printf("\n");
     }
-    printf("\n");
 }
 
+static void
+check_data(int *data, int size)
+{
+    for (int i=0;i<size;i++) {
+        if (i*2 != data[i]) {
+            printf("i=%d,%2d\n",i,data[i]);
+            puts("FAILURE");
+            return;
+        }
+    }
+    puts("SUCCESS");
+}    
 /**
  * タスク終了後の data1, data2 の確認
  */
@@ -39,6 +54,7 @@
     int* data = (int*)a;
     // int* task_buf = (int*)b;
     print_data(data, length*task_array_num, "after");
+    check_data(data, length*task_array_num);
     free(data);
     // free(task_buf);
 }
@@ -56,6 +72,8 @@
             block_num = atoi(argv[++i]);
         } else if (strcmp(argv[i], "-block_size") == 0) {
             block_size = atoi(argv[++i]);
+        } else if (strcmp(argv[i], "-no_print") == 0) {
+            print = 0;
         }
     }
     length = task_array_num * block_num * block_size;
--- a/example/fft/Makefile	Fri May 02 20:44:05 2014 +0900
+++ b/example/fft/Makefile	Mon May 05 22:11:49 2014 +0900
@@ -26,6 +26,9 @@
 test: gpu
 	./fft -file lena512.pgm -gpu -g
 
+parallel-test: macosx
+	@$(MAKE) -f Makefile.macosx test
+
 FORCE:
 
 clean:
--- a/example/fft/Makefile.macosx	Fri May 02 20:44:05 2014 +0900
+++ b/example/fft/Makefile.macosx	Mon May 05 22:11:49 2014 +0900
@@ -54,6 +54,9 @@
 debug: $(TARGET)
 	sudo gdb ./$(TARGET)
 
+test:
+	./$(TARGET) -file lena512.pgm -cpu 1
+	./$(TARGET) -file lena512.pgm -cpu 4
 clean:
 	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
 	rm -f *~ \#*
--- a/example/word_count/Makefile	Fri May 02 20:44:05 2014 +0900
+++ b/example/word_count/Makefile	Mon May 05 22:11:49 2014 +0900
@@ -12,20 +12,24 @@
 	@echo "Make for CELL (Cell)"
 	@$(MAKE) -f Makefile.cell
 
+gpu: FORCE
+	@echo "Make for OpenCL"
+	@$(MAKE) -f Makefile.gpu
+
+cuda: FORCE
+	@echo "Make for Cuda"
+	@$(MAKE) -f Makefile.cuda
+
 test:
 	./word_count -file c.txt
 
-gpu: FORCE
-	@echo "Make for OpenCL"
-	@$(MAKE) -f Makefile.gpu
+parallel-test: macosx
+	@$(MAKE) -f Makefile.macosx test
 
 gpu-test: FORCE
 	@echo "Make for OpenCL"
 	@$(MAKE) -f Makefile.gpu test
 
-cuda: FORCE
-	@echo "Make for Cuda"
-	@$(MAKE) -f Makefile.cuda
 
 FORCE:
 
--- a/example/word_count/Makefile.macosx	Fri May 02 20:44:05 2014 +0900
+++ b/example/word_count/Makefile.macosx	Mon May 05 22:11:49 2014 +0900
@@ -30,6 +30,10 @@
 debug: $(TARGET)
 	sudo gdb ./$(TARGET) 
 
+test:
+	./$(TARGET) -file c.txt -cpu 1
+	./$(TARGET) -file c.txt -cpu 4
+	./$(TARGET) -file c.txt -cpu 4 -i
 clean:
 	rm -f $(TARGET) $(OBJS) $(TASK_OBJS)
 	rm -f *~ \#*