Changeset 5634
- Timestamp:
- 10/30/09 12:40:10 (3 weeks ago)
- Location:
- mpich2/trunk/src/pm/smpd
- Files:
-
- 3 modified
-
smpd.h (modified) (1 diff)
-
smpd_affinitize.c (modified) (7 diffs)
-
smpd_cmd_args.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mpich2/trunk/src/pm/smpd/smpd.h
r5117 r5634 981 981 DWORD_PTR smpd_get_next_process_affinity_mask(void ); 982 982 DWORD_PTR smpd_get_processor_affinity_mask(int proc_num); 983 voidsmpd_init_affinity_table(void );983 BOOL smpd_init_affinity_table(void ); 984 984 #endif 985 985 -
mpich2/trunk/src/pm/smpd/smpd_affinitize.c
r4983 r5634 40 40 { 41 41 DWORD_PTR Mask; 42 if (s_affinity_max == 0) 42 if (s_affinity_max == 0){ 43 smpd_dbg_printf("Affinity table not initialized. Returning invalid mask\n"); 43 44 return 0; 45 } 44 46 45 47 Mask = s_affinity_table[s_affinity_idx % s_affinity_max]; … … 246 248 are distributed so as to balance the use of system resources. 247 249 */ 248 void smpd_init_affinity_table() 250 typedef BOOL (WINAPI *LPFN_GetLogicalProcessorInformation)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD); 251 BOOL smpd_init_affinity_table() 249 252 { 250 253 /* … … 252 255 */ 253 256 int count, nTableEntries; 254 BOOL fSucc ;257 BOOL fSucc, retval = TRUE; 255 258 DWORD Length; 256 259 DWORD_PTR SystemMask, ReserveMask, PrimaryMask; … … 258 261 SYSTEM_LOGICAL_PROCESSOR_INFORMATION* pInfo = NULL; 259 262 ResourceTableEntry* pTable = NULL; 263 LPFN_GetLogicalProcessorInformation lpfn_get_logical_proc_info; 260 264 261 265 fSucc = GetProcessAffinityMask(GetCurrentProcess(), &UsableProcessorMask, &SystemMask); 262 if(!fSucc) 263 return; 264 266 if(!fSucc){ 267 return FALSE; 268 } 269 270 /* Check if GetLogicalProcessorInformation() is available */ 271 lpfn_get_logical_proc_info = 272 (LPFN_GetLogicalProcessorInformation ) GetProcAddress(GetModuleHandle(TEXT("kernel32")), 273 "GetLogicalProcessorInformation"); 274 if(lpfn_get_logical_proc_info == NULL){ 275 smpd_dbg_printf("GetLogicalProcessorInformation() not available\n"); 276 return FALSE; 277 } 265 278 /* 266 279 Retrieve the length required to store the processor information data 267 280 */ 268 281 Length = 0; 269 /* FIXME: Check return val */ 270 GetLogicalProcessorInformation(NULL, &Length); 271 if(Length == 0) 272 return; 282 /* This call will fail - however it will return the length reqd to store proc info*/ 283 fSucc = lpfn_get_logical_proc_info(NULL, &Length); 284 if(Length == 0){ 285 smpd_dbg_printf("GetLogicalProcessorInformation() returned invalid (0 bytes) length to store proc info\n"); 286 return FALSE; 287 } 273 288 274 289 /* … … 276 291 */ 277 292 pInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION*) malloc(Length); 278 if(pInfo == NULL) 279 return; 293 if(pInfo == NULL){ 294 smpd_err_printf("Allocating memory for system logical proc info failed\n"); 295 return FALSE; 296 } 280 297 281 298 /* 282 299 Query for the processors information 283 300 */ 284 fSucc = GetLogicalProcessorInformation(pInfo, &Length); 285 if(!fSucc) 286 goto fn_exit; 301 fSucc = lpfn_get_logical_proc_info(pInfo, &Length); 302 if(!fSucc){ 303 smpd_err_printf("GetLogicalProcessorInformation() failed (error = %d)\n", GetLastError()); 304 goto fn_fail; 305 } 287 306 288 307 count = Length / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); … … 294 313 295 314 pTable = (ResourceTableEntry*) malloc(count * sizeof(ResourceTableEntry)); 296 if (pTable == NULL) 297 goto fn_exit; 315 if (pTable == NULL){ 316 smpd_err_printf("Allocating memory for Resourcetableentry failed\n"); 317 goto fn_fail; 318 } 298 319 299 320 /* … … 326 347 327 348 free(pTable); 328 fn_exit:349 fn_exit: 329 350 free(pInfo); 351 return retval; 352 fn_fail: 353 retval = FALSE; 354 goto fn_exit; 330 355 } 331 356 -
mpich2/trunk/src/pm/smpd/smpd_cmd_args.c
r5462 r5634 446 446 } 447 447 #ifdef HAVE_WINDOWS_H 448 /* FIXME: smpd_init_affinity_table() Does not return error codes if it fails */ 449 smpd_init_affinity_table(); 448 { 449 BOOL ret; 450 ret = smpd_init_affinity_table(); 451 if(!ret){ 452 smpd_dbg_printf("Initializing smpd affinity table failed\n"); 453 } 454 } 450 455 #endif 451 456
