Skip to content

Commit

Permalink
Merge pull request #108 from nlesc-dirac/lbfgs_dev2
Browse files Browse the repository at this point in the history
Lbfgs dev2
  • Loading branch information
HannoSpreeuw authored Aug 29, 2019
2 parents 6854c15 + 386ea74 commit aa34c69
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/MS/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int Data::TileSize = 120;
int Data::Nt= 6;
char *Data::SkyModel=NULL;
char *Data::Clusters=NULL;
int Data::format=0; /* old LSM */
int Data::format=1; /* defaut is LSM with 3rd order spectra */
double Data::nulow=2.0;
double Data::nuhigh=30.0;

Expand Down
10 changes: 6 additions & 4 deletions src/buildsky/create_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def radec_to_lm_SIN(ra0,dec0,ra,dec):


#### main clustering routine : Q clusters
def cluster_this(skymodel,Q,outfile,max_iterations):
def cluster_this(skymodel,Q,outfile,max_iterations=5):
SKY=read_lsm_sky(skymodel)
K=len(SKY)

Expand Down Expand Up @@ -243,7 +243,7 @@ def cluster_this(skymodel,Q,outfile,max_iterations):
C[ci,0]=X[sImax,0]
C[ci,1]=X[sImax,1]
sItmp[sImax]=0.0
#print C
#print(C)
# calculate weights

# arrays to store which cluster each source belongs to
Expand All @@ -264,15 +264,15 @@ def cluster_this(skymodel,Q,outfile,max_iterations):
mra=X[ci,0]
mdec=X[ci,1]
closest=find_closest(mra,mdec,C,Ccos,Csin)
#print "src %d closest %d"%(ci,closest)
#print("src %d closest %d"%(ci,closest))
CL[ci]=closest
# add this source to dict
if closest in D:
D[closest].append(ci)
else:
D[closest]=list()
D[closest].append(ci)
#print D
#print(D)

# check to see also if source assignment changes
if numpy.sum(CL-CLold)==0:
Expand Down Expand Up @@ -341,6 +341,8 @@ def cluster_this(skymodel,Q,outfile,max_iterations):

if opts.skymodel and opts.clusters and opts.outfile and opts.iterations:
cluster_this(opts.skymodel,opts.clusters,opts.outfile,opts.iterations)
elif opts.skymodel and opts.clusters and opts.outfile:
cluster_this(opts.skymodel,opts.clusters,opts.outfile)
else:
parser.print_help()
exit()
2 changes: 1 addition & 1 deletion src/lib/Dirac/lmfit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ bfgsfit_visibilities(double *u, double *v, double *w, double *x, int N,
lmdata.Nt=64; /* increase threads for MIC */
#endif
/* use LBFGS */
if (solver_mode==2 || solver_mode==3) {
if (solver_mode==SM_RLM_RLBFGS || solver_mode==SM_OSLM_OSRLM_RLBFGS || solver_mode==SM_RTR_OSRLM_RLBFGS || solver_mode==SM_NSD_RLBFGS ) {
lmdata.robust_nu=mean_nu;
lbfgs_fit_robust_wrapper(p, x, m, n, max_lbfgs, lbfgs_m, gpu_threads, (void*)&lmdata);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Dirac/lmfit_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ bfgsfit_visibilities_gpu(double *u, double *v, double *w, double *x, int N,

if (max_lbfgs>0) {
/* use LBFGS */
if (solver_mode==2 || solver_mode==3) {
if (solver_mode==SM_RLM_RLBFGS || solver_mode==SM_OSLM_OSRLM_RLBFGS || solver_mode==SM_RTR_OSRLM_RLBFGS || solver_mode==SM_NSD_RLBFGS) {
lmdata.robust_nu=mean_nu;
lbfgs_fit_robust_cuda(p, x, m, n, max_lbfgs, lbfgs_m, gpu_threads, (void*)&lmdata);
} else {
Expand Down
1 change: 1 addition & 0 deletions src/lib/Dirac/load_balance.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ destroy_task_hist(taskhist *th) {
in such a way to allow load balancing */
int
select_work_gpu(int max_gpu, taskhist *th) {
if (!max_gpu) return 0; /* no need to spend time if only one GPU is available */
#ifdef MPI_BUILD
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
Expand Down

0 comments on commit aa34c69

Please sign in to comment.