Parfor --> Undefined function 'colon' for input arguments of type 'distributed'.

11 views (last 30 days)
Hi,
I am new with the parallel toolbox and I need some help. I have a code that looks like this
function A = main_function(..)
parfor c1=1:m
for c2=1:n
if c2 >= c1
A(c1,c2,:)= my_function(..);
end
end
end
end
I get an error that says
Error using internal_compute_H_9int_vect_simplified (line 141). The source code (C:\Users\..\main_function.m) for the parfor-loop that is trying to execute on the worker could not be found.
Caused by:
Undefined function 'colon' for input arguments of type 'distributed'.
Error using remoteParallelFunction (line 84)
Worker unable to find file.
Undefined function 'colon' for input arguments of type 'distributed'.
At first I thought that the problem was the ":" in the matrix A, but then I tried this simple code
m = 3;
n = 3;
H = zeros(2,2,3);
beta =rand(3,1);
parfor c1=1:m
for c2=1:n
H(c1,c2,:) = 3*rand(3,1);
end
end
and it works.
What is the problem? Is related to the location of the function "main_function", to the matrix A , or to what I do in the funtion "my_function" ? What "distributed" actually means here?
Best
  3 Comments
Maria
Maria on 19 Aug 2021
Hi Raymond!
Unfortunately, I am not allowed to share the code, but I can provide the class of the data used and a small example. I hope it helps for the debugging of the error.
In the main , I have:
H = internal_compute_H(sup1,sup2,dir_curr1,dir_curr2,w1,w2,ori1,ori2,1,beta,TOL);
All the inputs are double, either matrices or vectors (sup1/2 have size 728 X 12, dir_curr, w and ori have size 728 X 1, beta has size 1 X 25) .
The function looks like below
function H_result = internal_compute_H(sup1,sup2,dir_curr1,dir_curr2,w1,w2,ori1,ori2,1,beta,TOL)
m = length(w1);
n = length(w2);
LENGTH_BETA = length(beta);
% organize sliced variable for code optimization (parallelization)
xm_1 = zeros(1,m);
ym_1 = zeros(1,m);
zm_1 = zeros(1,m);
xm_2 = zeros(1,m);
ym_2 = zeros(1,m);
zm_2 = zeros(1,m);
% to allow a perfomed used of sliced arrays (paralellization)
temp_sup1_xm = sup1(:,1:3:12);
temp_sup1_ym = sup1(:,2:3:12);
temp_sup1_zm = sup1(:,3:3:12);
parfor c1 = 1 : m
xm_1(c1) = min(temp_sup1_xm(c1,:)); %min(sup1(c1,1:3:12));
ym_1(c1) = min(temp_sup1_ym(c1,:));%min(sup1(c1,2:3:12));
zm_1(c1) = min(temp_sup1_zm(c1,:));%min(sup1(c1,3:3:12));
end
parfor c1 = 1 : m
xm_2(c1) = max(temp_sup1_xm(c1,:));%max(sup1(c1,1:3:12));
ym_2(c1) = max(temp_sup1_ym(c1,:)); %max(sup1(c1,2:3:12));
zm_2(c1) = max(temp_sup1_zm(c1,:)); %max(sup1(c1,3:3:12));
end
clear temp_sup1_xm temp_sup1_ym temp_sup1_zm
xn_1 = zeros(1,n);
yn_1 = zeros(1,n);
zn_1 = zeros(1,n);
xn_2 = zeros(1,n);
yn_2 = zeros(1,n);
zn_2 = zeros(1,n);
% to allow a perfomed used of sliced arrays (paralellization)
temp_sup2_xm = sup2(:,1:3:12);
temp_sup2_ym = sup2(:,2:3:12);
temp_sup2_zm = sup2(:,3:3:12);
xn_1 = xm_1;
yn_1 = ym_1;
zn_1 = zm_1;
xn_2 = xm_2;
yn_2 = ym_2;
zn_2 = zm_2;
clear temp_sup2_xm temp_sup2_ym temp_sup2_zm
parfor c1=1:m
for c2=1:n
if c2 >= c1
if dir_curr1(c1)==dir_curr2(c2)
if ori1(c1)==1
H_result = my_function(zm_1(c1),zm_2(c1),zn_1(c2),zn_2(c2), ym_1(c1),ym_2(c1),yn_1(c2),yn_2(c2), xm_1(c1),xm_2(c1),xn_1(c2),xn_2(c2),beta,TOL);
end
end
end
end
end
The error that I get tells that the "internal_compute_H" could not be found, Caused by: Undefined function 'colon' for input arguments of type 'distributed'. Error using remoteParallelFunction (line 84). Worker unable to find file. Undefined function 'colon' for input arguments of type 'distributed'.
Maria
Maria on 19 Aug 2021
Maybe it can help, I already tested "my_function" in a different (parallelized) code and it did not give any error. This is why I am a bit confused.

Sign in to comment.

Accepted Answer

Maria
Maria on 19 Aug 2021
So, I had a problem in my code, that is now fixed. I had another function, which I forgot to test, and where I was using distributed arrays. I removed the 'distributed' and now it works! Strange that the error did not point exactly at that function...but now it works!

More Answers (0)

Categories

Find more on MATLAB Parallel Server in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!