﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3335	ParModelica: parfor with for inside creates broken OpenCL code	Gustaf Thorslund	Mahder Alemseged Gebremedhin	"Given the following test functions:
{{{#!mo
package ParArray
  constant Integer globalSizes = 10;
  constant Integer localSizes = 2;
  constant Integer nx = 10;
  constant Integer ny = 10;

  function OneDim
    input Real a;
    output Real result[nx];
  protected
    parglobal Real pa;
    parglobal Real presult[nx];
  algorithm
    pa := a;
    parfor i in 1:nx loop
      presult[i] := i*pa;
    end parfor;
    result := presult;
  end OneDim;
  
  function TwoDim1
    input Real a;
    output Real result[nx,ny];
  protected
    parglobal Real pa;
    parglobal Real presult[nx,ny];
  algorithm
    pa := a;
    parfor i in 1:nx loop
      presult[i,1] := i*1*pa;
    end parfor;
    result := presult;
  end TwoDim1;

  function TwoDim2
    input Real a;
    output Real result[nx,ny];
  protected
    parglobal Real pa;
    parglobal Real presult[nx,ny];
  algorithm
    pa := a;
    parfor i in 1:nx loop
      for j in 1:ny loop
        presult[i,j] := i*j*pa;
      end for;
    end parfor;
    result := presult;
  end TwoDim2;
end ParArray;
}}}

And a little script:
{{{#!mo
setCommandLineOptions(""+d=noevalfunc +g=ParModelica -v=1"");
getErrorString();

setDefaultOpenCLDevice(1);
getErrorString();

loadFile(""ParArray.mo"");
getErrorString();

// x:=ParArray.OneDim(5);
getErrorString();

// y:=ParArray.TwoDim1(5);
getErrorString();

z:=ParArray.TwoDim2(5);
getErrorString();
}}}

The following error is produced:
{{{#!bash
$ omc ParArray.mos 
true
""""
true
""""
true
""""
""""
""""
	 :Using flags -I""/home/gusth/src/OpenModelica/build/include/omc/c/""
Error building program:
CL_BUILD_PROGRAM_FAILURE 
Build failed: Errors detected in compilation of OpenCL code:
CL_PROGRAM_BUILD_LOG:  
/tmp/OCLdHvhO6.cl(45): error: function ""omc_assert_withEquationIndexes""
          declared implicitly
        omc_assert_withEquationIndexes(threadData, info, equationIndexes, ""assertion range step != 0 failed"");
        ^

/tmp/OCLdHvhO6.cl(45): error: identifier ""threadData"" is undefined
        omc_assert_withEquationIndexes(threadData, info, equationIndexes, ""assertion range step != 0 failed"");
                                       ^

/tmp/OCLdHvhO6.cl(45): error: identifier ""equationIndexes"" is undefined
        omc_assert_withEquationIndexes(threadData, info, equationIndexes, ""assertion range step != 0 failed"");
                                                         ^

3 errors detected in the compilation of ""/tmp/OCLdHvhO6.cl"".

Internal error: clc compiler invocation failed.
}}}
OneDim and TwoDim1 works as expected, but are disabled in the above test.

Test performed on fermi with Intel driver."	defect	closed	high	1.9.4	ParModelica	trunk	fixed		
