Add WORKER_POOL environmental option to facilitate pysawsim.manager benchmarking.
authorW. Trevor King <wking@drexel.edu>
Fri, 1 Apr 2011 01:45:43 +0000 (18:45 -0700)
committerW. Trevor King <wking@drexel.edu>
Fri, 1 Apr 2011 01:45:43 +0000 (18:45 -0700)
pysawsim/manager/mpi.py
pysawsim/manager/subproc.py
pysawsim/manager/thread.py
pysawsim/test/bell_rate.py

index 0c4ad4754f4e93260600b3ff89c063f1a22f57b6..a398c4f90ce40464fe3e8f05c8beec6df2bc0899 100644 (file)
@@ -49,6 +49,7 @@ There is also a `free_queue` running from `receive-thread` to
 nodes are free (and therefore ready to receive new jobs).
 """
 
+import os
 from Queue import Queue, Empty
 import sys
 from threading import Thread
@@ -208,8 +209,9 @@ class MPIManager (ThreadManager):
                 'w.run()',
                 'w.teardown()',
                 ])
-        if worker_pool == None:
-            worker_pool = MPI.COMM_WORLD.Get_size()
+        if worker_pool is None:
+            worker_pool = int(os.environ.get('WORKER_POOL',
+                                             MPI.COMM_WORLD.Get_size()))
         comm = MPI.COMM_SELF.Spawn(  # locks with mpich2 if no mpd running
             sys.executable, args=['-c', spawn_script], maxprocs=worker_pool)
         rank = comm.Get_rank()
index d767da4011cac35dc66c544a78eff99bac7e6775..6a17078ab4cb2a9978eec68b7116da7ca99441a2 100644 (file)
@@ -30,6 +30,7 @@ except ImportError, _DISABLING_ERROR:
     Process = object
     _SKIP = '  # doctest: +SKIP'
 
+import os
 
 from .. import log
 from . import Job
@@ -116,8 +117,8 @@ class SubprocessManager (ThreadManager):
         self._receive_queue = Queue()
 
     def _spawn_workers(self, worker_pool=None):
-        if worker_pool == None:
-            worker_pool = cpu_count() + 1
+        if worker_pool is None:
+            worker_pool = int(os.environ.get('WORKER_POOL', cpu_count() + 1))
         self._manager = Manager()
         self._workers = []
         for i in range(worker_pool):
index 48a2f9fec3b0f97315c18dc787cc513423f00851..a4e98f5cf5a0b508c520b713c4b644616ecb4ae5 100644 (file)
@@ -21,6 +21,7 @@
 """
 
 import copy
+import os
 from Queue import Queue, Empty
 import threading
 
@@ -90,7 +91,7 @@ class ThreadManager (JobManager):
     Increasing `worker_pool` will only help you get around IO blockin
     at the cost increased time-slicing overhead.
     """
-    def __init__(self, worker_pool=2):
+    def __init__(self, worker_pool=None):
         super(ThreadManager, self).__init__()
         self._blocked = []
         self._setup_queues()
@@ -101,6 +102,8 @@ class ThreadManager (JobManager):
         self._receive_queue = Queue()
 
     def _spawn_workers(self, worker_pool):
+        if worker_pool is None:
+            worker_pool = int(os.environ.get('WORKER_POOL', 2))
         self._workers = []
         for i in range(worker_pool):
             worker = WorkerThread(spawn_queue=self._spawn_queue,
index f54243368dd7cf0d8de6e13ad726fbfe4faffda7..fdbec6fd3bfd5a83a692595a1696330a2d6736e4 100644 (file)
@@ -28,7 +28,7 @@ Analytically, with a spring constant
 .. math:: k = df/dx
 
 and a pulling velocity
-
+unfolindg
 .. math:: v = dx/dt
 
 we have a loading rate
@@ -148,7 +148,7 @@ class GumbelModelFitter (HistogramModelFitter):
 
 def bell_rate(sawsim_runner, num_domains=1, unfolding_rate=1,
               unfolding_distance=1, temperature=1/kB, spring_constant=1,
-              velocity=1, N=100):
+              velocity=1, N=200):
     loading_rate = float(spring_constant * velocity)
     rho = kB * temperature / unfolding_distance
     alpha = rho * log(loading_rate / (unfolding_rate * rho))