[pypy-commit] stmgc c7-more-segments: Test the maximum number of segments, in test_random.

arigo noreply at buildbot.pypy.org
Sun Mar 16 12:04:50 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: c7-more-segments
Changeset: r1039:0454581ce4a8
Date: 2014-03-16 12:04 +0100
http://bitbucket.org/pypy/stmgc/changeset/0454581ce4a8/

Log:	Test the maximum number of segments, in test_random.

diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -15,7 +15,7 @@
 
 
 #define NB_PAGES            (1500*256)    // 1500MB
-#define NB_SEGMENTS         3
+#define NB_SEGMENTS         STM_NB_SEGMENTS
 #define NB_SEGMENTS_MAX     240    /* don't increase NB_SEGMENTS past this */
 #define MAP_PAGES_FLAGS     (MAP_SHARED | MAP_ANONYMOUS | MAP_NORESERVE)
 #define NB_NURSERY_PAGES    (STM_GC_NURSERY/4)
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -127,6 +127,12 @@
 
 /* ==================== PUBLIC API ==================== */
 
+/* Number of segments (i.e. how many threads can be executed in
+   parallel, in maximum).
+*/
+#define STM_NB_SEGMENTS    4
+
+
 /* Structure of objects
    --------------------
 
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -9,6 +9,7 @@
 typedef ... object_t;
 typedef ... stm_jmpbuf_t;
 #define SIZEOF_MYOBJ ...
+#define STM_NB_SEGMENTS ...
 #define _STM_FAST_ALLOC ...
 #define _STM_GCFLAG_WRITE_BARRIER ...
 
@@ -260,6 +261,7 @@
 HDR = lib.SIZEOF_MYOBJ
 assert HDR == 8
 GCFLAG_WRITE_BARRIER = lib._STM_GCFLAG_WRITE_BARRIER
+NB_SEGMENTS = lib.STM_NB_SEGMENTS
 
 
 class Conflict(Exception):
@@ -400,10 +402,11 @@
 
 
 class BaseTest(object):
+    NB_THREADS = 2
 
     def setup_method(self, meth):
         lib.stm_setup()
-        self.tls = [_allocate_thread_local(), _allocate_thread_local()]
+        self.tls = [_allocate_thread_local() for i in range(self.NB_THREADS)]
         self.current_thread = 0
 
     def teardown_method(self, meth):
diff --git a/c7/test/test_random.py b/c7/test/test_random.py
--- a/c7/test/test_random.py
+++ b/c7/test/test_random.py
@@ -533,12 +533,13 @@
 
 
 class TestRandom(BaseTest):
+    NB_THREADS = NB_SEGMENTS
 
     def test_fixed_16_bytes_objects(self, seed=1010):
         rnd = random.Random(seed)
 
         N_OBJECTS = 3
-        N_THREADS = 2
+        N_THREADS = self.NB_THREADS
         ex = Exec(self)
         ex.do("################################################################\n"*10)
         ex.do('# initialization')


More information about the pypy-commit mailing list