changeset 956:16a3c77d2a5a

wc tweak
author ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
date Tue, 09 Mar 2021 20:07:02 +0900
parents e7cff9d88e5f
children 006e3b7472a9
files src/parallel_execution/CMakeLists.txt src/parallel_execution/examples/wc/WcImpl.cbc src/parallel_execution/examples/wc/main.cbc src/parallel_execution/lib/Gears/Template/Context.pm
diffstat 4 files changed, 39 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Sun Feb 28 17:57:25 2021 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Tue Mar 09 20:07:02 2021 +0900
@@ -179,3 +179,11 @@
   SOURCES
   examples/generics_test/main.cbc  examples/generics_test/StackGenericsImpl.cbc TaskManagerImpl.cbc CPUWorker.cbc SynchronizedQueue.cbc AtomicReference.cbc
 )
+
+GearsCommand(
+  TARGET
+  word_count
+  SOURCES
+  TaskManagerImpl.cbc CPUWorker.cbc SynchronizedQueue.cbc AtomicReference.cbc SingleLinkedStack.cbc examples/wc/main.cbc examples/wc/WcImpl.cbc
+)
+
--- a/src/parallel_execution/examples/wc/WcImpl.cbc	Sun Feb 28 17:57:25 2021 +0900
+++ b/src/parallel_execution/examples/wc/WcImpl.cbc	Tue Mar 09 20:07:02 2021 +0900
@@ -23,12 +23,19 @@
     return wc;
 }
 __code openFile(struct WcImpl* wc,char* filename, __code next(...)) {
-   
-  goto next(...);
+  file = fopen(filename, "r");
+  if (fp == NULL){
+    printf("ファイルが開ませんでした\n");
+    exit(1);
+  } else {
+    printf("file open");
+  }
+ 
+  goto countUp(wc);
 }
 
 __code countUp(struct WcImpl* wc,__code next(WcResult* result, ...)) {
-
+  
     goto next(WcResult* result, ...);
 }
 
--- a/src/parallel_execution/examples/wc/main.cbc	Sun Feb 28 17:57:25 2021 +0900
+++ b/src/parallel_execution/examples/wc/main.cbc	Tue Mar 09 20:07:02 2021 +0900
@@ -3,8 +3,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 
+
 #include "../../../context.h"
+#include "wcTarget.h"
 #interface "TaskManager.h"
+#interface "Wc.h"
 
 int cpu_num = 1;
 int length = 102400;
@@ -36,11 +39,25 @@
 }
 
 
-__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
-   Wc* wc1 = createWcImpl(context);
-   goto wc1->openFile(target.);   
+__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {   
+  Wc* wc1 = createWcImpl(context);
+  goto wc1->openFile(target.filename, wc1->countUp); 
 }
 
+__code openFile(Impl* wc) {
+  File *fp;
+  fp = fopen(wc.filename, "r"); 
+  if (fp == NULL){
+    printf("ファイルが開ませんでした\n");
+    exit(1);
+  } else {
+    printf("file open");
+  }
+  
+  //goto 
+}
+
+
 
 __code code2(struct TaskManager* taskManager) {
     goto taskManager->shutdown(exit_code);
--- a/src/parallel_execution/lib/Gears/Template/Context.pm	Sun Feb 28 17:57:25 2021 +0900
+++ b/src/parallel_execution/lib/Gears/Template/Context.pm	Tue Mar 09 20:07:02 2021 +0900
@@ -162,6 +162,7 @@
 #ifndef USE_CUDAWorker
 typedef unsigned long long CUdeviceptr;
 #endif
+#include "c/typedefData.h"
 EOFEOF
     print $out $str;
 }
@@ -192,7 +193,6 @@
 sub emit_last_header {
   my($class, $out) = @_;
   print $out <<'EOF';
-#include "c/typedefData.h"
 
 #include "c/extern.h"