38
38
#include "src/util/name_fns.h"
39
39
#include "src/util/pmix_environ.h"
40
40
#include "src/util/pmix_show_help.h"
41
+ #include "src/util/pmix_string_copy.h"
41
42
42
43
#include "plm_slurm.h"
43
44
#include "src/mca/plm/base/plm_private.h"
@@ -84,28 +85,15 @@ prte_mca_plm_slurm_component_t prte_mca_plm_slurm_component = {
84
85
here; will be initialized in plm_slurm_open() */
85
86
};
86
87
87
- static char * custom_args = NULL ;
88
- static char * force_args = NULL ;
89
-
90
88
static int plm_slurm_register (void )
91
89
{
92
90
pmix_mca_base_component_t * comp = & prte_mca_plm_slurm_component .super ;
93
91
94
92
95
- prte_mca_plm_slurm_component .custom_args_index =
96
- pmix_mca_base_component_var_register (comp , "args" , "Custom arguments to srun" ,
97
- PMIX_MCA_BASE_VAR_TYPE_STRING ,
98
- & custom_args );
99
-
100
- force_args = NULL ;
101
- (void ) pmix_mca_base_component_var_register (comp , "force_args" , "Mandatory custom arguments to srun" ,
102
- PMIX_MCA_BASE_VAR_TYPE_STRING ,
103
- & force_args );
104
-
105
- prte_mca_plm_slurm_component .slurm_warning_msg = false;
106
- (void ) pmix_mca_base_component_var_register (comp , "disable_warning" , "Turn off warning message about custom args set in environment" ,
107
- PMIX_MCA_BASE_VAR_TYPE_BOOL ,
108
- & prte_mca_plm_slurm_component .slurm_warning_msg );
93
+ prte_mca_plm_slurm_component .custom_args = NULL ;
94
+ pmix_mca_base_component_var_register (comp , "args" , "Custom arguments to srun" ,
95
+ PMIX_MCA_BASE_VAR_TYPE_STRING ,
96
+ & prte_mca_plm_slurm_component .custom_args );
109
97
110
98
return PRTE_SUCCESS ;
111
99
}
@@ -117,40 +105,44 @@ static int plm_slurm_open(void)
117
105
118
106
static int prte_mca_plm_slurm_component_query (pmix_mca_base_module_t * * module , int * priority )
119
107
{
120
- const pmix_mca_base_var_t * var ;
121
- pmix_status_t rc ;
108
+ FILE * fp ;
109
+ char version [1024 ], * ptr ;
110
+ int major , minor ;
122
111
123
112
/* Are we running under a SLURM job? */
124
-
125
113
if (NULL != getenv ("SLURM_JOBID" )) {
126
114
* priority = 75 ;
127
115
128
116
PMIX_OUTPUT_VERBOSE ((1 , prte_plm_base_framework .framework_output ,
129
117
"%s plm:slurm: available for selection" ,
130
118
PRTE_NAME_PRINT (PRTE_PROC_MY_NAME )));
131
119
132
- prte_mca_plm_slurm_component .custom_args = NULL ;
133
-
134
- // if we were are warning about externally set custom args, then
135
- // check to see if that was done
136
- if (!prte_mca_plm_slurm_component .slurm_warning_msg &&
137
- NULL == force_args ) {
138
- // check for custom args
139
- rc = pmix_mca_base_var_get (prte_mca_plm_slurm_component .custom_args_index , & var );
140
- if (PMIX_SUCCESS == rc ) {
141
- // the variable was set - see who set it
142
- if (PMIX_MCA_BASE_VAR_SOURCE_ENV == var -> mbv_source ) {
143
- // set in the environment - warn
144
- pmix_show_help ("help-plm-slurm.txt" , "custom-args-in-env" , true,
145
- custom_args );
146
- }
147
- }
120
+ // check the version
121
+ fp = popen ("srun --version" , "r" );
122
+ if (NULL == fp ) {
123
+ // cannot run srun, so we cannot support this job
124
+ * module = NULL ;
125
+ return PRTE_ERROR ;
148
126
}
149
-
150
- if (NULL != force_args ) {
151
- prte_mca_plm_slurm_component .custom_args = force_args ;
152
- } else if (NULL != custom_args ) {
153
- prte_mca_plm_slurm_component .custom_args = custom_args ;
127
+ if (NULL == fgets (version , sizeof (version ), fp )) {
128
+ pclose (fp );
129
+ * module = NULL ;
130
+ return PRTE_ERROR ;
131
+ }
132
+ pclose (fp );
133
+ // parse on the dots
134
+ major = strtol (& version [6 ], & ptr , 10 );
135
+ ++ ptr ;
136
+ minor = strtol (ptr , NULL , 10 );
137
+
138
+ if (23 > major ) {
139
+ prte_mca_plm_slurm_component .early = true;
140
+ } else if (23 < major ) {
141
+ prte_mca_plm_slurm_component .early = false;
142
+ } else if (11 > minor ) {
143
+ prte_mca_plm_slurm_component .early = true;
144
+ } else {
145
+ prte_mca_plm_slurm_component .early = false;
154
146
}
155
147
156
148
* module = (pmix_mca_base_module_t * ) & prte_plm_slurm_module ;
0 commit comments