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

Multithreading not working #180

Open
scepeda78 opened this issue May 13, 2021 · 8 comments
Open

Multithreading not working #180

scepeda78 opened this issue May 13, 2021 · 8 comments

Comments

@scepeda78
Copy link

scepeda78 commented May 13, 2021

Hi all,

I have 32 cores, and when putting NThreads as 20, it doesn't do the mutilthreading. I have set 25 cores in the JULIA_NUM_THREADS=25, but i cannot see any difference or use of the threads. My function costo took 45 secs to run, and therefore it's a slow function. Any ideas of the issue? My Julia version is 1.6.0

function costo(x)
    total=sum(x[2:5])
    utilidadcorte=x[1]
    pesopayback=x[2]/total
    pesoenv=x[3]/total
    pesoingreso=x[4]/total
    pesored=x[5]/total
    anoinicio=2015
    anofinal=2019
    vidautil=25
    factores=Dict{Int,Float64}()
    for ano in anoinicio:(anofinal+1)
        indice=ano-2015+6
        factores[ano]=x[indice]
    end
    activarerror=true   
    verbose=false
    modelo,error=simular(utilidadcorte,factores,pesopayback,pesoenv,pesoingreso,pesored,anoinicio,anofinal,vidautil,activarerror,verbose);
    return error

end
    result = bboptimize(
        costo;
        SearchRange = (0.0, 1.0),
        NumDimensions = 11,
        TraceMode=:verbose,
        MaxTime = 500,
        NThreads=20
    )
@robertfeldt
Copy link
Owner

Yes, I have also noted there is problem with multi-threaded evaluation on latest Julia versions. I will deactivate the multi-threaded tests on master for now and release a new version and will have to get back to this problem later. Sorry for this, but the multi-threading was not implemented by me and I will need more time to fix it. Will keep this thread open to investigate more.

@scepeda78
Copy link
Author

@robertfeldt do you remember the version that was working with Julia?

@robertfeldt
Copy link
Owner

I think it worked on 1.0 but there has been different reports about problems from 1.1 and forward. However, I wouldn't put too much work into this since there is a new user-level parallelism feature in the works now which should make it much easier to do multi-threaded eval of the fitness function calls. You can see another issue here on GitHub where it has been discussed. I'm currently modeling the solution on the one used in Cubature.jl. Inputs/ideas welcome.

@davidschlegel
Copy link

Any progress on implementing multithreading on the latest julia version?

@ruizhi92
Copy link

ruizhi92 commented Nov 3, 2021

Multithreading is really needed for optimization, hope this issue can be fixed :)

@longemen3000
Copy link

if i understand correctly, for multithreading to work,it is necessary to make a (working) MultithreadedEvaluator ?

@robertfeldt
Copy link
Owner

My plan is actually to switch and make multi-threading the default for function evaluation. I need to check if there might be any adverse affects but I doubt it since the function evaluation just happens in a loop "outside" of the lib itself. Since multi-core has been the default for most machines for long I think it is time we just make that the default.

@oameye
Copy link

oameye commented Feb 15, 2024

@robertfeldt Could you give me some details about what is going wrong and what has to happen to solve this? Do you know of any alternative global optimizer with multithreading functionality?

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

6 participants