Skip to content
Snippets Groups Projects
Commit 0b4ff233 authored by Moe Jette's avatar Moe Jette
Browse files

With some restrictions and less than optimal algorithms, node selections

is functioning. Time about 3msec with little variation for cluster or job
size. - Jette
parent 3d87b2b0
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ int Msg_From_Root(void); ...@@ -26,7 +26,7 @@ int Msg_From_Root(void);
#if DEBUG_MODULE #if DEBUG_MODULE
/* main is used here for testing purposes only */ /* main is used here for testing purposes only */
main(int argc, char * argv[]) { main(int argc, char * argv[]) {
int Error_Code, Line_Num; int Error_Code, Line_Num, i;
FILE *Command_File; FILE *Command_File;
char In_Line[BUF_SIZE], Node_Name[MAX_NAME_LEN]; char In_Line[BUF_SIZE], Node_Name[MAX_NAME_LEN];
int CPUs, RealMemory, TmpDisk; int CPUs, RealMemory, TmpDisk;
...@@ -53,6 +53,12 @@ main(int argc, char * argv[]) { ...@@ -53,6 +53,12 @@ main(int argc, char * argv[]) {
exit(Error_Code); exit(Error_Code);
} /* if */ } /* if */
/* Mark everything up and idle for testing */
for (i=0; i<Node_Record_Count; i++) {
BitMapSet(Idle_NodeBitMap, i);
BitMapSet(Up_NodeBitMap, i);
} /* for */
Error_Code = gethostname(Node_Name, MAX_NAME_LEN); Error_Code = gethostname(Node_Name, MAX_NAME_LEN);
if (Error_Code != 0) { if (Error_Code != 0) {
fprintf(stderr, "controller: Error %d from gethostname\n", Error_Code); fprintf(stderr, "controller: Error %d from gethostname\n", Error_Code);
...@@ -84,11 +90,11 @@ main(int argc, char * argv[]) { ...@@ -84,11 +90,11 @@ main(int argc, char * argv[]) {
printf("\n\nAllocate resources for a job\n"); printf("\n\nAllocate resources for a job\n");
Start_Time = clock(); Start_Time = clock();
NodeName = NULL; NodeName = NULL;
/* Error_Code = Allocate_Nodes(&In_Line[8], &NodeName); Skip over "Allocate" */ Error_Code = Select_Nodes(&In_Line[8], &NodeName); /* Skip over "Allocate" */
if (Error_Code) if (Error_Code)
printf("Error %d allocating resources for %s\n", &In_Line[8]); printf("Error %d allocating resources for %s", Error_Code, &In_Line[8]);
else else
printf("Allocated nodes %s to job %s\n", NodeName, &In_Line[8]); printf("Allocated nodes %s to job %s", NodeName, &In_Line[8]);
if (NodeName) free(NodeName); if (NodeName) free(NodeName);
printf("Time = %ld usec\n", (long)(clock() - Start_Time)); printf("Time = %ld usec\n", (long)(clock() - Start_Time));
......
...@@ -600,7 +600,7 @@ int Dump_Node(char **Buffer_Ptr, int *Buffer_Size, time_t *Update_Time) { ...@@ -600,7 +600,7 @@ int Dump_Node(char **Buffer_Ptr, int *Buffer_Size, time_t *Update_Time) {
return ENOMEM; return ENOMEM;
} /* if */ } /* if */
/* Write haeader, version and time */ /* Write haeader: version and time */
Buffer_Offset = 0; Buffer_Offset = 0;
i = CONFIG_STRUCT_VERSION; i = CONFIG_STRUCT_VERSION;
memcpy(Buffer+Buffer_Offset, &i, sizeof(i)); memcpy(Buffer+Buffer_Offset, &i, sizeof(i));
...@@ -734,8 +734,8 @@ int Dump_Node(char **Buffer_Ptr, int *Buffer_Size, time_t *Update_Time) { ...@@ -734,8 +734,8 @@ int Dump_Node(char **Buffer_Ptr, int *Buffer_Size, time_t *Update_Time) {
/* Write node records */ /* Write node records */
for (inx=0; inx<Node_Record_Count; inx++) { for (inx=0; inx<Node_Record_Count; inx++) {
if (strlen((Node_Record_Table_Ptr+inx)->Name) == 0) continue; if (strlen(Node_Record_Table_Ptr[inx].Name) == 0) continue;
Record_Size = MAX_NAME_LEN + 2 * sizeof(int); Record_Size = MAX_NAME_LEN + 5 * sizeof(int);
if ((Buffer_Offset+Record_Size) >= Buffer_Allocated) { /* Need larger buffer */ if ((Buffer_Offset+Record_Size) >= Buffer_Allocated) { /* Need larger buffer */
Buffer_Allocated += (Record_Size + BUF_SIZE); Buffer_Allocated += (Record_Size + BUF_SIZE);
Buffer = realloc(Buffer, Buffer_Allocated); Buffer = realloc(Buffer, Buffer_Allocated);
...@@ -750,29 +750,29 @@ int Dump_Node(char **Buffer_Ptr, int *Buffer_Size, time_t *Update_Time) { ...@@ -750,29 +750,29 @@ int Dump_Node(char **Buffer_Ptr, int *Buffer_Size, time_t *Update_Time) {
} /* if */ } /* if */
} /* if */ } /* if */
memcpy(Buffer+Buffer_Offset, (Node_Record_Table_Ptr+inx)->Name, memcpy(Buffer+Buffer_Offset, Node_Record_Table_Ptr[inx].Name,
sizeof((Node_Record_Table_Ptr+inx)->Name)); sizeof(Node_Record_Table_Ptr[inx].Name));
Buffer_Offset += sizeof((Node_Record_Table_Ptr+inx)->Name); Buffer_Offset += sizeof(Node_Record_Table_Ptr[inx].Name);
i = (int)(Node_Record_Table_Ptr+inx)->NodeState; i = (int)Node_Record_Table_Ptr[inx].NodeState;
memcpy(Buffer+Buffer_Offset, &i, sizeof(i)); memcpy(Buffer+Buffer_Offset, &i, sizeof(i));
Buffer_Offset += sizeof(i); Buffer_Offset += sizeof(i);
i = (Node_Record_Table_Ptr+inx)->CPUs; i = Node_Record_Table_Ptr[inx].CPUs;
memcpy(Buffer+Buffer_Offset, &i, sizeof(i)); memcpy(Buffer+Buffer_Offset, &i, sizeof(i));
Buffer_Offset += sizeof(i); Buffer_Offset += sizeof(i);
i = (Node_Record_Table_Ptr+inx)->RealMemory; i = Node_Record_Table_Ptr[inx].RealMemory;
memcpy(Buffer+Buffer_Offset, &i, sizeof(i)); memcpy(Buffer+Buffer_Offset, &i, sizeof(i));
Buffer_Offset += sizeof(i); Buffer_Offset += sizeof(i);
i = (Node_Record_Table_Ptr+inx)->TmpDisk; i = Node_Record_Table_Ptr[inx].TmpDisk;
memcpy(Buffer+Buffer_Offset, &i, sizeof(i)); memcpy(Buffer+Buffer_Offset, &i, sizeof(i));
Buffer_Offset += sizeof(i); Buffer_Offset += sizeof(i);
for (i=0; i<Config_Spec_List_Cnt; i++) { for (i=0; i<Config_Spec_List_Cnt; i++) {
if (Config_Spec_List[i].Config_Record_Point == if (Config_Spec_List[i].Config_Record_Point ==
(Node_Record_Table_Ptr+inx)->Config_Ptr) break; Node_Record_Table_Ptr[inx].Config_Ptr) break;
} /* for (i */ } /* for (i */
if (i < Config_Spec_List_Cnt) if (i < Config_Spec_List_Cnt)
i++; i++;
...@@ -1368,6 +1368,10 @@ int Update_Node(char *NodeName, char *Spec) { ...@@ -1368,6 +1368,10 @@ int Update_Node(char *NodeName, char *Spec) {
} /* if */ } /* if */
if (State_Val != NO_VAL) { if (State_Val != NO_VAL) {
Node_Record_Point->NodeState = State_Val; Node_Record_Point->NodeState = State_Val;
if (State_Val != STATE_IDLE) BitMapClear(Idle_NodeBitMap,
(int)(Node_Record_Point-Node_Record_Table_Ptr));
if (State_Val != STATE_UP) BitMapClear(Up_NodeBitMap,
(int)(Node_Record_Point-Node_Record_Table_Ptr));
#if DEBUG_SYSTEM #if DEBUG_SYSTEM
fprintf(stderr, "Update_Node: Node %s state set to %s\n", fprintf(stderr, "Update_Node: Node %s state set to %s\n",
This_Node_Name, Node_State_String[State_Val]); This_Node_Name, Node_State_String[State_Val]);
......
...@@ -407,7 +407,7 @@ int Pick_Best_Nodes(struct Node_Set *Node_Set_Ptr, int Node_Set_Size, ...@@ -407,7 +407,7 @@ int Pick_Best_Nodes(struct Node_Set *Node_Set_Ptr, int Node_Set_Size,
Total_Nodes = Total_CPUs = 0; Total_Nodes = Total_CPUs = 0;
} /* else */ } /* else */
/* We need to pick (more) nodes here */ /* Identify how many feature sets we have (e.g. "[FS1|FS2|FS3|FS4]" */
Max_Feature = Min_Feature = Node_Set_Ptr[0].Feature; Max_Feature = Min_Feature = Node_Set_Ptr[0].Feature;
for (i=1; i<Node_Set_Size; i++) { for (i=1; i<Node_Set_Size; i++) {
if (Node_Set_Ptr[i].Feature > Max_Feature) Max_Feature = Node_Set_Ptr[i].Feature; if (Node_Set_Ptr[i].Feature > Max_Feature) Max_Feature = Node_Set_Ptr[i].Feature;
...@@ -416,7 +416,7 @@ int Pick_Best_Nodes(struct Node_Set *Node_Set_Ptr, int Node_Set_Size, ...@@ -416,7 +416,7 @@ int Pick_Best_Nodes(struct Node_Set *Node_Set_Ptr, int Node_Set_Size,
if (Req_CPUs != NO_VAL) { printf("CPU requirement for job not yet supported\n"); return EINVAL; } if (Req_CPUs != NO_VAL) { printf("CPU requirement for job not yet supported\n"); return EINVAL; }
if (Req_BitMap[0]) { printf("Incomplete job NodeList not yet supported\n");return EINVAL; } if (Req_BitMap[0]) { printf("Incomplete job NodeList not yet supported\n");return EINVAL; }
if (Contiguous) { printf("Contiguous node allocation for job not yet supported\n"); return EINVAL; } if (Contiguous!= NO_VAL){ printf("Contiguous node allocation for job not yet supported\n"); return EINVAL; }
printf("More work to be done in node selection\n"); printf("More work to be done in node selection\n");
for (j=Min_Feature; j<=Max_Feature; j++) { for (j=Min_Feature; j<=Max_Feature; j++) {
...@@ -432,10 +432,12 @@ printf("More work to be done in node selection\n"); ...@@ -432,10 +432,12 @@ printf("More work to be done in node selection\n");
Avail_Nodes += Node_Set_Ptr[i].Nodes; Avail_Nodes += Node_Set_Ptr[i].Nodes;
Avail_CPUs += (Node_Set_Ptr[i].Nodes * Node_Set_Ptr[i].CPUs_Per_Node); Avail_CPUs += (Node_Set_Ptr[i].Nodes * Node_Set_Ptr[i].CPUs_Per_Node);
if (Req_Nodes != NO_VAL) { if (Req_Nodes != NO_VAL) {
Error_Code = BitMapFit(Avail_BitMap, Req_Nodes); Error_Code = BitMapFit(Avail_BitMap, Req_Nodes, Contiguous);
Req_BitMap[0] = Avail_BitMap; if (Error_Code == 0) {
free(Total_BitMap); Req_BitMap[0] = Avail_BitMap;
return 0; free(Total_BitMap);
return 0;
} /* if */
} /* if */ } /* if */
} /* for (i */ } /* for (i */
memset(Total_BitMap, 0, size); memset(Total_BitMap, 0, size);
...@@ -729,7 +731,6 @@ int Select_Nodes(char *Job_Specs, char **Node_List) { ...@@ -729,7 +731,6 @@ int Select_Nodes(char *Job_Specs, char **Node_List) {
&Req_BitMap, Req_CPUs, Req_Nodes, Contiguous, Shared); &Req_BitMap, Req_CPUs, Req_Nodes, Contiguous, Shared);
if (Error_Code) goto cleanup; if (Error_Code) goto cleanup;
/* Mark the selected nodes as STATE_STAGE_IN */ /* Mark the selected nodes as STATE_STAGE_IN */
Allocate_Nodes(Req_BitMap); Allocate_Nodes(Req_BitMap);
Error_Code = BitMap2NodeName(Req_BitMap, Node_List); Error_Code = BitMap2NodeName(Req_BitMap, Node_List);
......
...@@ -221,6 +221,7 @@ int Build_Part_BitMap(struct Part_Record *Part_Record_Point) { ...@@ -221,6 +221,7 @@ int Build_Part_BitMap(struct Part_Record *Part_Record_Point) {
if (Old_BitMap) free(Old_BitMap); if (Old_BitMap) free(Old_BitMap);
return ENOMEM; return ENOMEM;
} /* if */ } /* if */
strcpy(My_Node_List, Part_Record_Point->Nodes);
str_ptr2 = (char *)strtok_r(My_Node_List, ",", &str_ptr1); str_ptr2 = (char *)strtok_r(My_Node_List, ",", &str_ptr1);
while (str_ptr2) { /* Break apart by comma separators */ while (str_ptr2) { /* Break apart by comma separators */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment