Use JIT to skfem.asm #1094
Replies: 2 comments 4 replies
-
There is no definite answers yet, any ideas are welcome. Some facts:
To minimize the back and forth, you should try to do as much as possible using a single numpy call within the form function. Another idea is to JIT the entire function, to evaluate everything in one low level call. We are still bound to do N^2 evaluations of the JITted form. Can you give examples of the forms you assemble and mesh size? |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm sorry, I didn't quite understand all your answers. I'll try to ask again where I couldn't understand in your answer. Also, I'll try to give you an example of my case (it became too big now so it's impossible to put the entire code). And Thank you for the answer btw! Please correct me if I'm wrong. > If you have N basis functions per element, the form function (wrapped by BilinearForm) gets evaluated N^2 times
> The inputs u and v to the form are largeish Nelems x Nqp numpy arrays > If you have lots of such operations, it involves going back and forth between numpy low level and Python high level code > To minimize the back and forth, you should try to do as much as possible using a single numpy call within the form function. Another idea is to JIT the entire function, to evaluate everything in one low level call. We are still bound to do N^2 evaluations of the JITted form. My form function is like this:
I have 8 coupled transport equations (Poisson-typed), and because they are coupled either in the diffusion coefficient (A) or f . So there are # of single case iterations * n times skfem.asm process. For now, I'm using 1D mesh with 200 - 1000 mesh elements, but since there are so many iterations, it's already slow. If you can direct me to a simpler (relatively) example, that would be really helpful. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Hi, I have read some old discussions and some of them used JIT to speed up the code.
I also want to do something similar, but I'm not fully sure how to apply JIT to skfem. Especially, a code I'm working on right now does a lot of skfem.asm() to build jacobians iteratively, and that makes the speed of the code super slow.
Is there a simpler example that uses JIT with scikit-fem? such as the Poisson example?
Thank you, as always.
Beta Was this translation helpful? Give feedback.
All reactions