MilesCranmer commited on
Commit
02e2655
1 Parent(s): 55f53cf

Make job spawn asynchronous

Browse files
Files changed (1) hide show
  1. julia/sr.jl +13 -11
julia/sr.jl CHANGED
@@ -791,7 +791,7 @@ function fullRun(niterations::Integer;
791
 
792
  # # 2. Start the cycle on every process:
793
  @sync for i=1:npopulations
794
- @async allPops[i] = @spawnat :any run(fetch(allPops[i]), ncyclesperiteration, verbosity=verbosity)
795
  end
796
  println("Started!")
797
  cycles_complete = npopulations * niterations
@@ -868,20 +868,22 @@ function fullRun(niterations::Integer;
868
  end
869
  end
870
 
871
- allPops[i] = @spawnat :any let
872
- tmp_pop = run(cur_pop, ncyclesperiteration, verbosity=verbosity)
873
- for j=1:tmp_pop.n
874
- if rand() < 0.1
875
- tmp_pop.members[j].tree = simplifyTree(tmp_pop.members[j].tree)
876
- tmp_pop.members[j].tree = combineOperators(tmp_pop.members[j].tree)
877
- if shouldOptimizeConstants
878
- tmp_pop.members[j] = optimizeConstants(tmp_pop.members[j])
 
 
879
  end
880
  end
 
881
  end
882
- tmp_pop
883
  end
884
- @async put!(channels[i], fetch(allPops[i]))
885
 
886
  cycles_complete -= 1
887
  num_equations += ncyclesperiteration * npop / 10.0
 
791
 
792
  # # 2. Start the cycle on every process:
793
  @sync for i=1:npopulations
794
+ @async allPops[i] = @spawn run(fetch(allPops[i]), ncyclesperiteration, verbosity=verbosity)
795
  end
796
  println("Started!")
797
  cycles_complete = npopulations * niterations
 
868
  end
869
  end
870
 
871
+ @async begin
872
+ allPops[i] = @spawn let
873
+ tmp_pop = run(cur_pop, ncyclesperiteration, verbosity=verbosity)
874
+ for j=1:tmp_pop.n
875
+ if rand() < 0.1
876
+ tmp_pop.members[j].tree = simplifyTree(tmp_pop.members[j].tree)
877
+ tmp_pop.members[j].tree = combineOperators(tmp_pop.members[j].tree)
878
+ if shouldOptimizeConstants
879
+ tmp_pop.members[j] = optimizeConstants(tmp_pop.members[j])
880
+ end
881
  end
882
  end
883
+ tmp_pop
884
  end
885
+ put!(channels[i], fetch(allPops[i]))
886
  end
 
887
 
888
  cycles_complete -= 1
889
  num_equations += ncyclesperiteration * npop / 10.0