Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#3334 closed defect (fixed)

ParModelica: failure using parallel function

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

Description

Suppose we had a small testcase where a parallel function was called from within a parfor-loop. Suppose the testcase looked something like the following:

package ParFuncTest
  constant Integer globalSizes = 10;
  constant Integer localSizes = 2;
  constant Integer elements = 10;

  parallel function f
    parglobal input Integer i;
    parglobal output Integer o;
  algorithm
    o := 10*i;
    annotation(Inline=true);
  end f;

  function test
    input Integer a;
    output Integer result[elements];
  protected
    Integer v[elements] = {i for i in 1:elements};
    parglobal Integer pv[elements];
    parglobal Integer pr[elements];
    parglobal Integer pa;
    parglobal Integer pi;
  algorithm
    oclSetNumThreadsGlobalLocal1D({globalSizes}, {localSizes});
    pa := a;
    pv := v;
    parfor i in 1 : elements loop
      pi := i;
      pr[i] := pa * pv[i] * f(pi);
    end parfor;
    result := pr;
  end test;
end ParFuncTest;

Now suppose we call the function 'test' from a script, maybe something like:

setCommandLineOptions("+d=noevalfunc +g=ParModelica -v=1");
getErrorString();
loadFile("ParFuncTest.mo");
getErrorString();

x:=ParFuncTest.test(5);
getErrorString();

Suppose we try this on host, suppose the host is named 'fermi'...

$ omc ParFuncTest.mos
true
""
true
""
- 3 OpenCL devices available.

1 CL_DEVICE_NAME :		Intel(R) Xeon(R) CPU           E5520  @ 2.27GHz
1 CL_DRIVER_VERSION :	2.0
1 CL_DEVICE_MAX_COMPUTE_UNITS :	16
1 CL_DEVICE_MAX_CLOCK_FREQUENCY :	1600
1 CL_DEVICE_LOCAL_MEM_SIZE :	                                                              32 KB
1 CL_DEVICE_GLOBAL_MEM_SIZE:                                                            24107 MB
1 CL_DEVICE_MAX_MEM_ALLOC_SIZE:                                                             6026 MB
1 CL_DEVICE_MAX_PARAMETER_SIZE: 4096 MB
1 CL_DEVICE_MAX_WORK_GROUP_SIZE: 1024 
1 CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE  : 0
.
 .
  .

- Select your device:      1
	 :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/OCLuMvo6t.cl(55): error: expression must have arithmetic type
      (*integer_array_element_addr_c99_1(&_pr, 1, /* modelica_integer */ (modelica_integer)_i)) = ((modelica_integer)_pa * ((*integer_array_element_addr_c99_1(&_pv, 1, /* modelica_integer */ (modelica_integer)_i)) * omc_ParFuncTest_f((modelica_integer)_pi)));
                                                                                                                                                                                                                        ^

/tmp/OCLuMvo6t.cl(62): error: function "ocl_device_alloc" declared implicitly
    tmp1.c1 = ocl_device_alloc(sizeof(modelica_integer));
              ^

/tmp/OCLuMvo6t.cl(67): error: function "copy_assignment_helper_integer"
          declared implicitly
    copy_assignment_helper_integer(&tmp1.c1, &_o);
    ^

3 errors detected in the compilation of "/tmp/OCLuMvo6t.cl".

Internal error: clc compiler invocation failed.

Then suppose we suddenly wake up and realise this was just a dream. Maybe a nightmare, but still a dream too good to be true... Somewhere in the dream there was a horrifying part with failure on other devices too, but that's already part of dream #3326, even if the failures where earlier now...

Change History (5)

comment:1 Changed 9 years ago by mahge930

  • Status changed from new to accepted

comment:2 Changed 9 years ago by mahge930

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

comment:3 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:4 Changed 8 years ago by sjoelund.se

  • Milestone changed from 1.9.4 to 1.9.4-1.9.x

Milestone renamed

comment:5 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.