CkIO: test callbacks with refnums set
authorPhil Miller <mille121@illinois.edu>
Tue, 23 Jul 2013 22:53:22 +0000 (17:53 -0500)
committerPhil Miller <mille121@illinois.edu>
Tue, 20 Aug 2013 23:28:58 +0000 (18:28 -0500)
tests/charm++/io/Makefile
tests/charm++/io/iotest.C
tests/charm++/io/iotest.ci

index 97167c142d79da2cab7b889d1de7a54c9415fa7a..6d697526ab20d2deebd56382fa290700ea078e8f 100644 (file)
@@ -5,4 +5,4 @@ pgm: iotest.ci iotest.C
        $(CHARMC) -g iotest.C -o $@ -module CkIO
 
 clean:
-       rm -f *.o *.decl.h *.def.h pgm
+       rm -f *.o *.decl.h *.def.h pgm test
index 0aed707a2fd64640c79df45d74f897c690c9a29c..6eb76ca1dadef29ca82e6d4d5729e7f30cd644cc 100644 (file)
@@ -3,6 +3,8 @@
 /* readonly */ CkGroupID mgr;
 
 class Main : public CBase_Main {
+  Main_SDAG_CODE
+
   CProxy_test testers;
   int n;
   Ck::IO::File f;
@@ -12,32 +14,14 @@ public:
     Ck::IO::Options opts;
     opts.peStripe = 200;
     opts.writeStripe = 1;
-
-    Ck::IO::open("test", CkCallback(CkIndex_Main::ready(NULL), thisProxy), opts);
+    CkCallback opened(CkIndex_Main::ready(NULL), thisProxy);
+    opened.setRefnum(5);
+    Ck::IO::open("test", opened, opts);
 
     CkPrintf("Main ran\n");
+    thisProxy.run();
   }
 
-  void ready(Ck::IO::FileReadyMsg *m) {
-    f = m->file;
-    Ck::IO::startSession(f, 10*n, 0,
-                         CkCallback(CkIndex_Main::start_write(0), thisProxy),
-                        CkCallback(CkIndex_Main::test_written(), thisProxy));
-    delete m;
-    CkPrintf("Main saw file ready\n");
-  }
-
-  void start_write(Ck::IO::SessionReadyMsg *m) {
-    testers = CProxy_test::ckNew(m->session, n);
-    CkPrintf("Main saw session ready\n");
-  }
-
-  void test_written() {
-    CkPrintf("Main saw write done\n");
-    // Read file and validate contents
-
-    CkExit();
-  }
 };
 
 struct test : public CBase_test {
index 25189a20fa8ad303946f6c0dad95bf785c7321c8..d76a720aee38be33332b2b1356fac7fa99cc538e 100644 (file)
@@ -5,8 +5,32 @@ mainmodule iotest {
   mainchare Main {
     entry Main(CkArgMsg *m);
     entry void ready(Ck::IO::FileReadyMsg *m);
+
+    entry void run() {
+      when ready[5](Ck::IO::FileReadyMsg *m) serial {
+        f = m->file;
+        CkCallback sessionStart(CkIndex_Main::start_write(0), thisProxy);
+        sessionStart.setRefnum(13);
+        CkCallback sessionEnd(CkIndex_Main::test_written(0), thisProxy);
+        sessionEnd.setRefnum(13);
+        Ck::IO::startSession(f, 10*n, 0, sessionStart, sessionEnd);
+        delete m;
+        CkPrintf("Main saw file ready\n");
+      }
+      when start_write[13](Ck::IO::SessionReadyMsg *m) serial {
+        testers = CProxy_test::ckNew(m->session, n);
+        CkPrintf("Main saw session ready\n");
+      }
+      when test_written[13](CkReductionMsg *m) serial {
+        CkPrintf("Main saw write done\n");
+        // Read file and validate contents
+
+        CkExit();
+      }
+    };
+
     entry void start_write(Ck::IO::SessionReadyMsg *m);
-    entry void test_written();
+    entry void test_written(CkReductionMsg *m);
   };
 
   array [1D] test {