Adds cross compile and test cases
authorPeizhao Ou <peizhaoo@uci.edu>
Thu, 1 Feb 2018 00:10:28 +0000 (16:10 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Thu, 1 Feb 2018 00:10:28 +0000 (16:10 -0800)
CMakeLists.txt
samples/MapCorrectnessTests/TestDoubleAssign.h
test/grampa_driver.cpp [new file with mode: 0644]
test/linear_driver.cpp [new file with mode: 0755]

index 93cf495de51c5b16630515332694455c1a4bb503..8a30b4420f2eb313d984a1cabebdf9431fab47eb 100644 (file)
@@ -1,5 +1,10 @@
 cmake_minimum_required(VERSION 2.8.5)
 
 cmake_minimum_required(VERSION 2.8.5)
 
+#SET(CMAKE_C_COMPILER clang-native)
+#SET(CMAKE_CXX_COMPILER clang++-native)
+SET(CMAKE_C_COMPILER clang-cross)
+SET(CMAKE_CXX_COMPILER clang++-cross)
+
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
        # If this is the root project, issue a project() command so that
        # the Visual Studio generator will create an .sln file.
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
        # If this is the root project, issue a project() command so that
        # the Visual Studio generator will create an .sln file.
@@ -9,7 +14,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     set(JUNCTION_WITH_SAMPLES TRUE CACHE BOOL "Include all Junction samples in generated build system")
     set(JUNCTION_MAKE_INSTALLABLE TRUE)
     set(TURF_MAKE_INSTALLABLE TRUE)
     set(JUNCTION_WITH_SAMPLES TRUE CACHE BOOL "Include all Junction samples in generated build system")
     set(JUNCTION_MAKE_INSTALLABLE TRUE)
     set(TURF_MAKE_INSTALLABLE TRUE)
-endif()        
+endif()
 
 # Default values, can be overridden by user
 set(JUNCTION_USERCONFIG "" CACHE STRING "Optional path to additional config file (relative to root CMakeLists.txt)")
 
 # Default values, can be overridden by user
 set(JUNCTION_USERCONFIG "" CACHE STRING "Optional path to additional config file (relative to root CMakeLists.txt)")
index 7a924c48f3891caf948db15eaf9e1da3fd41236c..fb27b2633239e0c5fe44d61e1903fc741ff4599a 100644 (file)
@@ -58,7 +58,8 @@ public:
 
     void run() {
         m_map = new MapAdapter::Map(MapAdapter::getInitialCapacity(KeysToInsert));
 
     void run() {
         m_map = new MapAdapter::Map(MapAdapter::getInitialCapacity(KeysToInsert));
-        m_index = 2;
+//        m_index = 2;
+        m_index.store(2, turf::SeqCst);
         m_env.dispatcher.kick(&TestDoubleAssign::doubleAssignKeys, *this);
         checkMapContents();
         delete m_map;
         m_env.dispatcher.kick(&TestDoubleAssign::doubleAssignKeys, *this);
         checkMapContents();
         delete m_map;
diff --git a/test/grampa_driver.cpp b/test/grampa_driver.cpp
new file mode 100644 (file)
index 0000000..db2a276
--- /dev/null
@@ -0,0 +1,65 @@
+#include <junction/ConcurrentMap_Grampa.h>
+#include <iostream>
+#include <memory>
+#include <chrono>
+#include <cassert>
+
+namespace {
+
+const size_t kMapSize = 10000;
+const size_t kPassCount = 100000;
+const unsigned s_nInsertPercentage = 10;
+const char* kTestName = "InsDelFind";
+const char* kBenchmarkName = "JunctionMapLinear";
+
+} // namespace
+
+typedef junction::ConcurrentMap_Grampa<turf::u64, turf::u64> Map;
+
+int main() {
+    auto start_time = std::chrono::system_clock::now();
+
+    size_t nInsertedNum = 0;
+    size_t nFindSuccess = 0;
+    std::unique_ptr<Map> map(new Map(kMapSize));
+    for (size_t count = 0; count < kPassCount; count++) {
+        for (size_t i = 1; i <= kMapSize; ++i) {
+            // The number to operate on the map.
+            size_t n = i;
+            // Insert
+            if (i % s_nInsertPercentage == 1) {
+                auto iter = map->insertOrFind(n);
+                if (!iter.getValue()) {
+                  iter.assignValue(n + 1);
+                  nInsertedNum++;
+//                  std::cout << "Inserted" << n << "\n";
+                }
+            }
+            // Find
+            {
+                auto iter = map->find(n);
+                if (!iter.getValue()) {
+                    ++nFindSuccess;
+//                    std::cout << "Found" << n << "\n";
+                }
+            }
+            // Delete
+            if (i % s_nInsertPercentage == 1) {
+                auto iter = map->find(n);
+                if (iter.getValue()) {
+                    iter.eraseValue();
+//                    std::cout << "Erased" << n << "\n";
+                }
+            }
+        }
+    }
+    assert(nFindSuccess == nFindSuccess && "junction::ConcurrentMap_Linear ERROR");
+
+    auto finish_time = std::chrono::system_clock::now();
+    auto dur = finish_time - start_time;
+    auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
+    std::cout << "[       OK ] " << kTestName << "." << kBenchmarkName << "("
+              << milisecs.count() << " ms)\n";
+
+    return 0;
+}
diff --git a/test/linear_driver.cpp b/test/linear_driver.cpp
new file mode 100755 (executable)
index 0000000..3f8dab7
--- /dev/null
@@ -0,0 +1,65 @@
+#include <junction/ConcurrentMap_Linear.h>
+#include <iostream>
+#include <memory>
+#include <chrono>
+#include <cassert>
+
+namespace {
+
+const size_t kMapSize = 10000;
+const size_t kPassCount = 1;
+const unsigned s_nInsertPercentage = 10;
+const char* kTestName = "InsDelFind";
+const char* kBenchmarkName = "JunctionMapLinear";
+
+} // namespace
+
+typedef junction::ConcurrentMap_Linear<turf::u64, turf::u64> Map;
+
+int main() {
+    auto start_time = std::chrono::system_clock::now();
+
+    size_t nInsertedNum = 0;
+    size_t nFindSuccess = 0;
+    std::unique_ptr<Map> map(new Map(kMapSize / 8));
+    for (size_t count = 0; count < kPassCount; count++) {
+        for (size_t i = 1; i <= kMapSize; ++i) {
+            // The number to operate on the map.
+            size_t n = i;
+            // Insert
+            if (i % s_nInsertPercentage == 1) {
+                auto iter = map->insertOrFind(n);
+                if (!iter.getValue()) {
+                  iter.assignValue(n + 1);
+                  nInsertedNum++;
+                  std::cout << "Inserted\n";
+                }
+            }
+            // Find
+            {
+                auto iter = map->find(n);
+                if (!iter.getValue()) {
+                    ++nFindSuccess;
+                    std::cout << "Found\n";
+                }
+            }
+            // Delete
+            if (i % s_nInsertPercentage == 1) {
+                auto iter = map->find(n);
+                if (iter.getValue()) {
+                    iter.eraseValue();
+                    std::cout << "Erased\n";
+                }
+            }
+        }
+    }
+    assert(nFindSuccess == nFindSuccess && "junction::ConcurrentMap_Linear ERROR");
+
+    auto finish_time = std::chrono::system_clock::now();
+    auto dur = finish_time - start_time;
+    auto milisecs = std::chrono::duration_cast<std::chrono::milliseconds>(dur);
+    std::cout << "[       OK ] " << kTestName << "." << kBenchmarkName << "("
+              << milisecs.count() << " ms)\n";
+
+    return 0;
+}