1

I stumbled across this problem while working with Jacket.

I use a compiled function (compiled with gcompile) within a gfor loop. This is meant to be supported as far as I know: http://wiki.accelereyes.com/wiki/index.php/GCOMPILE

But I observed that while the uncompiled function delivers the correct results, the compiled function gives the same output for all the gfor-iterations:

%================
% function[C] = test(A,B)
% C = A+B;
% end
%================

testing = gcompile('test.m');

A = gdouble(1:1:10);
B = gdouble(2:2:20);
C1 = gzeros(10,1);
C2 = gzeros(10,1);

gfor l=1:10
    C1(l) = test(A(l),B(l));
    C2(l) = testing(A(l),B(l));
gend

The output is:

C1 = [ 3,6,9,12,15,18,21,24,27,30] (correct result)

C2 = [ 3,3,3,3,3,3,3,3,3,3]

Can you verify/rebut my results? What am I doing wrong?

Cheers, Angela

Angela
  • 53
  • 4
  • The person that can answer that more than any of us is @Pavan ... I'm sure he'll get to asnwer this soon... – bla Feb 27 '13 at 06:42

1 Answers1

0

I was able to reproduce this behavior by running Jacket on MATLAB. It appears that gcompile does not work over GFOR as it should, and the documentation was in error. Sorry about that.

Vish
  • 2,144
  • 5
  • 25
  • 48
  • This should have been a comment instead. – Ja͢ck Feb 27 '13 at 10:08
  • Do you plan on fixing this, or do you know if Matlab will provide such a combination GCOMPILE/GFOR, once they release it? – Angela Mar 01 '13 at 09:48
  • We are unable to make changes to Jacket source code at this time. However, there are many ways to accomplish what you are doing - GCOMPILE is not necessarily the best or the only solution. In fact, GCOMPILE has many limitations that I'm sure you are aware of: http://wiki.accelereyes.com/wiki/index.php/GCOMPILE – Vish Mar 01 '13 at 16:19