Opened 10 years ago
Last modified 9 years ago
#3242 reopened defect
Failure to compile generated code due to type mismatch
Reported by: | Gustaf Thorslund | Owned by: | Mahder Alemseged Gebremedhin |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | ParModelica | Version: | trunk |
Keywords: | array, codegen | Cc: |
Description
When trying out the ocl* functions in ParModelica I ran into issues compiling the generated code. This might be related to bug #3214, but for ParModelica this time.
To start with the test code (that should probably be extended to cover more of the ocl* functions):
/// oclTest.mo package oclTest constant Integer globalSizes = 10; constant Integer localSizes = 2; parkernel function Kernel parglobal output Integer groupId[globalSizes]; parglobal output Integer localId[globalSizes]; algorithm groupId[oclGetGlobalId(1)] := oclGetGroupId(1); localId[oclGetGlobalId(1)] := oclGetLocalId(1); end Kernel; function test output Integer groupId[globalSizes]; output Integer localId[globalSizes]; algorithm oclSetNumThreadsGlobalLocal1D({globalSizes}, {localSizes}); (groupId, localId) := Kernel(); end test; end oclTest;
Then a little script:
/// oclTest.mos loadFile("oclTest.mo"); getErrorString(); (x,y):=oclTest.test(); getErrorString();
Then try to build and run the test script:
$ omc -g=ParModelica oclTest.mos true "" Error processing file: oclTest.mos Error: Error building simulator. Build log: g++ -I"/home/gustaf/local/openmodelica/include/omc/c" -fPIC -O0 -falign-functions -march=native -c -o oclTest_test.o oclTest_test.c oclTest_test.c: In function ‘integer_array omc_oclTest_test(threadData_t*, integer_array*)’: oclTest_test.c:35:46: error: cannot convert ‘base_array_t* {aka base_array_s*}’ to ‘device_integer_array* {aka dev_arr*}’ for argument ‘2’ to ‘device_integer_array omc_oclTest_Kernel(threadData_t*, device_integer_array*)’ tmp2 = omc_oclTest_Kernel(threadData, &tmp1); ^ oclTest_test.makefile:18: recipe for target 'oclTest_test' failed make: *** [oclTest_test] Error 1 # Error encountered! Exiting... # Please check the error message and the flags. Execution failed!
$ omc --version
1.9.3+dev (r25196)
Change History (4)
follow-up: 2 comment:1 by , 10 years ago
comment:2 by , 10 years ago
Replying to mahge930:
Ya I am already aware of this errors :).
Good! Now it's also official :-)
It's not the ocl* functions that are the problem though.
Ok, so once we have a place for test cases, maybe this test should be split into two tests.
It is the array copy functions. Specifically this line
(groupId, localId) := Kernel();where the returned gpu arrays are copied to cpu arrays.
Ok, so just one tiny line producing a few lines of compilation errors.
Btw for now you should expicitly copy these values.
Thanks for the workaround! I suppose you are already aware each of these likes will produce quite a few lines of compilation errors:
(p_groupId, p_localId) := Kernel(); groupId := p_groupId; localId := p_localId;
Some of the errors when using -v=1:
oclTest_test.c: In function ‘integer_array omc_oclTest_test(threadData_t*, integer_array*)’: oclTest_test.c:41:46: error: cannot convert ‘base_array_t* {aka base_array_s*}’ to ‘device_integer_array* {aka dev_arr*}’ for argument ‘2’ to ‘device_integer_array omc_oclTest_Kernel(threadData_t*, device_integer_array*)’ tmp2 = omc_oclTest_Kernel(threadData, &tmp1); ^ oclTest_test.c:42:14: error: no match for ‘operator=’ (operand types are ‘device_integer_array {aka dev_arr}’ and ‘base_array_t {aka base_array_s}’) _p_localId = tmp1; ^ oclTest_test.c:42:14: note: candidate is: In file included from /home/gustaf/local/openmodelica/include/omc/c/ParModelica/explicit/openclrt/omc_ocl_interface.h:55:0, from oclTest_test.h:8, from oclTest_test.c:1: /home/gustaf/local/openmodelica/include/omc/c/ParModelica/explicit/openclrt/omc_ocl_common_header.h:88:16: note: dev_arr& dev_arr::operator=(const dev_arr&) typedef struct dev_arr{ ^ /home/gustaf/local/openmodelica/include/omc/c/ParModelica/explicit/openclrt/omc_ocl_common_header.h:88:16: note: no known conversion for argument 1 from ‘base_array_t {aka base_array_s}’ to ‘const dev_arr&’ oclTest_test.c:43:14: error: no match for ‘operator=’ (operand types are ‘device_integer_array {aka dev_arr}’ and ‘base_array_t {aka base_array_s}’) _p_groupId = tmp2; ^ oclTest_test.c:43:14: note: candidate is: In file included from /home/gustaf/local/openmodelica/include/omc/c/ParModelica/explicit/openclrt/omc_ocl_interface.h:55:0, from oclTest_test.h:8, from oclTest_test.c:1: /home/gustaf/local/openmodelica/include/omc/c/ParModelica/explicit/openclrt/omc_ocl_common_header.h:88:16: note: dev_arr& dev_arr::operator=(const dev_arr&) typedef struct dev_arr{ ^ /home/gustaf/local/openmodelica/include/omc/c/ParModelica/explicit/openclrt/omc_ocl_common_header.h:88:16: note: no known conversion for argument 1 from ‘base_array_t {aka base_array_s}’ to ‘const dev_arr&’ oclTest_test.c:45:153: error: cannot convert ‘device_integer_array* {aka dev_arr*}’ to ‘const integer_array_t* {aka const base_array_s*}’ for argument ‘1’ to ‘modelica_integer* integer_array_element_addr(const integer_array_t*, int, ...)’ array_alloc_scalar_integer_array(&tmp3, 10, (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 1)), (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 2)), (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 3)), (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 4)), (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 5)), (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 6)), (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 7)), (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 8)), (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 9)), (modelica_integer)(*integer_array_element_addr(&_p_groupId, 1, /* modelica_integer */ (modelica_integer) 10))); . . . oclTest_test.c:48:153: error: cannot convert ‘device_integer_array* {aka dev_arr*}’ to ‘const integer_array_t* {aka const base_array_s*}’ for argument ‘1’ to ‘mode lica_integer* integer_array_element_addr(const integer_array_t*, int, ...)’ array_alloc_scalar_integer_array(&tmp4, 10, (modelica_integer)(*integer_array_element_addr(&_p_localId, 1, /* modelica_integer */ (modelica_integer) 1)), (model ica_integer)(*integer_array_element_addr(&_p_localId, 1, /* modelica_integer */ (modelica_integer) 2)), (modelica_integer)(*integer_array_element_addr(&_p_localId, 1, /* modelica_integer */ (modelica_integer) 3)), (modelica_integer)(*integer_array_element_addr(&_p_localId, 1, /* modelica_integer */ (modelica_integer) 4)), (m odelica_integer)(*integer_array_element_addr(&_p_localId, 1, /* modelica_integer */ (modelica_integer) 5)), (modelica_integer)(*integer_array_element_addr(&_p_loca lId, 1, /* modelica_integer */ (modelica_integer) 6)), (modelica_integer)(*integer_array_element_addr(&_p_localId, 1, /* modelica_integer */ (modelica_integer) 7)) , (modelica_integer)(*integer_array_element_addr(&_p_localId, 1, /* modelica_integer */ (modelica_integer) 8)), (modelica_integer)(*integer_array_element_addr(&_p_ localId, 1, /* modelica_integer */ (modelica_integer) 9)), (modelica_integer)(*integer_array_element_addr(&_p_localId, 1, /* modelica_integer */ (modelica_integer) 10))); . . .
It is function signature mismatches between the normal run-time functions and the parmodelica run-time counterparts (passing values vs passing pointers). I am trying to decide which one to fix.
To fix normal run-time I suppose you should have some other ticket to work on, but maybe you already have.
comment:3 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Recheck. There is no test for this.
Ya I am already aware of this errors :). It's not the ocl* functions that are the problem though. It is the array copy functions. Specifically this line
where the returned gpu arrays are copied to cpu arrays. Btw for now you should expicitly copy these values.
It is function signature mismatches between the normal run-time functions and the parmodelica run-time counterparts (passing values vs passing pointers). I am trying to decide which one to fix.