Giter Club home page Giter Club logo

Comments (9)

adtzlr avatar adtzlr commented on May 25, 2024

A possible solution would be to update globals with felupe.use_numba() or something similar. For example, the __init__.py file contains an import statement for a function fun.

from ._python import fun

If form.assemble(parallel=True) is called, the functions should be replaced by numba-accelerated functions

def use_numba():
    from ._numba import fun
    globals().update(fun=fun)

from felupe.

adtzlr avatar adtzlr commented on May 25, 2024

equivalent to globals()["fun"] = fun or globals().update(fun=fun) is also import sys; fe = sys.modules[__name__]; fe.fun=fun

from felupe.

adtzlr avatar adtzlr commented on May 25, 2024

In the past (alpha versions) this was complicated but now that everything is organized in folders/files this should be an easy task.

from felupe.

adtzlr avatar adtzlr commented on May 25, 2024

see branch https://github.com/adtzlr/felupe/tree/improve-numba-jit

from felupe.

adtzlr avatar adtzlr commented on May 25, 2024

okay, it seems this commit slows down import time even more.

from felupe.

adtzlr avatar adtzlr commented on May 25, 2024

Inspecting __init__.py gives:

from .__about__ import __version__

import time 
t = []

t.append(time.time())
from . import math
t.append(time.time())
from . import mesh
t.append(time.time())
from . import quadrature
t.append(time.time())
from . import dof
t.append(time.time())
from . import element
t.append(time.time())
from . import tools
t.append(time.time())
from . import constitution
t.append(time.time())
from . import solve
t.append(time.time())
from . import region
t.append(time.time())

import numpy as np
print(np.diff(np.array(t)))
# ...

produces

In [1]: import felupe
[0.00519323 0.01053238 2.14523649 0.87573862 0.05784726 0.38405085
 0.00819564 0.         0.00375438]

from felupe.

adtzlr avatar adtzlr commented on May 25, 2024

It seems most of the time is spent on importing quadrature due to quadpy followed by dof due to `sparse´.

from felupe.

adtzlr avatar adtzlr commented on May 25, 2024

As we only use Legendre-Gauss rules quadpy could be removed - NumPy has them built-in. See https://numpy.org/doc/stable/reference/routines.polynomials.legendre.html

points, weights = numpy.polynomial.legendre.leggauss(deg)

from felupe.

adtzlr avatar adtzlr commented on May 25, 2024
x, y = np.polynomial.legendre.leggauss(3)
w, v, u = np.meshgrid(x, x, x, indexing="ij")
points = np.vstack((u.ravel(), v.ravel(), w.ravel())).T
weights = np.einsum("i,j,k",y,y,y).ravel()

from felupe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.