필터 지우기
필터 지우기

Too many output arguments while launching workers with parfeval

조회 수: 16 (최근 30일)
Quant
Quant 2021년 11월 18일
댓글: Quant 2021년 11월 18일
I try to write and read in parallel to/from a hardware device (under Linux) for the purpose of testing the device and it must happen infinitely until instructed to stop.
script:
write_file='testdata';
read_file='result';
pattern=int16([ 0x0102, 0x0304, 0x0506, 0x0708; %test pattern is chosen so individual bytes could be identified
0x090a, 0x0b0c, 0x0d0e, 0x0f10;
0x1112, 0x1314, 0x1516, 0x1718;
0x191a, 0x1b1c, 0x1d1e, 0x1f20]);
repetition=128;
testdata=repmat(pattern, 1, 8192*repetition); %replicate for 32768* repetition test data points
read_dim=[4, 32768*repetition];
write_thread=parfeval(@writeXillybus, 2, write_file, testdata);
read_thread=parfeval(@readXillybus, 2, read_file, read_dim);
pause %let the workers run indefinitely
cancel(write_thread);
cancel(read_thread);
functions:
function out=writeXillybus(device, testdata)
test_fid=fopen(['/dev/xillybus_', device], 'w');%open device file
cleanup = onCleanup(@() fclose(test_fid));
while(true)
out=fwrite(test_fid, testdata,'int16');
end
end
function out=readXillybus(device, format)
data_fid=fopen(['/dev/xillybus_', device], 'r');
cleanup = onCleanup(@() fclose(data_fid));
while(true)
out=fread(data_fid, format, '*int16');
end
end
However the workers crash with future reporting. 'Too many output arguments.' I have trouble making sense out of it, because it rises deep from Matlab internals: remote cause shows line 39 of toolbox/parallel/cluster/+parallel/+internal/+queue/evaluateRequest.m as origin.
Anyway, isn't parfeval supposed to be able to handle arbitrary number of outputs?

채택된 답변

Yongjian Feng
Yongjian Feng 2021년 11월 18일
According to the help of parfeval, the second input argument is NUMOUT. You gave 2?
  댓글 수: 1
Quant
Quant 2021년 11월 18일
I read docs a few times, but every time I somehow understood it refers to the input arguments. what an embarassing lapse in attention

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Asynchronous Parallel Programming에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by