Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.
This repository was archived by the owner on Nov 19, 2020. It is now read-only.

Speed up matrix-vector operations #752

@CatchemAL

Description

@CatchemAL

A number of linear algebra operations in the library would benefit from being pinned and working directly with pointers. Creating this issue so it can be referenced in git commits. I will pick this up and send a PR once complete.

Vector-Matrix

This shows a comparison of Accord's vector.Dot(matrix, result) versus a proposed change pinning the arrays and using pointer arithmetic.

Size is the size of the matrix (so 32 means a 32 x 32 square matrix). Trials is the number of simulations run. The timings are shown next and then the speed multiplier is shown. So the bottom row shows it is 17 times faster to pin the array than Accord's current method.

Size Trials Accord (ms) Proposed (ms) Multiplier
8 4194304 750 368 x2
16 1048576 722 291 x2.5
32 262144 684 242 x2.8
64 65536 746 242 x3.1
128 16384 782 238 x3.3
256 4096 1049 227 x4.6
512 1024 1095 225 x4.9
1024 256 2936 256 x11.5
2048 64 3781 254 x14.9
4096 16 4373 255 x17.1

Matrix-Vector

This shows a comparison of Accord's matrix.Dot(vector, result) versus a proposed change pinning the arrays and using pointer arithmetic.

Size Trials Accord (ms) Proposed (ms) Multiplier
8 4194304 712 290 x2.5
16 1048576 707 225 x3.1
32 262144 714 206 x3.5
64 65536 702 199 x3.5
128 16384 696 185 x3.8
256 4096 688 182 x3.8
512 1024 717 179 x4
1024 256 697 205 x3.4
2048 64 697 199 x3.5
4096 16 698 200 x3.5

Thanks,
Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions