- instead of parfor use spmd. spmd permits you to use labSend to send data to another worker
- you can carefully arrange a series of three parallel queue objects such that you can send data from one worker back to the client, and then have the client send it to the other worker (the workers cannot communicate directly for this purpose)
- you can look in the File Exchange for the Shared Matrix contribution
- you can use a shared file, especially if you use memory map (but that is not strictly needed)
Reading update of variable in parallel function?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
E.B
el 12 de Ag. de 2019
Comentada: Walter Roberson
el 14 de Ag. de 2019
I need to implement two function in parallel but one of them reads update value of another function .
Details:
i read CSV file " 200" row as stream data (sensor data) in matrix and at same time another function need to read updated matrix
both need to be simulated in parallel
Two parallel function will be implemented
1- function read() read each raw from file in matrix "Datachunk1"
2- function( out ) has if condition
"if condition" will implement sequentional with another function and take too much time than function read
"else condition" will need to read updated matrix Datachunk1" 50 raw" at a time do operations then deleted them from matrix .this process continue till reading all 200 raw."4 chunks"
i have matlab >2016 i didn't try parallel function before.
part of code
function read()
fid = fopen('t.csv');
filename = fullfile(pwd, 't.csv');
while(i ~=200)
i = i + 1;
next_line = fgetl(fid);
D=Datachunk1;
Datachunk1=cell2mat(textscan(next_line,'%f %f %f %f','Delimiter', ',','CollectOutput', true))
Datachunk1=[D;Datachunk1];
end
end
function out(inputs,position)
if position==0
call by another function
/*do some operations
end
else
Datachunk1
/*do some operations in Datachunk1
end
end
0 comentarios
Respuesta aceptada
Walter Roberson
el 12 de Ag. de 2019
You have several options:
When the second worker goes to delete items out of the matrix, that is going to be a problem, as most of these methods will not reflect the deletion back to the first worker. Matlab arrays always live in exactly one process, and the memory management routines are not able to allocate or deallocate on a different process.
14 comentarios
Walter Roberson
el 14 de Ag. de 2019
We seem to be unable to figure out how to assist you in implementing your needs in MATLAB.
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings 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!