Skip to content

Commit 94ce412

Browse files
committed
Let all 3 modules built with Glib use max number of cores by default like the OMP case.
1 parent 8423c31 commit 94ce412

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

doc/rst/source/explain_core.rst_

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**-x**\ [[-]\ *n*] :ref:`(more ...) <core_full>`
2-
Limit number of cores used in multi-threaded algorithms (OpenMP required).
2+
Limit number of cores used in multi-threaded algorithms (OpenMP required for most of modules,
3+
or Glib for grdfilter, gmt|grdgravmag3d).

src/grdfilter.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,11 @@ static int parse (struct GMT_CTRL *GMT, struct GRDFILTER_CTRL *Ctrl, struct GMT_
893893
}
894894
}
895895

896+
#ifdef HAVE_GLIB_GTHREAD
897+
/* Make the default equal to the OMP case where we use all threads if not stated otherwise. */
898+
if (!GMT->common.x.active) GMT->common.x.n_threads = gmtlib_get_num_processors();
899+
#endif
900+
896901
n_errors += gmt_M_check_condition (GMT, !Ctrl->G.active, "Option -G: Must specify output file\n");
897902
n_errors += gmt_M_check_condition (GMT, !Ctrl->In.file, "Must specify input file\n");
898903
n_errors += gmt_M_check_condition (GMT, !Ctrl->D.active, "Option -D: Choose from p or 0-5\n");

src/potential/gmtgravmag3d.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
252252
return (GMT_MODULE_USAGE);
253253
}
254254

255-
static int parse (struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, struct GMT_OPTION *options) {
255+
static int parse(struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, struct GMT_OPTION *options) {
256256

257257
/* This parses the options provided to gmtgravmag3d and sets parameters in Ctrl.
258258
* Note Ctrl has already been initialized and non-zero default values set.
@@ -453,6 +453,11 @@ static int parse (struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, struct G
453453
}
454454
}
455455

456+
#ifdef HAVE_GLIB_GTHREAD
457+
/* Make the default equal to the OMP case where we use all threads if not stated otherwise. */
458+
if (!GMT->common.x.active) GMT->common.x.n_threads = gmtlib_get_num_processors();
459+
#endif
460+
456461
n_errors += gmt_M_check_condition(GMT, Ctrl->S.active && (Ctrl->S.radius <= 0.0 || gmt_M_is_dnan (Ctrl->S.radius)),
457462
"Option -S: Radius is NaN or negative\n");
458463
n_errors += gmt_M_check_condition(GMT, !Ctrl->T.active && !Ctrl->M.active, "Options -T or -M are mandatory\n");

src/potential/grdgravmag3d.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static int usage (struct GMTAPI_CTRL *API, int level) {
262262
return (GMT_MODULE_USAGE);
263263
}
264264

265-
static int parse (struct GMT_CTRL *GMT, struct GRDGRAVMAG3D_CTRL *Ctrl, struct GMT_OPTION *options) {
265+
static int parse(struct GMT_CTRL *GMT, struct GRDGRAVMAG3D_CTRL *Ctrl, struct GMT_OPTION *options) {
266266

267267
/* This parses the options provided to grdgravmag3d and sets parameters in Ctrl.
268268
* Note Ctrl has already been initialized and non-zero default values set.
@@ -448,6 +448,11 @@ static int parse (struct GMT_CTRL *GMT, struct GRDGRAVMAG3D_CTRL *Ctrl, struct G
448448
}
449449
}
450450

451+
#ifdef HAVE_GLIB_GTHREAD
452+
/* Make the default equal to the OMP case where we use all threads if not stated otherwise. */
453+
if (!GMT->common.x.active) GMT->common.x.n_threads = gmtlib_get_num_processors();
454+
#endif
455+
451456
n_errors += gmt_M_check_condition(GMT, !Ctrl->In.file[0], "Must specify input file\n");
452457
n_errors += gmt_M_check_condition(GMT, Ctrl->S.active && (Ctrl->S.radius <= 0.0 || gmt_M_is_dnan(Ctrl->S.radius)),
453458
"Option -S: Radius is NaN or negative\n");

0 commit comments

Comments
 (0)