Show More
@@ -145,10 +145,38 operations and distribute them, reconstructing the result. | |||
|
145 | 145 | In [17]: (C_local == C_remote).all() |
|
146 | 146 | Out[17]: True |
|
147 | 147 | |
|
148 | Calling a ``@parallel`` function *does not* correspond to map. It is used for splitting | |
|
149 | element-wise operations that operate on a sequence or array. For ``map`` behavior, | |
|
150 | parallel functions do have a map method. | |
|
151 | ||
|
152 | ==================== ============================ ============================= | |
|
153 | call pfunc(seq) pfunc.map(seq) | |
|
154 | ==================== ============================ ============================= | |
|
155 | # of tasks # of engines (1 per engine) # of engines (1 per engine) | |
|
156 | # of remote calls # of engines (1 per engine) ``len(seq)`` | |
|
157 | argument to remote ``seq[i:j]`` (sub-sequence) ``seq[i]`` (single element) | |
|
158 | ==================== ============================ ============================= | |
|
159 | ||
|
160 | A quick example to illustrate the difference in arguments for the two modes: | |
|
161 | ||
|
162 | .. sourcecode:: ipython | |
|
163 | ||
|
164 | In [16]: @dview.parallel(block=True) | |
|
165 | ....: def echo(x): | |
|
166 | ....: return str(x) | |
|
167 | ....: | |
|
168 | ||
|
169 | In [17]: echo(range(5)) | |
|
170 | Out[17]: ['[0, 1]', '[2]', '[3]', '[4]'] | |
|
171 | ||
|
172 | In [18]: echo.map(range(5)) | |
|
173 | Out[18]: ['0', '1', '2', '3', '4'] | |
|
174 | ||
|
175 | ||
|
148 | 176 | .. seealso:: |
|
149 | 177 | |
|
150 | See the docstrings for the :func:`parallel` and :func:`remote` decorators for | |
|
151 | options. | |
|
178 | See the :func:`~.remotefunction.parallel` and :func:`~.remotefunction.remote` | |
|
179 | decorators for options. | |
|
152 | 180 | |
|
153 | 181 | Calling Python functions |
|
154 | 182 | ======================== |
General Comments 0
You need to be logged in to leave comments.
Login now