﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3347	ParModelica: Cannot use sqrt() or log() within parallel code due to generated OpenCL code	Gustaf Thorslund	Mahder Alemseged Gebremedhin	"{{{#!mo
setCommandLineOptions(""-v=1 +g=ParModelica +d=noevalfunc"");
loadString(""
package ParSqrt
  constant Integer arrayCnt = 2;
  parkernel function f
    parglobal input Real A[arrayCnt];
    parglobal output Real B[arrayCnt];
  algorithm
    for
      i in oclGetGlobalId(1):oclGetGlobalSize(1):arrayCnt
    loop
      B[i] := sqrt(A[i]);
    end for;
  end f;
  
  function test
    input Real d;
    output Real result[arrayCnt];
  protected
    parglobal Real pResult[arrayCnt];
    Real tmp[arrayCnt];
    parglobal Real pTmp[arrayCnt];
  algorithm
    for i loop
      tmp[i] := i;
    end for;
    pTmp := tmp;
    f(pTmp);
    pResult := f(pTmp);
    result := pResult;
  end test;
end ParSqrt;
"");

x:=ParSqrt.test(4);
}}}

{{{
Error building program:
CL_BUILD_PROGRAM_FAILURE 
Build failed: Errors detected in compilation of OpenCL code:
CL_PROGRAM_BUILD_LOG:  
:54:29: warning: incompatible pointer to integer conversion initializing 'modelica_integer' (aka 'long') with an expression of type 'char __attribute__((address_space(2))) [1]'
          FILE_INFO info = {"""",0,0,0,0,0};
                            ^~
:54:32: warning: excess elements in scalar initializer
          FILE_INFO info = {"""",0,0,0,0,0};
                               ^
:55:11: warning: implicit declaration of function 'omc_assert_warning' is invalid in C99
          omc_assert_warning(info, ""The following assertion has been violated at time %f"", time);
          ^
:55:92: error: use of undeclared identifier 'time'
          omc_assert_warning(info, ""The following assertion has been violated at time %f"", time);
                                                                                           ^
:56:11: warning: implicit declaration of function 'throwStreamPrintWithEquationIndexes' is invalid in C99
          throwStreamPrintWithEquationIndexes(threadData, equationIndexes, ""Model error: Argument of sqrt(A[i]) was %g should be >= 0"", tmp1);
          ^
:56:59: error: use of undeclared identifier 'equationIndexes'
          throwStreamPrintWithEquationIndexes(threadData, equationIndexes, ""Model error: Argument of sqrt(A[i]) was %g should be >= 0"", tmp1);
}}}

Tested using my ParModelicaFixes branch on github with fixes from Mahder."	defect	closed	high	1.9.4	ParModelica	trunk	fixed		
