Improving dot product for standard multidimensional D arrays
jmh530
john.michael.hall at gmail.com
Mon Mar 2 20:56:50 UTC 2020
On Monday, 2 March 2020 at 20:22:55 UTC, p.shkadzko wrote:
> [snip]
>
> Interesting growth of processing time. Could it be GC?
>
> +------------------+-------------+
> | matrixDotProduct | time (sec.) |
> +------------------+-------------+
> | 2x[100 x 100] | 0.01 |
> | 2x[1000 x 1000] | 2.21 |
> | 2x[1500 x 1000] | 5.6 |
> | 2x[1500 x 1500] | 9.28 |
> | 2x[2000 x 2000] | 44.59 |
> | 2x[2100 x 2100] | 55.13 |
> +------------------+-------------+
Your matrixDotProduct creates a new Matrix and then returns it.
When you look at the Matrix struct, it is basically building upon
D's GC-backed slices. So yes, you are using the GC here.
You could try creating the output matrices outside of the
matrixDotProduct function and then pass them by pointer or
reference into the function if you want to profile just the
calculation.
More information about the Digitalmars-d-learn
mailing list