Commit ad1f48d8 authored by Olivier Richard's avatar Olivier Richard

Begin smpi profile support: add smpi_app_instances registering

parent 58ed9ba5
......@@ -10,6 +10,7 @@
#include <float.h>
#include <math.h>
#include <stdbool.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(batexec, "Batexec");
......@@ -50,13 +51,15 @@ static int job_launcher(int argc, char *argv[])
return 0;
}
msg_error_t deploy_all(const char *platform_file)
msg_error_t deploy_all(const char *platform_file, bool smpi_used)
{
msg_error_t res = MSG_OK;
xbt_dynar_t all_hosts;
msg_host_t first_host;
MSG_config("host/model", "ptask_L07");
if (!smpi_used)
MSG_config("host/model", "ptask_L07");
MSG_create_environment(platform_file);
all_hosts = MSG_hosts_as_dynar();
......@@ -81,7 +84,7 @@ msg_error_t deploy_all(const char *platform_file)
int main(int argc, char *argv[])
{
msg_error_t res = MSG_OK;
bool smpi_used;
json_t *json_workload_profile;
//Comment to remove debug message
......@@ -102,9 +105,12 @@ int main(int argc, char *argv[])
retrieve_profiles(json_workload_profile);
MSG_init(&argc, argv);
//register all smpi jobs app and init SMPI
smpi_used = register_smpi_app_instances();
XBT_INFO("finished initialize for smpi");
res = deploy_all(argv[1]);
res = deploy_all(argv[1], smpi_used);
if (res == MSG_OK)
return 0;
......
This diff is collapsed.
......@@ -3,7 +3,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <smpi/smpi.h>
#include "job.h"
#include "utils.h"
......@@ -218,3 +219,57 @@ int job_exec(int job_id, int nb_res, int *res_idxs, msg_host_t *nodes, double wa
free(job_res);
return ret;
}
int smpi_replay(int argc, char *argv[])
{
//just to verify given argv
int index;
for(index = 0; index < argc; index++) {
printf("The %d is %s\n",index,argv[index]);
}
printf("yop...\n");
smpi_replay_init(&argc, &argv);
//printf("smpi_rank %d\n", smpi_comm_rank(MPI_));
/* Actually do the simulation using smpi_action_trace_run */
smpi_action_trace_run(NULL);
//smpi_replay_finalize_instance();
smpi_replay_finalize();
return 0;
}
bool register_smpi_app_instances()
{
bool smpi_used = false;
s_job_t *job;
profile_t profile;
unsigned int job_index;
int nb_traces;
xbt_dynar_foreach(jobs_dynar, job_index, job)
{
profile = xbt_dict_get(profiles,job->profile);
if (strcmp(profile->type, "smpi") == 0)
{
smpi_used = true;
nb_traces = ((s_smpi_t *)(profile->data))->nb_traces;
if ( nb_traces != job->nb_res)
xbt_die("SMPI nb_traces (%d) and nb_res (%d) for job (%d) are not equal\n", nb_traces, job->nb_res, job->id);
SMPI_app_instance_register(job->id_str, smpi_replay, nb_traces);
XBT_INFO("register SMPI app instance %s with nb_traces %d", job->id_str, nb_traces);
}
}
if (smpi_used)
SMPI_init();
return(smpi_used);
}
......@@ -2,7 +2,10 @@
* All rights reserved. */
#pragma once
#include <smpi/smpi.h>
#include <sys/types.h> /* ssize_t, needed by xbt/str.h, included by msg/msg.h */
#include <stdbool.h>
#include <simgrid/msg.h>
#include <xbt.h>
......@@ -34,7 +37,7 @@ typedef struct s_job
double startingTime; //! The time at which the job started being executed
double runtime; //! The execution time of the job
int * alloc_ids; //! The resources allocated that were allocated to this job
int * alloc_ids; //! The resources that were allocated to this job
e_job_state_t state; //! The state
} s_job_t;
......@@ -67,6 +70,14 @@ typedef struct s_delay
double delay;
} s_delay_t;
//! The structure used to store additional information about profiles of type smpi
typedef struct s_smpi
{
xbt_dynar_t trace_filenames_dynar; //! all defined tracefile
int nb_traces; //total number of trace files only valid for the head link
} s_smpi_t;
/**
* @brief Executes a job
* @param[in] job_id The job number
......@@ -77,3 +88,6 @@ typedef struct s_delay
* @return 1 if the job finished in time, 0 if the walltime had been reached
*/
int job_exec(int job_id, int nb_res, int *res_idxs, msg_host_t *nodes, double walltime);
bool register_smpi_app_instances();
......@@ -2,6 +2,7 @@
* All rights reserved. */
#include <string.h>
#include <errno.h>
#include "job.h"
#include "utils.h"
......@@ -280,7 +281,32 @@ void retrieve_profiles(json_t *root)
}
else if (strcmp(type, "smpi") == 0)
{
XBT_WARN("Profile with type %s is not yet implemented", type);
s_smpi_t * smpi_prof = xbt_new(s_smpi_t, 1);
profile->data = smpi_prof;
e = json_object_get(j_profile, "trace");
xbt_assert(e != NULL, "The smpi profile '%s' must have a 'trace' field", key);
xbt_assert(json_typeof(e) == JSON_STRING, "The 'trace' field of the smpi profile '%s' must be a string", key);
//! Retrieves filename of each traces
const char* filename = json_string_value(e);
FILE *fp = NULL;
ssize_t read;
char *line = NULL;
size_t n = 0;
xbt_dynar_t traceFilenamesDynar = xbt_dynar_new(sizeof(char *), NULL);
fp = fopen(filename, "r");
if (fp == NULL)
xbt_die("Cannot open %s: %s", filename, strerror(errno));
while ((read = xbt_getline(&line,&n,fp)) != -1){
xbt_str_trim(line, NULL);
xbt_dynar_push(traceFilenamesDynar, line);
printf("line: %s\n", line);
}
smpi_prof->trace_filenames_dynar = traceFilenamesDynar;
smpi_prof->nb_traces = xbt_dynar_length(traceFilenamesDynar);
}
else
xbt_die("Invalid profile '%s' : type '%s' is not supported", key, profile->type);
......
/* Copyright (c) 2015. The OAR Team.
* All rights reserved. */
#pragma once
#ifndef _INCL_GUARD_UTIL
#define _INCL_GUARD_UTIL
#endif
#include <simgrid/msg.h>
#include <xbt.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment