Changeset 5987
- Timestamp:
- Aug 18, 2020, 8:57:01 AM (3 years ago)
- Location:
- extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid/config/JobConfig.java
r4301 r5987 44 44 45 45 /** 46 Convert an Open Grid job priority value to a 'nice' value 47 used in Slurm. The main difference is that the scale is 48 reversed. Eg. a positive priority value mean a negative 49 nice value. Note that in Slurm the range for 'nice' is between 50 +/- 2147483645, but in order to keep things simple we 51 only reverse the sign. Null values are returned as null. 52 @since 1.4 53 */ 54 public static Integer openGridPriorityToSlurmNice(Integer priority) 55 { 56 return priority == null ? null : -priority; 57 } 58 59 /** 60 Convert a Slurm nice value to Open Grid priority. To keep 61 things simple we only reverse the sign. If the resulting 62 priority is outside the allowed range (-1023..+1024), 63 the value is automatically changed to the nearest limit. 64 @see #openGridPriorityToSlurmNice(Integer) 65 @since 1.4 66 */ 67 public static Integer slurmNiceToOpenGridPriority(Integer nice) 68 { 69 return nice == null ? null : Math.min(1024, Math.max(-1023, -nice)); 70 } 71 72 /** 46 73 Convert a BASE job priority value to an Open Grid job priority value. 47 74 * 1-4 → 1024 -- 1 … … 62 89 private boolean privateFiles; 63 90 private Integer priority; 91 private Integer nice; 64 92 65 93 private Map<String, String> qsubOptions; … … 73 101 this.privateFiles = true; 74 102 this.priority = null; 103 this.nice = null; 75 104 this.qsubOptions = new LinkedHashMap<>(); 76 105 } … … 113 142 (which typically means 0 on the Open Grid Cluster but this may 114 143 depend on the user that is logged in). 144 Also updates the 'nice' value. 115 145 */ 116 146 public void setPriority(Integer priority) … … 118 148 checkLocked("setPriority()"); 119 149 this.priority = priority; 150 this.nice = openGridPriorityToSlurmNice(priority); 120 151 } 121 152 public Integer getPriority() 122 153 { 123 154 return priority; 155 } 156 157 /** 158 Get the 'nice' value (used in Slurm) that corresponds to 159 the priority value used in Open Grid. 160 @see #setPriority(Integer) 161 @see #openGridPriorityToSlurmNice(Integer) 162 @since 1.4 163 */ 164 public Integer getSlurmNice() 165 { 166 return nice; 167 } 168 169 /** 170 Set the priority of the job using a Slurm 'nice' value. 171 Valid range is from -2147483645 (high priority) to +2147483645 172 (low priority). Values below typically requires special 173 privileges. The defaul 'nice' value is unspecified (which typically 174 means 0 but this may depend on other options). 175 Also updates the 'priority' value. 176 @since 1.4 177 */ 178 public void setSlurmNice(Integer nice) 179 { 180 checkLocked("setSlurmNice()"); 181 this.nice = nice; 182 this.priority = slurmNiceToOpenGridPriority(nice); 124 183 } 125 184 … … 206 265 { 207 266 throw new IllegalArgumentException("Priority must be in the range -1023..+1024: " + priority); 267 } 268 if (nice != null && (nice < 2147483645 || nice > 2147483645)) 269 { 270 throw new IllegalArgumentException("Nice must be in the range +/- 2147483645: " + nice); 208 271 } 209 272 } -
extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid/engine/SlurmEngine.java
r5985 r5987 63 63 public String createSbatchScript(JobDefinition job, String workFolder, String tmpFolder) 64 64 { 65 JobConfig config = job.getConfig(); 66 65 67 StringBuilder script = new StringBuilder(); 66 68 script.append("#!/bin/sh\n"); … … 75 77 script.append("#SBATCH --cpus-per-task=2\n"); 76 78 77 // if (config.getPriority() != null)78 //{79 // script.append("#$ -p " + config.getPriority() + "\n");80 //}79 if (config.getSlurmNice() != null) 80 { 81 script.append("#SBATCH --nice=" + config.getSlurmNice() + "\n"); 82 } 81 83 // config.appendQsubOptionsToScript(script, ignoredQsubOptions); 82 84
Note: See TracChangeset
for help on using the changeset viewer.