Prechádzať zdrojové kódy

starpu_replay: Cope with the case when the number of parameters might be inconsistent in the trace

Samuel Thibault 6 rokov pred
rodič
commit
5e2ac4d57e
1 zmenil súbory, kde vykonal 20 pridanie a 22 odobranie
  1. 20 22
      tools/starpu_replay.c

+ 20 - 22
tools/starpu_replay.c

@@ -840,30 +840,28 @@ int main(int argc, char **argv)
 			const char *delim = " ";
 			char *token = strtok(buffer, delim);
 
-			while (token != NULL)
+			for (i = 0 ; i < nb_parameters ; i++)
 			{
-				for (i = 0 ; i < nb_parameters ; i++)
-				{
-					struct handle *handles_cell; /* A cell of the hash table for the handles */
-					starpu_data_handle_t  handle_value = (starpu_data_handle_t) strtol(token, NULL, 16); /* Get the ith handle on the line (in the file) */
-
-					HASH_FIND(hh, handles_hash, &handle_value, sizeof(handle_value), handles_cell); /* Find if the handle_value was already registered as a key in the hash table */
+				STARPU_ASSERT(token);
+				struct handle *handles_cell; /* A cell of the hash table for the handles */
+				starpu_data_handle_t  handle_value = (starpu_data_handle_t) strtol(token, NULL, 16); /* Get the ith handle on the line (in the file) */
 
-					/* If it wasn't, then add it to the hash table */
-					if (handles_cell == NULL)
-					{
-						/* Hide the initial handle from the file into the handles array to find it when necessary */
-						handles_ptr[i] = handle_value;
-						reg_signal[i] = 1;
-					}
-					else
-					{
-						handles_ptr[i] = handles_cell->mem_ptr;
-						reg_signal[i] = 0;
-					}
+				HASH_FIND(hh, handles_hash, &handle_value, sizeof(handle_value), handles_cell); /* Find if the handle_value was already registered as a key in the hash table */
 
-					token = strtok(NULL, delim);
+				/* If it wasn't, then add it to the hash table */
+				if (handles_cell == NULL)
+				{
+					/* Hide the initial handle from the file into the handles array to find it when necessary */
+					handles_ptr[i] = handle_value;
+					reg_signal[i] = 1;
+				}
+				else
+				{
+					handles_ptr[i] = handles_cell->mem_ptr;
+					reg_signal[i] = 0;
 				}
+
+				token = strtok(NULL, delim);
 			}
 		}
 		else if (TEST("Modes"))
@@ -873,7 +871,7 @@ int main(int argc, char **argv)
 			const char * delim = " ";
 			char * token = strtok(buffer, delim);
 
-			while (token != NULL)
+			while (token != NULL && mode_i < nb_parameters)
 			{
 				/* Subject to the names of starpu modes enumerator are not modified */
 				if (!strncmp(token, "RW", 2))
@@ -908,7 +906,7 @@ int main(int argc, char **argv)
 
 			_STARPU_MALLOC(sizes_set, nb_parameters * sizeof(size_t));
 
-			while (token != NULL)
+			while (token != NULL && k < nb_parameters)
 			{
 				sizes_set[k] = strtol(token, NULL, 10);
 				token = strtok(NULL, delim);