I’m doing some performance research on the fork/join framework in Java 7. To improve the test results I want to use different recursive algorithms during the tests. One of t
You are accumulating the results in C[cRow + i][cCol + j] += s00;
and the like. This is not a thread safe operation so you must synchronize the row or ensure that only one task ever updates the cell. Without this you will see random cells being set incorrectly.
I would check you get the right answer with a concurrency of 1.
BTW: float
may not be the best choice here. It has a fairly low number of digits of precision and in heavy matrix operations (which I assume you are doing or there wouldn't be much point using multiple threads) the rounding error can use up most or all your precision. I would suggest considering double
instead.
e.g. float
has about 7 digits of precision and one rule of thumb is that the error is proportional to the number of calculations. So for a 1K x 1K matrix you might have 4 digits of precision left. For 10K x 10K you might only have three at best. double
has 16 digits of precision meaning you may have 12 digits of precision after a 10K x 10K mutlipication.