mn416 / QPULib

Language and compiler for the Raspberry Pi GPU
Other
430 stars 63 forks source link

3D Rotation example: different result each run with vector version 2 #1

Closed yoterel closed 7 years ago

yoterel commented 7 years ago

Hi, when running the example 3d rotation and tweeking the source to post vertex x[0] y[0] before and after transformation, i receieve different values each time i run the program (vector 2 is being used).

tested on raspberry pi 3.

the function i am writing about: void rot3D(Int n, Float cosTheta, Float sinTheta, Ptr x, Ptr y) { // Function index() returns vector <0 1 2 ... 14 15> Ptr p = x + index(); Ptr q = y + index(); // Pre-fetch first two vectors gather(p); gather(q);

Float xOld, yOld; //initialiased to nothing at first For (Int i = 0, i < n, i = i+16) // Pre-fetch two vectors for the next iteration gather(p+16); gather(q+16); // Receive vectors for this iteration receive(xOld); receive(yOld); // Store results store(xOld cosTheta - yOld sinTheta, p); store(yOld cosTheta + xOld sinTheta, q); p = p+16; q = q+16; End }

mn416 commented 7 years ago

Hi @yoterel, many thanks for the report.

After repeated runs of this example I was able to reproduce the non-deterministic behaviour you describe. I believe the problem arises because the Rot3D examples did not obey the following rule: for every call of gather() there should be a call of receive(). Breaking this rule could leave the QPUs in an inconsistent state. I've committed a fix. Let me know if you still encounter the problem.

mn416 commented 7 years ago

Hopefully this issue has been addressed. If not, please reopen.