Commit 3157a9dc authored by Millian Poquet's avatar Millian Poquet

Indentation coherency: removal of all tabulations in source code

parent 84dc211b
......@@ -175,7 +175,7 @@ static int requestReplyScheduler(int argc, char *argv[])
char sendDateAsString[16];
sprintf(sendDateAsString, "%f", MSG_get_clock());
char *sendBuf = MSG_process_get_data(MSG_process_self());
XBT_INFO("Buffer received in REQ-REP: '%s'", sendBuf);
......@@ -447,7 +447,7 @@ int server(int argc, char *argv[])
break;
} // end of case SUBMITTER_HELLO
case SUBMITTER_BYE:
{
{
nb_submitters_finished++;
XBT_INFO("A submitted said goodbye. Number of finished submitters: %d", nb_submitters_finished);
break;
......@@ -463,7 +463,7 @@ int server(int argc, char *argv[])
size_m = snprintf(sched_message + lg_sched_message, schedMessageMaxLength - lg_sched_message,
"|%f:C:%s", MSG_get_clock(), job->id_str);
lg_sched_message += size_m;
xbt_assert(lg_sched_message <= schedMessageMaxLength,
xbt_assert(lg_sched_message <= schedMessageMaxLength,
"Buffer for sending messages to the scheduler is not big enough...");
XBT_INFO("Message to send to scheduler: %s", sched_message);
......@@ -479,7 +479,7 @@ int server(int argc, char *argv[])
size_m = snprintf(sched_message + lg_sched_message, schedMessageMaxLength - lg_sched_message,
"|%f:S:%s", MSG_get_clock(), job->id_str);
lg_sched_message += size_m;
xbt_assert(lg_sched_message <= schedMessageMaxLength,
xbt_assert(lg_sched_message <= schedMessageMaxLength,
"Buffer for sending messages to the scheduler is not big enough...");
XBT_INFO("Message to send to scheduler: %s", sched_message);
......@@ -513,9 +513,9 @@ int server(int argc, char *argv[])
s_job_t * job = jobFromJobID(jobID);
xbt_assert(job->state == JOB_STATE_SUBMITTED, "Invalid allocation from the scheduler: the job %d is either not submitted yet"
" or already scheduled (state=%d)", jobID, job->state);
job->state = JOB_STATE_RUNNING;
nb_running_jobs++;
xbt_assert(nb_running_jobs <= nb_submitted_jobs);
nb_scheduled_jobs++;
......@@ -621,7 +621,7 @@ int server(int argc, char *argv[])
task_free(&task_received);
free(task_data);
if (sched_ready && (strcmp(sched_message, "") != 0))
{
char * sendBuf;
......@@ -629,10 +629,10 @@ int server(int argc, char *argv[])
int ret = asprintf(&sendBuf, "0:%f%s", MSG_get_clock(), sched_message);
xbt_assert(ret != -1, "asprintf failed (not enough memory?)");
sched_message[0] = '\0'; // empties the string
lg_sched_message = 0;
lg_sched_message = 0;
MSG_process_create("Sched REQ-REP", requestReplyScheduler, sendBuf, MSG_host_self());
sched_ready = 0;
}
......@@ -671,7 +671,7 @@ msg_error_t deploy_all(const char *platform_file, const char * masterHostName, c
xbt_assert(master_host != NULL,"Invalid SimGrid platform file '%s': cannot find any host named '%s'. "
"This special host is the one on which the simulator and the job submitters run.",
platform_file, masterHostName);
// Let's remove the master host from the hosts used to run jobs
msg_host_t host;
unsigned int i;
......
......@@ -24,9 +24,9 @@ typedef enum
*/
typedef struct s_task_data
{
e_task_type_t type; //! Type of task
int job_id; //! The job ID
void *data; //! Either NULL or points to something else based on type
e_task_type_t type; //! Type of task
int job_id; //! The job ID
void *data; //! Either NULL or points to something else based on type
} s_task_data_t;
/**
......@@ -34,7 +34,7 @@ typedef struct s_task_data
*/
typedef struct s_lauch_data
{
int jobID; //! The job identification number
int reservedNodeCount; //! The number of reserved nodes
int * reservedNodesIDs; //! The nodes on which the job will be run
int jobID; //! The job identification number
int reservedNodeCount; //! The number of reserved nodes
int * reservedNodesIDs; //! The nodes on which the job will be run
} s_launch_data_t;
......@@ -12,71 +12,71 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(export, "export");
WriteBuffer * writeBuffer_create(const char * filename, int bufferSize)
{
xbt_assert(bufferSize > 0, "Invalid buffer size (%d)", bufferSize);
xbt_assert(bufferSize > 0, "Invalid buffer size (%d)", bufferSize);
WriteBuffer * wbuf = xbt_new(WriteBuffer, 1);
wbuf->f = fopen(filename, "w");
wbuf->bufferSize = bufferSize;
wbuf->f = fopen(filename, "w");
wbuf->bufferSize = bufferSize;
wbuf->buffer = xbt_new0(char, bufferSize);
wbuf->bufferPos = 0;
wbuf->bufferPos = 0;
xbt_assert(wbuf->f != NULL, "Cannot write file '%s'", filename);
xbt_assert(wbuf->buffer != NULL, "Cannot allocate a buffer of size %d", bufferSize);
xbt_assert(wbuf->f != NULL, "Cannot write file '%s'", filename);
xbt_assert(wbuf->buffer != NULL, "Cannot allocate a buffer of size %d", bufferSize);
return wbuf;
return wbuf;
}
void writeBuffer_destroy(WriteBuffer ** wbuf)
{
if (*wbuf != NULL)
{
if ((*wbuf)->bufferPos > 0)
writeBuffer_flush(*wbuf);
int err = fclose((*wbuf)->f);
free((*wbuf)->buffer);
free(*wbuf);
*wbuf = NULL;
xbt_assert(err == 0, "File closure failed");
}
if (*wbuf != NULL)
{
if ((*wbuf)->bufferPos > 0)
writeBuffer_flush(*wbuf);
int err = fclose((*wbuf)->f);
free((*wbuf)->buffer);
free(*wbuf);
*wbuf = NULL;
xbt_assert(err == 0, "File closure failed");
}
}
void writeBuffer_append(WriteBuffer * wbuf, const char * text)
{
xbt_assert(wbuf != NULL);
xbt_assert(text != NULL);
const int textLength = strlen(text);
// If the buffer is big enough
if (wbuf->bufferPos + textLength < wbuf->bufferSize)
{
// Let's append the text to the buffer
memcpy(wbuf->buffer + wbuf->bufferPos, text, textLength * sizeof(char));
wbuf->bufferPos += textLength;
}
else
{
// Let's write the current buffer content in the file
writeBuffer_flush(wbuf);
// Let's write the text in the buffer
xbt_assert(textLength < wbuf->bufferSize, "Text too large to fit in the buffer (%d required, only got %d)", textLength, wbuf->bufferSize);
memcpy(wbuf->buffer, text, textLength * sizeof(char));
wbuf->bufferPos = textLength;
}
xbt_assert(wbuf != NULL);
xbt_assert(text != NULL);
const int textLength = strlen(text);
// If the buffer is big enough
if (wbuf->bufferPos + textLength < wbuf->bufferSize)
{
// Let's append the text to the buffer
memcpy(wbuf->buffer + wbuf->bufferPos, text, textLength * sizeof(char));
wbuf->bufferPos += textLength;
}
else
{
// Let's write the current buffer content in the file
writeBuffer_flush(wbuf);
// Let's write the text in the buffer
xbt_assert(textLength < wbuf->bufferSize, "Text too large to fit in the buffer (%d required, only got %d)", textLength, wbuf->bufferSize);
memcpy(wbuf->buffer, text, textLength * sizeof(char));
wbuf->bufferPos = textLength;
}
}
void writeBuffer_flush(WriteBuffer * wbuf)
{
xbt_assert(wbuf != NULL);
xbt_assert(wbuf != NULL);
int err = fputs(wbuf->buffer, wbuf->f);
wbuf->bufferPos = 0;
int err = fputs(wbuf->buffer, wbuf->f);
wbuf->bufferPos = 0;
xbt_assert(err >= 0, "Write string to file failure");
xbt_assert(err >= 0, "Write string to file failure");
}
......@@ -123,448 +123,448 @@ const char * PAJE_utilizationColor = "\"0.0 0.5 0.0\"";
PajeTracer * pajeTracer_create(const char * filename, int logLaunchings, int colorCount)
{
xbt_assert(logLaunchings == 0 || logLaunchings == 1, "logLaunchings must be either 0 or 1");
xbt_assert(colorCount > 0);
xbt_assert(logLaunchings == 0 || logLaunchings == 1, "logLaunchings must be either 0 or 1");
xbt_assert(colorCount > 0);
PajeTracer * tracer = xbt_new(PajeTracer, 1);
xbt_assert(tracer != NULL);
xbt_assert(tracer != NULL);
tracer->state = PAJE_STATE_UNINITIALIZED;
tracer->logLaunchings = logLaunchings;
tracer->buf = writeBuffer_create(filename, 1024*1024);
tracer->colorCount = colorCount;
tracer->colors = NULL;
tracer->state = PAJE_STATE_UNINITIALIZED;
tracer->logLaunchings = logLaunchings;
tracer->buf = writeBuffer_create(filename, 1024*1024);
tracer->colorCount = colorCount;
tracer->colors = NULL;
pajeTracer_private_generateColors(tracer, colorCount);
pajeTracer_private_generateColors(tracer, colorCount);
return tracer;
return tracer;
}
void pajeTracer_destroy(PajeTracer ** tracer)
{
if (tracer != NULL)
{
if ((*tracer)->state != PAJE_STATE_FINALIZED)
fprintf(stderr, "Destruction of a PajeTracer object which was not finalized. The corresponding trace file may be invalid.");
if (tracer != NULL)
{
if ((*tracer)->state != PAJE_STATE_FINALIZED)
fprintf(stderr, "Destruction of a PajeTracer object which was not finalized. The corresponding trace file may be invalid.");
writeBuffer_destroy(&((*tracer)->buf));
writeBuffer_destroy(&((*tracer)->buf));
for (int i = 0; i < (*tracer)->colorCount; ++i)
free((*tracer)->colors[i]);
for (int i = 0; i < (*tracer)->colorCount; ++i)
free((*tracer)->colors[i]);
free((*tracer)->colors);
free(*tracer);
*tracer = NULL;
}
free((*tracer)->colors);
free(*tracer);
*tracer = NULL;
}
}
void pajeTracer_initialize(PajeTracer * tracer, double date, int machineCount, const msg_host_t * machines)
{
xbt_assert(tracer != NULL);
xbt_assert(tracer->state == PAJE_STATE_UNINITIALIZED, "Bad call: the object is not UNINITIALIZED");
xbt_assert(machineCount > 0);
xbt_assert(machines != NULL);
// The buffer used to write lines in the file
const int bufSize = 1024;
char buf[bufSize];
// Let's write the Pajé schedule header
snprintf(buf, bufSize,
"%%EventDef PajeDefineContainerType %d\n"
"%% Type string\n"
"%% Alias string\n"
"%% Name string\n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeCreateContainer %d\n"
"%% Time date \n"
"%% Type string \n"
"%% Alias string \n"
"%% Name string \n"
"%% Container string \n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeDestroyContainer %d\n"
"%% Time date\n"
"%% Name string \n"
"%% Type string\n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeDefineStateType %d\n"
"%% Alias string \n"
"%% Type string \n"
"%% Name string \n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeDefineEntityValue %d\n"
"%% Alias string \n"
"%% Type string \n"
"%% Name string \n"
"%% Color color \n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeSetState %d\n"
"%% Time date \n"
"%% Type string \n"
"%% Container string \n"
"%% Value string \n"
"%%EndEventDef \n"
"\n"
"%%EventDef PajeDefineEventType %d\n"
"%% Type string\n"
"%% Alias string\n"
"%% Name string\n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeNewEvent %d\n"
"%% Time date\n"
"%% Type string\n"
"%% Container string\n"
"%% Value string\n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeDefineVariableType %d\n"
"%% Type string\n"
"%% Alias string\n"
"%% Name string\n"
xbt_assert(tracer != NULL);
xbt_assert(tracer->state == PAJE_STATE_UNINITIALIZED, "Bad call: the object is not UNINITIALIZED");
xbt_assert(machineCount > 0);
xbt_assert(machines != NULL);
// The buffer used to write lines in the file
const int bufSize = 1024;
char buf[bufSize];
// Let's write the Pajé schedule header
snprintf(buf, bufSize,
"%%EventDef PajeDefineContainerType %d\n"
"%% Type string\n"
"%% Alias string\n"
"%% Name string\n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeCreateContainer %d\n"
"%% Time date \n"
"%% Type string \n"
"%% Alias string \n"
"%% Name string \n"
"%% Container string \n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeDestroyContainer %d\n"
"%% Time date\n"
"%% Name string \n"
"%% Type string\n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeDefineStateType %d\n"
"%% Alias string \n"
"%% Type string \n"
"%% Name string \n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeDefineEntityValue %d\n"
"%% Alias string \n"
"%% Type string \n"
"%% Name string \n"
"%% Color color \n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeSetState %d\n"
"%% Time date \n"
"%% Type string \n"
"%% Container string \n"
"%% Value string \n"
"%%EndEventDef \n"
"\n"
"%%EventDef PajeDefineEventType %d\n"
"%% Type string\n"
"%% Alias string\n"
"%% Name string\n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeNewEvent %d\n"
"%% Time date\n"
"%% Type string\n"
"%% Container string\n"
"%% Value string\n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeDefineVariableType %d\n"
"%% Type string\n"
"%% Alias string\n"
"%% Name string\n"
"%% Color color\n"
"%%EndEventDef\n"
"\n"
"%%EventDef PajeSetVariable %d\n"
"%% Time date\n"
"%% Type string\n"
"%% Container string\n"
"%% Value double\n"
"%%EndEventDef\n"
"\n",
PAJE_DEFINE_CONTAINER_TYPE, PAJE_CREATE_CONTAINER, PAJE_DESTROY_CONTAINER,
PAJE_DEFINE_STATE_TYPE, PAJE_DEFINE_ENTITY_VALUE, PAJE_SET_STATE,
PAJE_DEFINE_EVENT_TYPE, PAJE_NEW_EVENT, PAJE_DEFINE_VARIABLE_TYPE,
PAJE_SET_VARIABLE);
writeBuffer_append(tracer->buf, buf);
// Let's create our container types
snprintf(buf, bufSize,
"# Container types creation\n"
"%d 0 %s \"Machines\"\n"
"%d %s %s \"Machine\"\n"
"%d 0 %s \"Scheduler\"\n"
"%d %s %s \"Killer\"\n"
"\n",
PAJE_DEFINE_CONTAINER_TYPE, PAJE_rootType,
PAJE_DEFINE_CONTAINER_TYPE, PAJE_rootType, PAJE_machineType,
PAJE_DEFINE_CONTAINER_TYPE, PAJE_schedulerType,
PAJE_DEFINE_CONTAINER_TYPE, PAJE_schedulerType, PAJE_killerType);
writeBuffer_append(tracer->buf, buf);
// Let's create our event types
snprintf(buf, bufSize,
"# Event types creation\n"
"%d %s %s \"Job kill\"\n"
"%d %s %s \"Job kill\"\n"
"\n",
PAJE_DEFINE_EVENT_TYPE, PAJE_killerType, PAJE_killEventKiller,
PAJE_DEFINE_EVENT_TYPE, PAJE_machineType, PAJE_killEventMachine);
writeBuffer_append(tracer->buf, buf);
// Let's create our variable types
snprintf(buf, bufSize,
"# Variable types creation\n"
"%d %s %s \"Utilization\" %s\n"
"\n",
PAJE_DEFINE_VARIABLE_TYPE, PAJE_schedulerType,
PAJE_utilizationVarType, PAJE_utilizationColor);
writeBuffer_append(tracer->buf, buf);
// Let's create our containers
snprintf(buf, bufSize,
"# Containers creation\n"
"%d %lf %s %s \"Machines\" 0\n",
PAJE_CREATE_CONTAINER, date, PAJE_rootType, PAJE_root);
writeBuffer_append(tracer->buf, buf);
for (int i = 0; i < machineCount; ++i)
{
const char * machineName = MSG_host_get_name(machines[i]);
// todo: clean machine name
snprintf(buf, bufSize,
"%d %lf %s %s%d \"%s\" %s\n",
PAJE_CREATE_CONTAINER, date, PAJE_machineType,
PAJE_machinePrefix, i,
machineName, PAJE_root);
writeBuffer_append(tracer->buf, buf);
}
snprintf(buf, bufSize,
"%d %lf %s %s \"Scheduler\" 0\n"
"%d %lf %s %s \"Killer\" %s\n"
"\n",
PAJE_CREATE_CONTAINER, date, PAJE_schedulerType, PAJE_scheduler,
PAJE_CREATE_CONTAINER, date, PAJE_killerType, PAJE_killer, PAJE_scheduler);
writeBuffer_append(tracer->buf, buf);
// Let's declare that machines have a state
snprintf(buf, bufSize,
"# States creation\n"
"%d %s %s \"Machine state\"\n"
"\n",
PAJE_DEFINE_STATE_TYPE, PAJE_machineState, PAJE_machineType);
writeBuffer_append(tracer->buf, buf);
// Let's declare some machine states
snprintf(buf, bufSize,
"# Creation of the different values the machine state can be\n"
"%d %s %s \"Waiting\" %s\n"
"%d %s %s \"Launching\" %s\n"
"\n"
"# Begin of events\n",
PAJE_DEFINE_ENTITY_VALUE, PAJE_mstateWaiting, PAJE_machineState, PAJE_waitingColor,
PAJE_DEFINE_ENTITY_VALUE, PAJE_mstateLaunching, PAJE_machineState, PAJE_launchingColor);
writeBuffer_append(tracer->buf, buf);
for (int i = 0; i < machineCount; ++i)
{
snprintf(buf, bufSize,
"%d %lf %s %s%d %s\n",
PAJE_SET_STATE, date, PAJE_machineState, PAJE_machinePrefix, i, PAJE_mstateWaiting);
writeBuffer_append(tracer->buf, buf);
}
tracer->state = PAJE_STATE_INITIALIZED;
"%%EndEventDef\n"
"\n"
"%%EventDef PajeSetVariable %d\n"
"%% Time date\n"
"%% Type string\n"
"%% Container string\n"
"%% Value double\n"
"%%EndEventDef\n"
"\n",
PAJE_DEFINE_CONTAINER_TYPE, PAJE_CREATE_CONTAINER, PAJE_DESTROY_CONTAINER,
PAJE_DEFINE_STATE_TYPE, PAJE_DEFINE_ENTITY_VALUE, PAJE_SET_STATE,
PAJE_DEFINE_EVENT_TYPE, PAJE_NEW_EVENT, PAJE_DEFINE_VARIABLE_TYPE,
PAJE_SET_VARIABLE);
writeBuffer_append(tracer->buf, buf);
// Let's create our container types
snprintf(buf, bufSize,
"# Container types creation\n"
"%d 0 %s \"Machines\"\n"
"%d %s %s \"Machine\"\n"
"%d 0 %s \"Scheduler\"\n"
"%d %s %s \"Killer\"\n"
"\n",
PAJE_DEFINE_CONTAINER_TYPE, PAJE_rootType,
PAJE_DEFINE_CONTAINER_TYPE, PAJE_rootType, PAJE_machineType,
PAJE_DEFINE_CONTAINER_TYPE, PAJE_schedulerType,
PAJE_DEFINE_CONTAINER_TYPE, PAJE_schedulerType, PAJE_killerType);
writeBuffer_append(tracer->buf, buf);
// Let's create our event types
snprintf(buf, bufSize,
"# Event types creation\n"
"%d %s %s \"Job kill\"\n"
"%d %s %s \"Job kill\"\n"
"\n",
PAJE_DEFINE_EVENT_TYPE, PAJE_killerType, PAJE_killEventKiller,
PAJE_DEFINE_EVENT_TYPE, PAJE_machineType, PAJE_killEventMachine);
writeBuffer_append(tracer->buf, buf);
// Let's create our variable types
snprintf(buf, bufSize,
"# Variable types creation\n"
"%d %s %s \"Utilization\" %s\n"
"\n",
PAJE_DEFINE_VARIABLE_TYPE, PAJE_schedulerType,
PAJE_utilizationVarType, PAJE_utilizationColor);
writeBuffer_append(tracer->buf, buf);
// Let's create our containers
snprintf(buf, bufSize,
"# Containers creation\n"
"%d %lf %s %s \"Machines\" 0\n",
PAJE_CREATE_CONTAINER, date, PAJE_rootType, PAJE_root);
writeBuffer_append(tracer->buf, buf);
for (int i = 0; i < machineCount; ++i)
{
const char * machineName = MSG_host_get_name(machines[i]);
// todo: clean machine name
snprintf(buf, bufSize,
"%d %lf %s %s%d \"%s\" %s\n",
PAJE_CREATE_CONTAINER, date, PAJE_machineType,
PAJE_machinePrefix, i,
machineName, PAJE_root);
writeBuffer_append(tracer->buf, buf);
}
snprintf(buf, bufSize,
"%d %lf %s %s \"Scheduler\" 0\n"
"%d %lf %s %s \"Killer\" %s\n"
"\n",
PAJE_CREATE_CONTAINER, date, PAJE_schedulerType, PAJE_scheduler,
PAJE_CREATE_CONTAINER, date, PAJE_killerType, PAJE_killer, PAJE_scheduler);
writeBuffer_append(tracer->buf, buf);
// Let's declare that machines have a state
snprintf(buf, bufSize,
"# States creation\n"
"%d %s %s \"Machine state\"\n"
"\n",
PAJE_DEFINE_STATE_TYPE, PAJE_machineState, PAJE_machineType);
writeBuffer_append(tracer->buf, buf);
// Let's declare some machine states
snprintf(buf, bufSize,
"# Creation of the different values the machine state can be\n"
"%d %s %s \"Waiting\" %s\n"
"%d %s %s \"Launching\" %s\n"
"\n"
"# Begin of events\n",
PAJE_DEFINE_ENTITY_VALUE, PAJE_mstateWaiting, PAJE_machineState, PAJE_waitingColor,
PAJE_DEFINE_ENTITY_VALUE, PAJE_mstateLaunching, PAJE_machineState, PAJE_launchingColor);
writeBuffer_append(tracer->buf, buf);
for (int i = 0; i < machineCount; ++i)
{
snprintf(buf, bufSize,
"%d %lf %s %s%d %s\n",
PAJE_SET_STATE, date, PAJE_machineState, PAJE_machinePrefix, i, PAJE_mstateWaiting);
writeBuffer_append(tracer->buf, buf);
}
tracer->state = PAJE_STATE_INITIALIZED;
}
void pajeTracer_finalize(PajeTracer * tracer, double date, int machineCount, const msg_host_t * machines)
{
xbt_assert(tracer != NULL);
xbt_assert(tracer->state == PAJE_STATE_INITIALIZED, "Bad call: the object is not INITIALIZED");
(void) machines;
const int bufSize = 64;
char buf[bufSize];
snprintf(buf, bufSize,
"\n"
"# End of events, containers destruction\n");
writeBuffer_append(tracer->buf, buf);
for (int i = 0; i < machineCount; ++i)
{
snprintf(buf, bufSize,
"%d %lf %s%d %s\n",
PAJE_DESTROY_CONTAINER, date, PAJE_machinePrefix, i, PAJE_machineType);
writeBuffer_append(tracer->buf, buf);
}