PRODUCTS
Products Overview
Mathematica
Mathematica Student Edition
Mathematica Home Edition
Wolfram
CDF Player
(free download)
Computable Document Format (CDF)
web
Mathematica
grid
Mathematica
Wolfram
Workbench
Wolfram
SystemModeler
Wolfram
Finance Platform
Mathematica
Add-Ons
Wolfram|Alpha Products
SOLUTIONS
Solutions Overview
Engineering
Aerospace Engineering & Defense
Chemical Engineering
Control Systems
Electrical Engineering
Image Processing
Industrial Engineering
Materials Science
Mechanical Engineering
Operations Research
Optics
Petroleum Engineering
Biotechnology & Medicine
Bioinformatics
Medical Imaging
Finance, Statistics & Business Analysis
Actuarial Sciences
Data Analysis & Mining
Econometrics
Economics
Financial Engineering & Mathematics
Financial Risk Management
Statistics
Software Engineering & Content Delivery
Authoring & Publishing
Interface Development
Software Engineering
Web Development
Science
Astronomy
Biological Sciences
Chemistry
Environmental Sciences
Geosciences
Social & Behavioral Sciences
Design, Arts & Entertainment
Game Design, Special Effects & Generative Art
Education
STEM Education Initiative
Higher Education
Community & Technical College Education
Primary & Secondary Education
Students
Technology
Computable Document Format (CDF)
High-Performance & Parallel Computing (HPC)
See Also: Technology Guide
PURCHASE
Online Store
Other Ways to Buy
Volume & Site Licensing
Contact Sales
Software
Service
Upgrades
Training
Books
Merchandise
SUPPORT
Support Overview
Mathematica
Documentation
Knowledge Base
Learning Center
Technical Services
Community & Forums
Training
Does My Site Have a License?
Wolfram User Portal
COMPANY
About Wolfram Research
News
Events
Wolfram Blog
Partnerships
Employment Opportunities
History of
Mathematica
Stephen Wolfram's Home Page
Contact Us
OUR SITES
All Sites
Wolfram|Alpha
Demonstrations Project
MathWorld
Integrator
Wolfram Functions Site
Mathematica Journal
Wolfram Media
Wolfram
Tones
Wolfram Science
Stephen Wolfram
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE
DOCUMENTATION CENTER
FOR THE LATEST INFORMATION.
DOCUMENTATION CENTER SEARCH
New to
Mathematica
?
Find your learning path
»
Mathematica
>
Systems Interfaces & Deployment
>
Parallel Computing
>
ParallelTry
>
Mathematica
>
Core Language
>
Tuning & Debugging
>
Parallel Computing
>
ParallelTry
>
BUILT-IN MATHEMATICA SYMBOL
ParallelMap
Parallelize
WaitNext
$KernelCount
See Also »
|
Parallel Computing
Summary of New Features in 7.0
New in 7.0: Alphabetical Listing
New in 7.0: Core Language
New in 7.0: Systems Interfaces & Deployment
More About »
ParallelTry
ParallelTry
evaluates
in parallel, returning the first result received.
ParallelTry
returns a list of the first
k
results.
MORE INFORMATION
ParallelTry
automatically distributes computations among different available kernels and processors.
Any evaluations still underway after
k
results have been received are aborted.
If the result from evaluating one of the
is
$Failed
, then it is ignored.
If no results other than
$Failed
are obtained,
ParallelTry
returns
$Failed
.
ParallelTry
allocates evaluations of the
to different kernels and processors, starting with
.
If there are more
than kernels, then some of the
will not be tried unless earlier ones return
$Failed
.
ParallelTry
takes the same
DistributedContexts
option as
ParallelTable
.
EXAMPLES
CLOSE ALL
Basic Examples
(2)
Find the factorization of a number that is easy to factorize:
Nondeterministically find a prime in a given range:
Find the factorization of a number that is easy to factorize:
In[1]:=
Out[1]=
Nondeterministically find a prime in a given range:
In[1]:=
Out[1]=
Scope
(2)
Return the first two successful results:
If no successful results are found,
ParallelTry
returns
$Failed
:
Options
(5)
By default, definitions in the current context are distributed automatically:
Do not distribute any definitions of functions:
Distribute definitions for all symbols in all contexts appearing in a parallel computation:
Distribute only definitions in the given contexts:
Restore the value of the
DistributedContexts
option to its default:
Applications
(5)
Find a random prime in parallel:
Find an irreducible polynomial with a random search on each parallel kernel:
Search for a Mersenne prime starting at a given prime exponent:
Try different methods for minimization and return the first one that succeeds:
Try different symbolic methods of summation and return the first one to succeed:
In this case only one method succeeded:
Properties & Relations
(5)
ParallelTry
generally returns the first successful result received:
ParallelTry
works like
ParallelMap
, but returns only one of the results:
ParallelTry
is essentially implemented in terms of
WaitNext
:
Functions defined interactively are automatically distributed to all kernels when needed:
Distribute definitions manually and disable automatic distribution:
For functions from a package, use
ParallelNeeds
rather than
DistributeDefinitions
:
Possible Issues
(3)
If there are more expressions than kernels, some will never be tried:
A function used that is not known on the parallel kernels may lead to sequential evaluation:
Define the function on all parallel kernels:
The function is now evaluated on the parallel kernels:
Definitions of functions in the current context are distributed automatically:
Definitions from contexts other than the default context are not distributed automatically:
Use
DistributeDefinitions
to distribute such definitions:
Alternatively, set the
DistributedContexts
option to include all contexts:
SEE ALSO
ParallelMap
Parallelize
WaitNext
$KernelCount
MORE ABOUT
Parallel Computing
Summary of New Features in 7.0
New in 7.0: Alphabetical Listing
New in 7.0: Core Language
New in 7.0: Systems Interfaces & Deployment
New in 7 | Last modified in 8