Trying to parallel compute a function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a function in a program that does calcuations I believe in serial. It gets an array of values as inputs and then performs these calculations. The outputs are not based on previous outputs so I believe this function can be done in parallel with itself. I should mention the AT08gui function is the one I want to perform in parallel. This for loop should only really run 1 time unless multiple files are used. I apologize if I'm not using the proper nomenclature as I'm not extremely familiar with parallel computing and just want to share the load of a 7000 point program between the 4 cpu cores I have to hopefully speed the process up, so that each core would be only doing 1750 and hopefully would be speed the process up. Essentially the same thing as me running the program in 4 seperate instances with the data split up appropriately and then having the outputs return to a single excel file.
I hope this makes sense and hopefully there is maybe a simple matlab function that implements what I'm talking about? or maybe MATLAB automatically does this and my function is already running in parallel?
for x=1:length(FLIST)
v=FLIST(x);
if firstpass==1||get(handles.Filetype_selector,'value')==4
Fdat(1)={v};
[D, Oh, Ogh, Osh, Ov, Ogv, Osv, ~, ~, ~, ~, AntF, AntB, AntFX, AntBX, ux, uy, ~]=AT08gui(Filename,Filetype,v,Tsurf,Psurf,pMSL,er,ho,ha,AOIs,R,model,gm,MBD,MBDr,det,resolution,Numfiles,Fdat);
[E]=WRITETA(FNXLS,E,D,v,Tsurf,Psurf,pMSL,er,ho,ha,AOIs,model,Ov,Oh,Osh,Ogv,Ogh);
firstpass=0;
else
[D, Oh, Ogh, Osh, Ov, Ogv, Osv]=Get_Ta(AntF,AntB,AntFX,AntBX,ux,uy,v,Tsurf,Psurf,pMSL,er,ho,ha,R,AOIs,model,gm,us);
[E]=WRITETA(FNXLS,E,D,v,Tsurf,Psurf,pMSL,er,ho,ha,AOIs,model,Ov,Oh,Osh,Ogv,Ogh);
end
end
2 comentarios
Matt J
el 4 de Ag. de 2022
The outputs are not based on previous outputs.
It doesn't look that way. The line,
[E]=WRITETA(FNXLS,E,D,v,Tsurf,Psurf,pMSL,er,ho,ha,AOIs,model,Ov,Oh,Osh,Ogv,Ogh);
refers to the previous value of E.
In any case, do you even have the Parallel Computing Toolbox?
Respuestas (1)
Bruno Luong
el 4 de Ag. de 2022
"or maybe MATLAB automatically does this and my function is already running in parallel?"
No.
But if you vectorize your function AT08gui , MATLAB might use low-level function on vector that are implemented in multi-thread.
Ver también
Categorías
Más información sobre Performance and Memory en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!