Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • T transonic
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • fluiddyn
  • transonic
  • Issues
  • #43
Closed
Open
Created Apr 16, 2021 by rqwa@rqwa

@jit runs uncompiled code at first execution

This ticket is related to this stackoverflow question.

I use an adapted version of the bug.py from #40 (closed) .

import numpy as np
from transonic import jit,boost
from transonic.util import timeit_verbose

def norming(np_array: "float[:,:]"):
    norm_array = np.linalg.norm(np_array, axis=1)
    return norm_array

norming_pythran = jit(norming)

in_arr = np.random.rand(20000, 5)

def timeit(statement, norm=None):
    return timeit_verbose(statement, globals=globals(), norm=norm)

norm = timeit("norming(in_arr)")

timeit("norming_pythran(in_arr)", norm=norm)

I run two versions of the code, once with in_arr = np.random.rand(20000, 5) and once with in_arr = np.random.rand(20000, 500). Between the two versions I delete ~/.transonic/pythran/__jit__/bug.

Output (20000,5):

% python bug.py
norming                          :     1 * norm
norm = 0.000448 s
Schedule pythranization: norming.py
INFO: Schedule pythranization: norming.py
norming_pythran                  :  1.03 * norm


% python bug.py
norming                          :     1 * norm
norm = 0.000449 s
norming_pythran                  : 0.287 * norm

Output (20000,500):

% python bug.py                                                                0 [9:44:54]
norming                          :     1 * norm
norm = 0.0513 s
Schedule pythranization: norming.py
INFO: Schedule pythranization: norming.py
norming_pythran                  :  1.03 * norm

% python bug.py                                                                0 [9:45:03]
norming                          :     1 * norm
norm = 0.0673 s
norming_pythran                  : 0.198 * norm

The first code execution shows no acceleration from pyhtran. It seems like only for all following executions the compiled code is used. Is this the expected behavior?

The configuration can be found here.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking