var pa1 = new ParallelArray([1, 2, 3, 4]);
pa1.map(function (x) { x = 0; return 1; });
In the generated OpenCL code, the variable x is declared and initialized as
const double RTl_x = tempThis[_readoffset];
This means x cannot be modified in the elemental function and thus x = 0; would cause an OpenCL compiler error. So why is RTl_x declared as a const variable here? Is this restriction documented anywhere?
This was a bug in code generation. The programming model does not prevent these variables from being modified in JavaScript. This is now also reflected in the code generation.
Take the follow code as an example :
In the generated OpenCL code, the variable
x
is declared and initialized asThis means
x
cannot be modified in the elemental function and thusx = 0;
would cause an OpenCL compiler error. So why isRTl_x
declared as a const variable here? Is this restriction documented anywhere?Thanks Jiajie