Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out a way to speed up matrix operation in python #19

Open
einarf opened this issue Jun 27, 2018 · 3 comments
Open

Figure out a way to speed up matrix operation in python #19

einarf opened this issue Jun 27, 2018 · 3 comments
Labels
enhancement future some time in the future..

Comments

@einarf
Copy link
Member

einarf commented Jun 27, 2018

From #18

We are currently using pyrr for matrix operations. The main problem with pyrr is that it crates new instances for every calculation allocating a new ndarray. This is very expensive.

As an example:
https://github.com/adamlwgriffiths/Pyrr/blob/a86968b7ed242017247e27ac8a0e7b84bca0c333/pyrr/matrix44.py#L223-L236

numpy.dot has an out parameter to store the result in an existing ndarray. This avoids memory allocation.

@einarf
Copy link
Member Author

einarf commented Jun 27, 2018

We should possibly also try to make the default dtype of matrix types ti be a 32 bit float as these can be converted directly into uniforms with tobytes.

Numpy:

The default depends on your system. On a 64-bit system, default types will be 64-bit. On a 32-bit system, default types will be 32-bit. There is no way to change the default short of re-compiling numpy with a different system C header.

This could mean we have to do something about pyrr.

@einarf
Copy link
Member Author

einarf commented Jun 27, 2018

A branch matrix-performance was crated for this. Managed to boost performance by 10% ish by doing some simple tweaks with a local branch of pyrr. It's unlikely that using pyrr will ever be efficient when drawing complex scenes. Might want to turn a solution in ModernGL for this.

@einarf einarf added the future some time in the future.. label Jul 12, 2018
@einarf
Copy link
Member Author

einarf commented Aug 2, 2018

This looks like the solution:
https://github.com/cprogrammer1994/miniglm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement future some time in the future..
Projects
None yet
Development

No branches or pull requests

1 participant