diff --git a/doc/rst/source/explain_core.rst_ b/doc/rst/source/explain_core.rst_ index 6c58a331214..b427144f76e 100644 --- a/doc/rst/source/explain_core.rst_ +++ b/doc/rst/source/explain_core.rst_ @@ -1,3 +1,4 @@ **-x**\ [[-]\ *n*] :ref:`(more ...) ` - Limit number of cores used in multi-threaded algorithms (OpenMP required for most of modules, - or Glib for grdfilter, gmt|grdgravmag3d). + Limit number of cores used in multi-threaded algorithms. Multi-threaded behavior is enabled by default. + That covers the modules that implement the OpenMP API (required at compiling stage) and GThreads (Glib) + for the grdfilter module. diff --git a/src/gmt_init.c b/src/gmt_init.c index a492306137a..207d3ed6d1b 100644 --- a/src/gmt_init.c +++ b/src/gmt_init.c @@ -2607,8 +2607,8 @@ GMT_LOCAL int gmtinit_parse_U_option (struct GMT_CTRL *GMT, char *item) { } /*! -x[[-]] */ +GMT_LOCAL int gmtinit_parse_x_option (struct GMT_CTRL *GMT, char *arg) { /* Only effective if MP is enabled */ #ifdef GMT_MP_ENABLED -GMT_LOCAL int gmtinit_parse_x_option (struct GMT_CTRL *GMT, char *arg) { GMT->common.x.active = true; if (!arg) return (GMT_PARSE_ERROR); /* -x requires a non-NULL argument */ if (arg[0] == '\0') /* Use all processors */ @@ -2622,9 +2622,9 @@ GMT_LOCAL int gmtinit_parse_x_option (struct GMT_CTRL *GMT, char *arg) { GMT->common.x.n_threads = MAX(gmtlib_get_num_processors() - abs (GMT->common.x.n_threads), 1); /* Max-n but at least one */ if (GMT->current.setting.max_cores) /* Limit to max core defaults setting */ GMT->common.x.n_threads = GMT->current.setting.max_cores; +#endif return (GMT_NOERROR); } -#endif /*! . */ GMT_LOCAL int gmtinit_parse_colon_option (struct GMT_CTRL *GMT, char *item) { @@ -9151,9 +9151,12 @@ int gmt_default_error (struct GMT_CTRL *GMT, char option) { case 's': error += GMT->common.s.active == false; break; case 't': error += GMT->common.t.active == false; break; case 'w': error += GMT->common.w.active == false; break; -#if defined(GMT_MP_ENABLED) - case 'x': error += GMT->common.x.active == false; break; + case 'x': error += GMT->common.x.active == false; +#if !defined(GMT_MP_ENABLED) + error --; + GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "Option -x: GMT is not compiled with parallel support. Only one core is used\n"); #endif + break; case ':': error += GMT->common.colon.active == false; break; default: @@ -18792,12 +18795,13 @@ int gmt_parse_common_options (struct GMT_CTRL *GMT, char *list, char option, cha error += gmt_M_more_than_once (GMT, GMT->common.w.active) || gmtinit_parse_w_option (GMT, item); break; -#ifdef GMT_MP_ENABLED case 'x': error += (gmt_M_more_than_once (GMT, GMT->common.x.active) || gmtinit_parse_x_option (GMT, item)); GMT->common.x.active = true; - break; +#if !defined(GMT_MP_ENABLED) + GMT_Report (GMT->parent, GMT_MSG_WARNING, "Option -x: GMT is not compiled with parallel support. Only one core is used\n"); #endif + break; case ':': error += (gmt_M_more_than_once (GMT, GMT->common.colon.active) || gmtinit_parse_colon_option (GMT, item)); diff --git a/src/grdfilter.c b/src/grdfilter.c index 7c67882b7e4..c70cd9b8cb6 100644 --- a/src/grdfilter.c +++ b/src/grdfilter.c @@ -896,9 +896,9 @@ static int parse (struct GMT_CTRL *GMT, struct GRDFILTER_CTRL *Ctrl, struct GMT_ #ifdef HAVE_GLIB_GTHREAD /* Make the default equal to the OMP case where we use all threads if not stated otherwise. */ if (Ctrl->F.custom && GMT->common.x.n_threads > 1) { - //GMT->common.x.n_threads = 1; - //GMT->common.x.active = false; - //GMT_Report (GMT->parent, GMT_MSG_WARNING, "Sorry, custom filtering does not support multiple threads. Reset to 1.\n" ); + GMT->common.x.n_threads = 1; + GMT->common.x.active = false; + GMT_Report (GMT->parent, GMT_MSG_WARNING, "Sorry, custom filtering does not support multiple threads. Reset to 1.\n" ); } if (!GMT->common.x.active) { GMT->common.x.n_threads = API->n_cores; diff --git a/src/potential/gmtgravmag3d.c b/src/potential/gmtgravmag3d.c index ea14836a81f..1c2da2a8828 100644 --- a/src/potential/gmtgravmag3d.c +++ b/src/potential/gmtgravmag3d.c @@ -453,11 +453,6 @@ static int parse(struct GMT_CTRL *GMT, struct GMTGRAVMAG3D_CTRL *Ctrl, struct GM } } -#ifdef HAVE_GLIB_GTHREAD - /* Make the default equal to the OMP case where we use all threads if not stated otherwise. */ - if (!GMT->common.x.active) GMT->common.x.n_threads = API->n_cores; -#endif - n_errors += gmt_M_check_condition(GMT, Ctrl->S.active && (Ctrl->S.radius <= 0.0 || gmt_M_is_dnan (Ctrl->S.radius)), "Option -S: Radius is NaN or negative\n"); n_errors += gmt_M_check_condition(GMT, !Ctrl->T.active && !Ctrl->M.active, "Options -T or -M are mandatory\n"); diff --git a/src/potential/grdgravmag3d.c b/src/potential/grdgravmag3d.c index cbb40c6b925..168384fb56c 100644 --- a/src/potential/grdgravmag3d.c +++ b/src/potential/grdgravmag3d.c @@ -448,11 +448,6 @@ static int parse(struct GMT_CTRL *GMT, struct GRDGRAVMAG3D_CTRL *Ctrl, struct GM } } -#ifdef HAVE_GLIB_GTHREAD - /* Make the default equal to the OMP case where we use all threads if not stated otherwise. */ - if (!GMT->common.x.active) GMT->common.x.n_threads = API->n_cores; -#endif - n_errors += gmt_M_check_condition(GMT, !Ctrl->In.file[0], "Must specify input file\n"); n_errors += gmt_M_check_condition(GMT, Ctrl->S.active && (Ctrl->S.radius <= 0.0 || gmt_M_is_dnan(Ctrl->S.radius)), "Option -S: Radius is NaN or negative\n");