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

Check 'thread' on Windows #3184

Closed
jgillis opened this issue May 13, 2023 Discussed in #3142 · 1 comment
Closed

Check 'thread' on Windows #3184

jgillis opened this issue May 13, 2023 Discussed in #3142 · 1 comment
Milestone

Comments

@jgillis
Copy link
Member

jgillis commented May 13, 2023

Discussed in #3142

@jgillis jgillis added this to the Version 3.6.3 milestone May 13, 2023
@jgillis
Copy link
Member Author

jgillis commented May 17, 2023

Test script:

from casadi import *
import os


n_threads = os.cpu_count()//2

N = 1000

x = MX.sym("x",N)

y = sin(x)

for i in range(10000):
    y = sin(y)

f = Function("f",[x],[y])

import time


results = {}
for type in ["serial","thread"]:

    F = f.map(n_threads,type)

    X_ = np.random.random((N,n_threads*N))
    Y_ = np.zeros((N,n_threads*N))
   
    # Use buffered evaluation to avoid overhead

    [buf,F_eval] = F.buffer()
    buf.set_arg(0, memoryview(X_))
    buf.set_res(0, memoryview(Y_))

    t0 = time.time()
    F_eval()
    dt = time.time()-t0
    print("Time ", type, ": " , dt)
    
    results[type] = dt

print("Speedup: ", results["serial"]/results["thread"], " - expected :", n_threads)

@jgillis jgillis closed this as completed May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant