I'm implementing a simulated annealing algorithm in matlab using spmd. I will compare different implentation types. One of them is asynchronous paralellism. 12 workers will run the code. if one of them meets the criteria(error<0.01) code will stop the search. Is there any command to do that? If I use labBroadcast or labsend/labreceive it will be synchronus.
Matlab Spmd Termination
365 Views Asked by sakkas At
2
There are 2 best solutions below
0
Edric
On
Further to @Daniel's suggestion, in MATLAB releases R2013b and later, you can use parfeval to do this. Something like this:
% First, kick off the asynchronous work:
N = 12;
for idx = 1:N
f(idx) = parfeval(@myFcn, 1, args);
end
% Next, consume the results
for idx = 1:N
% fetchNext blocks until one of 'f' has completed,
% returning the index into 'f' that completed, as
% well as the result.
[idxInF, result] = fetchNext(f);
if result < 0.01
% we're done!
cancel(f); % Cancel all outstanding work
break; % stop looping and calling fetchNext
end
end
Related Questions in MATLAB
- Convert Cell Array of Symbolic Functions to Double Array of Symbolic Functions MATLAB
- How to restrict vpasolve() to only integer solutions (MATLAB)
- "Error in port widths or dimensions" while producting 27
- matlab has encountered an internal problem needs to close
- Minimize the sum of squared errors between the experimental and predicted data in order to estimate two optimum parameters by using matlab
- Solve equation with Crank Nicolson and Newton iterative method in Matlab
- Why options are not available in EEGLAB menu options?
- ash: ./MathWorksProductInstaller: not found, but file exists
- iterative GA optimization algorithm
- Create Symbolic Function from Double Vector MATLAB
- Fixing FEA Model loading with correct units and stress results
- loading variables from a python script in matlab
- Why cannot I set font of `xlabel` in `plotmf` in MATLAB?
- How would I go about filtering non-standardly formatted serial data which contains some junk binary between data entries?
- Cyclic Voltammetry Simmulation in MATLAB, I am running into issues with my data points returning as NaN values, i am a beginner, any help wanted
Related Questions in PARALLEL-PROCESSING
- How to calculate Matrix exponential with Tailor series PARALLEL using MPI c++
- Efficiently processing many small elements of a collection concurrently in Java
- Parallelize filling of Eigen Matrix in C++
- Memory efficient parallel repeated rarefaction with subsequent matrix addition of large data set
- How to publish messages to RabbitMQ by using Multi threading?
- Running a C++ Program with CMake, MPI and OpenCV
- Alternative approach to io.ReadAll to store memory consumption and send a PUT Request with valid data
- Parallelize nested loop with running sum in Fortran
- Can I use parfor within a parfeval in Matlab R2019b and if yes how?
- Parallel testing with cucumber, selenium and junit 5
- Parallel.ForEach vs ActionBlock
- Passing variable to foreach-object -parallel which is with in start-job
- dbatools SQL Functions Not Running In Parallel While SQL Server queries do in Powershell
- How do I run multiple instances of my Powershell function in parallel?
- Joblib.parallel vs concurrent.futures
Related Questions in SIMULATED-ANNEALING
- How to get python to deal with very small numbers?
- Adding maximum group size to a simulated annealing algorithm without slowing down the process
- Solve a MILP model with Simulated Annealing in Python
- using simulated annealing to solve 0/1 knapsack problem
- 1d bin packing problem with FFD + Simulated annealling not improving the solution. Any thoughts?
- How does the dual annealing algorithm work?
- Why am I getting an overflow error with simulated annealing?
- Simulated Annealing meta-heuristic for a single machine scheduling problem with 6 tasks in Visual Basic for Applications
- Setting bounds and constraints for scipy dual_annealing
- How to get out of local optimum using simulated annealing?
- Switch positions in array and switch order
- Simulated Annealing - Intuition
- How to take into account the constraints of MIP in Simulated Annealing algorithm?
- What is the difference between the objective function (SA) and the value function (RL)
- How to design a heuristic algorithm to solve this location optimization problem?
Related Questions in SPMD
- How to use a flag variable to break all the for-loops in spmd statement?
- Discrete Difference on Sharded JAX Arrays
- JAX vmap vs pmap vs Python multiprocessing
- What is the reason behind parfeval's time overhead compared to a serial implementation?
- Using matlab's spmd to compute simple triple integral is giving me incorrect solution, any thoughts on what I am doing wrong?
- How to properly use spmd in matlab with handle classes and synchonize data between workers
- MatLab Parallel computing toolbox: using more cores for same task
- Asynchronous Parallel Computing in MATLAB?
- Task is to parallelize matrix multiplication with p-threads and vectorized with Intel ISPC compiler
- Matlab: Shut down parallel pool - only working for parfeval() but not spmd
- Using MPI_PUT in fortran and different ranks have different displacements using c_loc
- Can I use mpiexec to run the same executable with different command line arguments for the executable each time?
- How to use SPMD for different input variables and save the output in order?
- How to save intermediate iterations during SPMD in MATLAB?
- How do I make matlab display messages from each worker in the order in which they were generated
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I would start all 12 Processes using jobs. You can check if one of the already completed jobs matches your criteria, then cancel the other jobs.
http://www.mathworks.com/help/distcomp/cancel.html http://www.mathworks.com/help/distcomp/create-simple-independent-jobs.html