Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53096 - sandbox/stm/libs/stm/test
From: vicente.botet_at_[hidden]
Date: 2009-05-18 15:27:34


Author: viboes
Date: 2009-05-18 15:27:34 EDT (Mon, 18 May 2009)
New Revision: 53096
URL: http://svn.boost.org/trac/boost/changeset/53096

Log:
Boost.Stm v0.1 Adding pointer test
Added:
   sandbox/stm/libs/stm/test/pointer_test.cpp (contents, props changed)
   sandbox/stm/libs/stm/test/pointer_test.h (contents, props changed)
Text files modified:
   sandbox/stm/libs/stm/test/stm.cpp | 2 ++
   1 files changed, 2 insertions(+), 0 deletions(-)

Added: sandbox/stm/libs/stm/test/pointer_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/stm/libs/stm/test/pointer_test.cpp 2009-05-18 15:27:34 EDT (Mon, 18 May 2009)
@@ -0,0 +1,111 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Justin E. Gottchlich 2009.
+// (C) Copyright Vicente J. Botet Escriba 2009.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+/* The DRACO Research Group (rogue.colorado.edu/draco) */
+/*****************************************************************************\
+ *
+ * Copyright Notices/Identification of Licensor(s) of
+ * Original Software in the File
+ *
+ * Copyright 2000-2006 The Board of Trustees of the University of Colorado
+ * Contact: Technology Transfer Office,
+ * University of Colorado at Boulder;
+ * https://www.cu.edu/techtransfer/
+ *
+ * All rights reserved by the foregoing, respectively.
+ *
+ * This is licensed software. The software license agreement with
+ * the University of Colorado specifies the terms and conditions
+ * for use and redistribution.
+ *
+\*****************************************************************************/
+
+#include <iostream>
+#include "lotExample.h"
+#include <boost/stm/transaction.hpp>
+#include "main.h"
+
+using namespace boost::stm;
+
+native_trans<int> *intP = NULL;
+
+static void pointer_test_alloc()
+{
+ atomic(t)
+ {
+ intP = t.new_shared_memory(intP);
+ SLEEP(1000);
+ *intP = 1;
+ t.force_to_abort();
+ t.end();
+ } before_retry { intP = NULL; }
+
+ SLEEP(10000);
+}
+
+static void do_pointer_access()
+{
+ int val = 0;
+
+ for (;;)
+ {
+ atomic(t)
+ {
+ if (NULL != t.read_ptr(intP)) val = *t.read_ptr(intP);
+
+ cout << val << endl;
+ } end_atom
+ }
+}
+
+static void* pointer_access_test(void*)
+{
+ boost::stm::transaction::initialize_thread();
+ do_pointer_access();
+ return NULL;
+}
+
+void pointer_test()
+{
+ boost::stm::transaction::initialize();
+ boost::stm::transaction::initialize_thread();
+
+ pthread_t *threads = new pthread_t[kMaxThreads];
+ int *threadId = new int[kMaxThreads];
+
+ //--------------------------------------------------------------------------
+ // Reset barrier variables before creating any threads. Otherwise, it is
+ // possible for the first thread
+ //--------------------------------------------------------------------------
+ threadsFinished.value() = 0;
+ threadsStarted.value() = 0;
+ startTimer = nMain::kStartingTime;
+ endTimer = 0;
+
+ for (int j = 0; j < kMaxThreads - 1; ++j)
+ {
+ threadId[j] = j;
+ pthread_create(&threads[j], NULL, pointer_access_test, (void *)&threadId[j]);
+ }
+
+ pointer_test_alloc();
+
+
+}
+
+
+
+
+
+
+

Added: sandbox/stm/libs/stm/test/pointer_test.h
==============================================================================
--- (empty file)
+++ sandbox/stm/libs/stm/test/pointer_test.h 2009-05-18 15:27:34 EDT (Mon, 18 May 2009)
@@ -0,0 +1,23 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Justin E. Gottchlich 2009.
+// (C) Copyright Vicente J. Botet Escriba 2009.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/synchro for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+#ifndef POINTER_TEST_H
+#define POINTER_TEST_H
+
+void pointer_test();
+
+#endif // SMART_H
+
+

Modified: sandbox/stm/libs/stm/test/stm.cpp
==============================================================================
--- sandbox/stm/libs/stm/test/stm.cpp (original)
+++ sandbox/stm/libs/stm/test/stm.cpp 2009-05-18 15:27:34 EDT (Mon, 18 May 2009)
@@ -29,6 +29,7 @@
 #include "testLL_latm.h"
 #include "testHT_latm.h"
 #include "smart.h"
+#include "pointer_test.h"
 #if 0
 #include "testLinkedListWithLocks.h"
 #include "testHashMapAndLinkedListsWithLocks.h"
@@ -178,6 +179,7 @@
       else if ("ll" == bench) TestLinkedListSetsWithLocks();
       else if ("smart" == bench) test_smart();
 #if 0
+ else if ("pointer" == bench) pointer_test();
       else if ("linkedlist_w_locks" == bench) TestLinkedListWithLocks();
       else if ("hashmap_w_locks" == bench) TestHashMapWithLocks();
       else if ("list_hash_w_locks" == bench) TestHashMapAndLinkedListWithLocks();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk