Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#3347 closed defect (fixed)

ParModelica: Cannot use sqrt() or log() within parallel code due to generated OpenCL code

Reported by: gustaf Owned by: mahge930
Priority: high Milestone: 1.9.4
Component: ParModelica Version: trunk
Keywords: Cc:

Description

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.

Change History (4)

comment:1 Changed 9 years ago by mahge930

  • Resolution set to fixed
  • Status changed from new to closed

comment:2 Changed 9 years ago by dietmarw

  • Milestone changed from Future to 1.9.4

Sorting these closed tickets away from "Future". Since they were closed after the last 1.9.3 release, it's very likely that they should have been part of the 1.9.4 release.

comment:3 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4 to 1.9.4-1.9.x

Milestone renamed

comment:4 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4-1.9.x to 1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.