Author: bugman
Date: Fri Mar 23 18:49:10 2012
New Revision: 15625
URL: http://svn.gna.org/viewcvs/relax?rev=15625&view=rev
Log:
Created the fetch_data_store() multi-processor API function.
This simply returns the data store of the same processor as the calling code.
The 2nd test
implementation now uses this code path.
Modified:
1.3/multi/__init__.py
1.3/multi/test_implementation2.py
Modified: 1.3/multi/__init__.py
URL:
http://svn.gna.org/viewcvs/relax/1.3/multi/__init__.py?rev=15625&r1=15624&r2=15625&view=diff
==============================================================================
--- 1.3/multi/__init__.py (original)
+++ 1.3/multi/__init__.py Fri Mar 23 18:49:10 2012
@@ -217,6 +217,24 @@
return processor_box.processor.fetch_data(name=name)
+def fetch_data_store():
+ """API function for obtaining the data store object from the Processor
instance.
+
+ If run on the master, then the master's data store will be returned. If
run on the slave, then the slave's data store will be returned.
+
+ @attention: No inter-processor communications are performed.
+
+ @return: The data store of the processor (of the same rank as the
calling code).
+ @rtype: class instance
+ """
+
+ # Load the Processor_box.
+ processor_box = Processor_box()
+
+ # Return the data store.
+ return processor_box.processor.data_store
+
+
def send_data_to_slaves(name=None, value=None):
"""API function for sending data from the master to all slaves processors.
Modified: 1.3/multi/test_implementation2.py
URL:
http://svn.gna.org/viewcvs/relax/1.3/multi/test_implementation2.py?rev=15625&r1=15624&r2=15625&view=diff
==============================================================================
--- 1.3/multi/test_implementation2.py (original)
+++ 1.3/multi/test_implementation2.py Fri Mar 23 18:49:10 2012
@@ -34,7 +34,7 @@
sys.path.append('..')
# relax module imports.
-from multi import fetch_data, send_data_to_slaves, Application_callback,
load_multiprocessor, Memo, Processor_box, Result_command, Slave_command
+from multi import fetch_data, fetch_data_store, send_data_to_slaves,
Application_callback, load_multiprocessor, Memo, Processor_box, Result_command,
Slave_command
# Module variables.
@@ -235,6 +235,9 @@
def run(self, processor, memo):
"""Essential method for doing something with the results from the
slave processors.
+ This code will run on the master processor.
+
+
@param processor: The slave processor object.
@type processor: Processor instance
@param memo: The slave's corresponding memo object.
@@ -247,12 +250,15 @@
# Calling a method on the master.
memo.sum_fn(self.num)
+ # Get the master processor data store (this is running on the master!).
+ data_store = fetch_data_store()
+
# Initialise the total length variable if the other slaves have not
created it.
- if not hasattr(processor.data_store, 'total_length'):
- processor.data_store.total_length = 0.0
+ if not hasattr(data_store, 'total_length'):
+ data_store.total_length = 0.0
# Sum the lengths.
- processor.data_store.total_length += self.length
+ data_store.total_length += self.length
_______________________________________________
relax (http://nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits