Example usage of cksequence
authorHarshitha Menon <gplkrsh2@illinois.edu>
Wed, 2 Nov 2011 18:47:08 +0000 (13:47 -0500)
committerHarshitha Menon <gplkrsh2@illinois.edu>
Wed, 2 Nov 2011 18:47:08 +0000 (13:47 -0500)
examples/charm++/cksequence/Makefile [new file with mode: 0644]
examples/charm++/cksequence/cksequence_test [new file with mode: 0755]
examples/charm++/cksequence/cksequence_test.C [new file with mode: 0644]
examples/charm++/cksequence/cksequence_test.ci [new file with mode: 0644]

diff --git a/examples/charm++/cksequence/Makefile b/examples/charm++/cksequence/Makefile
new file mode 100644 (file)
index 0000000..289f0c9
--- /dev/null
@@ -0,0 +1,20 @@
+CHARMC=../../../bin/charmc $(OPTS)
+
+OBJS = cksequence_test.o
+
+all: cksequence_test
+
+cksequence_test: $(OBJS)
+       $(CHARMC) -language charm++ -o cksequence_test $(OBJS)
+
+cksequence_test.decl.h: cksequence_test.ci
+       $(CHARMC)  cksequence_test.ci
+
+clean:
+       rm -f *.decl.h *.def.h conv-host *.o cksequence_test charmrun
+
+cksequence_test.o: cksequence_test.C cksequence_test.decl.h
+       $(CHARMC) -c cksequence_test.C
+
+test: all
+       ./charmrun cksequence_test +p4 10 $(TESTOPTS)
diff --git a/examples/charm++/cksequence/cksequence_test b/examples/charm++/cksequence/cksequence_test
new file mode 100755 (executable)
index 0000000..152aef1
Binary files /dev/null and b/examples/charm++/cksequence/cksequence_test differ
diff --git a/examples/charm++/cksequence/cksequence_test.C b/examples/charm++/cksequence/cksequence_test.C
new file mode 100644 (file)
index 0000000..60587b4
--- /dev/null
@@ -0,0 +1,55 @@
+////////////////////////////////////
+//
+//  cksequence_test.C
+//
+//  Definition of chares in cksequence_test
+//
+//
+////////////////////////////////////
+
+#include "cksequence_test.decl.h"
+
+#include "cksequence.h"
+#include <vector>
+#include  <set>
+
+void FillRandomSeq(std::set<int> &vec) {
+  srand(1024);
+  int total_elements = 1000000;
+  int max_element = 10000;
+  int counter = total_elements;
+
+  while (counter-- > 0) {
+    vec.insert(rand() % max_element);
+  }
+}
+
+
+class Main: public CBase_Main {
+  public:
+    Main(CkArgMsg *m) {
+      std::set<int> vec;
+      FillRandomSeq(vec);
+      CkSequence<int> seq(vec.begin(), vec.end());
+      seq.DoneInserting();
+
+      CkSequence<int>::iterator it;
+      CkSequence<int>::iterator it_end = seq.end();
+
+      std::set<int>::iterator set_it = vec.begin();
+      std::set<int>::iterator set_it_end = vec.end();
+
+      for (it = seq.begin(); it != seq.end(); ++it, ++set_it) {
+        if (*it != *set_it) {
+          CkPrintf("Irregularities %d : %d\n", *it, *set_it);
+        }
+      }
+      CkPrintf("Test passed!!\n");
+
+      delete m;
+      CkExit();
+    };
+
+};
+
+#include "cksequence_test.def.h"
diff --git a/examples/charm++/cksequence/cksequence_test.ci b/examples/charm++/cksequence/cksequence_test.ci
new file mode 100644 (file)
index 0000000..c20059d
--- /dev/null
@@ -0,0 +1,14 @@
+////////////////////////////////////////////////
+//
+//  cksequence_test.ci
+//
+//  Interface file for cksequence_test
+//
+//
+////////////////////////////////////////////////
+
+mainmodule cksequence_test {
+  mainchare Main {
+    entry Main(CkArgMsg *m);
+  };
+};