Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions platforms/energy_platform_homogeneous.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
When switching from a computing state to the state 1, passing by the virtual pstate 2 is mandatory to simulate the time and energy consumed by the switch off.
When switching from the state 1 to a computing state, passing by the virtual pstate 3 is mandatory to simulate the time and energy consumed by the switch on.
-->
<host id="Mercury" speed="100.0Mf, 1e-9Mf, 0.5f, 0.05f" pstate="0" >
<host id="Mercury" speed="100.0Mf, 1e-9Mf, 0.5f, 0.05f" pstate="0" core="100">
<prop id="wattage_per_state" value="30.0:30.0:100.0, 9.75:9.75:9.75, 200.996721311:200.996721311:200.996721311, 425.1743849:425.1743849:425.1743849" />
<prop id="wattage_off" value="9.75" />
<prop id="sleep_pstates" value="1:2:3" />
</host>

<host id="Venus" speed="100.0Mf, 1e-9Mf, 0.5f, 0.05f" pstate="0" >
<host id="Venus" speed="100.0Mf, 1e-9Mf, 0.5f, 0.05f" pstate="0" core="100">
<prop id="wattage_per_state" value="30.0:30.0:100.0, 9.75:9.75:9.75, 200.996721311:200.996721311:200.996721311, 425.1743849:425.1743849:425.1743849" />
<prop id="wattage_off" value="9.75" />
<prop id="sleep_pstates" value="1:2:3" />
</host>

<host id="Earth" speed="100.0Mf, 1e-9Mf, 0.5f, 0.05f" pstate="0" >
<host id="Earth" speed="100.0Mf, 1e-9Mf, 0.5f, 0.05f" pstate="0" core="100">
<prop id="wattage_per_state" value="30.0:30.0:100.0, 9.75:9.75:9.75, 200.996721311:200.996721311:200.996721311, 425.1743849:425.1743849:425.1743849" />
<prop id="wattage_off" value="9.75" />
<prop id="sleep_pstates" value="1:2:3" />
</host>

<host id="Mars" speed="100.0Mf, 1e-9Mf, 0.5f, 0.05f" pstate="0" >
<host id="Mars" speed="100.0Mf, 1e-9Mf, 0.5f, 0.05f" pstate="0" core="100">
<prop id="wattage_per_state" value="30.0:30.0:100.0, 9.75:9.75:9.75, 200.996721311:200.996721311:200.996721311, 425.1743849:425.1743849:425.1743849" />
<prop id="wattage_off" value="9.75" />
<prop id="sleep_pstates" value="1:2:3" />
Expand Down
31 changes: 31 additions & 0 deletions src/profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@ ProfilePtr Profile::from_json(const std::string & profile_name,
"elements must be non-negative", error_prefix.c_str(), profile_name.c_str());
}

// get and check util. Default to full utilization if not exists
if (json_desc.HasMember("util")) {
xbt_assert(json_desc["util"].IsNumber(), "%s: profile '%s' has a non-number 'util' field",
error_prefix.c_str(), profile_name.c_str());
data->util = json_desc["util"].GetDouble();
xbt_assert(data->util > 0.0 && data->util <= 1.0 , "%s: profile '%s' has an invalid 'util' field (%g)",
error_prefix.c_str(), profile_name.c_str(), data->util);
} else {
data->util = 1.0;
}

profile->data = data;
}
else if (profile_type == "parallel_homogeneous")
Expand Down Expand Up @@ -404,6 +415,16 @@ ProfilePtr Profile::from_json(const std::string & profile_name,
xbt_assert(data->com >= 0, "%s: profile '%s' has a non-positive 'com' field (%g)",
error_prefix.c_str(), profile_name.c_str(), data->com);

if (json_desc.HasMember("util")) {
xbt_assert(json_desc["util"].IsNumber(), "%s: profile '%s' has a non-number 'util' field",
error_prefix.c_str(), profile_name.c_str());
data->util = json_desc["util"].GetDouble();
xbt_assert(data->util > 0.0 && data->util <= 1.0 , "%s: profile '%s' has an invalid 'util' field (%g)",
error_prefix.c_str(), profile_name.c_str(), data->util);
} else {
data->util = 1.0;
}

profile->data = data;
}
else if (profile_type == "parallel_homogeneous_total")
Expand Down Expand Up @@ -434,6 +455,16 @@ ProfilePtr Profile::from_json(const std::string & profile_name,
xbt_assert(data->com >= 0, "%s: profile '%s' has a non-positive 'com' field (%g)",
error_prefix.c_str(), profile_name.c_str(), data->com);

if (json_desc.HasMember("util")) {
xbt_assert(json_desc["util"].IsNumber(), "%s: profile '%s' has a non-number 'util' field",
error_prefix.c_str(), profile_name.c_str());
data->util = json_desc["util"].GetDouble();
xbt_assert(data->util > 0.0 && data->util <= 1.0 , "%s: profile '%s' has an invalid 'util' field (%g)",
error_prefix.c_str(), profile_name.c_str(), data->util);
} else {
data->util = 1.0;
}

profile->data = data;
}
else if (profile_type == "composed")
Expand Down
3 changes: 3 additions & 0 deletions src/profiles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct ParallelProfileData
unsigned int nb_res; //!< The number of resources
double * cpu = nullptr; //!< The computation vector
double * com = nullptr; //!< The communication matrix
double util; //!< The cpu utilization on each node
};

/**
Expand All @@ -111,6 +112,7 @@ struct ParallelHomogeneousProfileData
{
double cpu; //!< The computation amount on each node
double com; //!< The communication amount between each pair of nodes
double util; //!< The cpu utilization on each node
};

/**
Expand All @@ -120,6 +122,7 @@ struct ParallelHomogeneousTotalAmountProfileData
{
double cpu; //!< The computation amount to spread over the nodes
double com; //!< The communication amount to spread over each pair of nodes
double util; //!< The cpu utilization on each node
};
/**
* @brief The data associated to DELAY profiles
Expand Down
91 changes: 90 additions & 1 deletion src/task_execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ using namespace roles;
* parallel task profile. Also set the prefix name of the task.
* @param[out] computation_amount the computation matrix to be simulated by the parallel task
* @param[out] communication_amount the communication matrix to be simulated by the parallel task
* @param[out] utilization the max CPU utilization to be simulated (as a decimal between 0 and 1)
* @param[in] nb_res the number of resources the task have to run on
* @param[in] profile_data the profile data
*/
void generate_parallel_task(std::vector<double>& computation_amount,
std::vector<double>& communication_amount,
double& utilization,
unsigned int nb_res,
void * profile_data)
{
Expand All @@ -42,25 +44,29 @@ void generate_parallel_task(std::vector<double>& computation_amount,
// Retrieve the matrices from the profile
memcpy(computation_amount.data(), data->cpu, sizeof(double) * nb_res);
memcpy(communication_amount.data(), data->com, sizeof(double) * nb_res * nb_res);
utilization = data->util;
}

/**
* @brief Generate the communication and computaion matrix for the
* parallel homogeneous task profile. Also set the prefix name of the task.
* @param[out] computation_amount the computation matrix to be simulated by the parallel task
* @param[out] communication_amount the communication matrix to be simulated by the parallel task
* @param[out] utilization the max CPU utilization to be simulated (as a decimal between 0 and 1)
* @param[in] nb_res the number of resources the task have to run on
* @param[in] profile_data the profile data
*/
void generate_parallel_homogeneous(std::vector<double>& computation_amount,
std::vector<double>& communication_amount,
double& utilization,
unsigned int nb_res,
void * profile_data)
{
auto * data = static_cast<ParallelHomogeneousProfileData*>(profile_data);

double cpu = data->cpu;
double com = data->com;
utilization = data->util;

// Prepare buffers
computation_amount.reserve(nb_res);
Expand Down Expand Up @@ -100,6 +106,7 @@ void generate_parallel_homogeneous(std::vector<double>& computation_amount,
*
* @param[out] computation_amount the computation matrix to be simulated by the parallel task
* @param[out] communication_amount the communication matrix to be simulated by the parallel task
* @param[out] utilization the max CPU utilization to be simulated (as a decimal between 0 and 1)
* @param[in] nb_res the number of resources the task have to run on
* @param[in] profile_data the profile data
*
Expand All @@ -109,6 +116,7 @@ void generate_parallel_homogeneous(std::vector<double>& computation_amount,
*/
void generate_parallel_homogeneous_total_amount(std::vector<double>& computation_amount,
std::vector<double>& communication_amount,
double& utilization,
unsigned int nb_res,
void * profile_data)
{
Expand Down Expand Up @@ -147,6 +155,8 @@ void generate_parallel_homogeneous_total_amount(std::vector<double>& computation
}
}
}

utilization = data->util;
}

/**
Expand All @@ -155,6 +165,7 @@ void generate_parallel_homogeneous_total_amount(std::vector<double>& computation
*
* @param[out] computation_amount the computation matrix to be simulated by the parallel task
* @param[out] communication_amount the communication matrix to be simulated by the parallel task
* @param[out] utilization the max CPU utilization to be simulated (as a decimal between 0 and 1)
* @param[in,out] hosts_to_use the list of host to be used by the task
* @param[in] storage_mapping mapping from label given in the profile and machine id
* @param[in] profile_data the profile data
Expand All @@ -165,6 +176,7 @@ void generate_parallel_homogeneous_total_amount(std::vector<double>& computation
*/
void generate_parallel_homogeneous_with_pfs(std::vector<double>& computation_amount,
std::vector<double>& communication_amount,
double& utilization,
std::vector<simgrid::s4u::Host*> & hosts_to_use,
const std::map<std::string, int> * storage_mapping,
void * profile_data,
Expand Down Expand Up @@ -243,6 +255,8 @@ void generate_parallel_homogeneous_with_pfs(std::vector<double>& computation_amo
}
}
}

utilization = 1.0;
}

/**
Expand All @@ -253,13 +267,15 @@ void generate_parallel_homogeneous_with_pfs(std::vector<double>& computation_amo
* name of the task.
* @param[out] computation_amount the computation matrix to be simulated by the parallel task
* @param[out] communication_amount the communication matrix to be simulated by the parallel task
* @param[out] utilization the max CPU utilization to be simulated (as a decimal between 0 and 1)
* @param[in,out] hosts_to_use the list of host to be used by the task
* @param[in] storage_mapping mapping from label given in the profile and machine id
* @param[in] profile_data the profile data
* @param[in] context the batsim context
*/
void generate_data_staging_task(std::vector<double>& computation_amount,
std::vector<double>& communication_amount,
double& utilization,
std::vector<simgrid::s4u::Host*> & hosts_to_use,
const std::map<std::string, int> * storage_mapping,
void * profile_data,
Expand Down Expand Up @@ -330,12 +346,15 @@ void generate_data_staging_task(std::vector<double>& computation_amount,
}
}
}

utilization = 1.0;
}

/**
* @brief Debug print of a parallel task (via XBT_DEBUG)
* @param[in] computation_vector The ptask computation vector
* @param[in] communication_matrix The ptask communication matrix
* @param[in] utilization the max CPU utilization d
* @param[in] nb_res The number of hosts involved in the parallel task
* @param[in] alloc The resource ids allocated for the parallel task
* @param[in] mapping The mapping between executor id and resource id, if any
Expand Down Expand Up @@ -374,13 +393,15 @@ void debug_print_ptask(const std::vector<double>& computation_vector,
* @brief
* @param[out] computation_vector The computation vector to be simulated by the parallel task
* @param[out] communication_matrix The communication matrix to be simulated by the parallel task
* @param[out] utilization the max CPU utilization to be simulated (as a decimal between 0 and 1)
* @param[in,out] hosts_to_use The list of host to be used by the task
* @param[in] profile The profile to be converted to a compute/comm matrix
* @param[in] storage_mapping The storage mapping
* @param[in] context The BatsimContext
*/
void generate_matrices_from_profile(std::vector<double>& computation_vector,
std::vector<double>& communication_matrix,
double& utilization,
std::vector<simgrid::s4u::Host*> & hosts_to_use,
ProfilePtr profile,
const std::map<std::string, int> * storage_mapping,
Expand All @@ -396,24 +417,28 @@ void generate_matrices_from_profile(std::vector<double>& computation_vector,
case ProfileType::PARALLEL:
generate_parallel_task(computation_vector,
communication_matrix,
utilization,
nb_res,
profile->data);
break;
case ProfileType::PARALLEL_HOMOGENEOUS:
generate_parallel_homogeneous(computation_vector,
communication_matrix,
utilization,
nb_res,
profile->data);
break;
case ProfileType::PARALLEL_HOMOGENEOUS_TOTAL_AMOUNT:
generate_parallel_homogeneous_total_amount(computation_vector,
communication_matrix,
utilization,
nb_res,
profile->data);
break;
case ProfileType::PARALLEL_HOMOGENEOUS_PFS:
generate_parallel_homogeneous_with_pfs(computation_vector,
communication_matrix,
utilization,
hosts_to_use,
storage_mapping,
profile->data,
Expand All @@ -422,6 +447,7 @@ void generate_matrices_from_profile(std::vector<double>& computation_vector,
case ProfileType::DATA_STAGING:
generate_data_staging_task(computation_vector,
communication_matrix,
utilization,
hosts_to_use,
storage_mapping,
profile->data,
Expand Down Expand Up @@ -462,6 +488,62 @@ void check_ptask_execution_permission(const IntervalSet & alloc,
}
}

/**
* @brief
* @param[in, out] computation_vector The computation vector to be simulated by the parallel task
* @param[in, out] communication_matrix The communication matrix to be simulated by the parallel task
* @param[in,out] hosts_to_use The list of host to be used by the task
*/
void replicate_for_cores(std::vector<double>& computation_vector,
std::vector<double>& communication_matrix,
std::vector<simgrid::s4u::Host*> & hosts_to_use,
double usage)
{
// compute how many cores should be used depending on usage and on which host is used
const double nb_cores = simgrid::s4u::this_actor::get_host()->get_core_count();
const int nb_cores_to_use = std::max(round(usage * nb_cores), 1.0); // use at least 1 core, otherwise using flops is impossible
const int nb_hosts = hosts_to_use.size();

XBT_DEBUG("Replicating computation to use %d cores per machine", nb_cores_to_use);

std::vector<simgrid::s4u::Host*> hosts_copy(hosts_to_use);
std::vector<double> computation_copy(computation_vector);
std::vector<double> communication_copy(communication_matrix);
hosts_to_use.reserve(nb_cores_to_use * nb_hosts);
computation_vector.reserve(nb_cores_to_use * nb_hosts);

for (int i = 0; i < nb_cores_to_use - 1; ++i) {
for (auto host : hosts_copy) {
hosts_to_use.push_back(host);
}
}

for (int i = 0; i < nb_cores_to_use - 1; ++i) {
for (auto computation : computation_copy) {
computation_vector.push_back(computation);
}
}

if(!communication_matrix.empty()) {
communication_matrix.clear();
communication_matrix.reserve(nb_cores_to_use * nb_hosts * nb_cores_to_use * nb_hosts);
for(int row = 0; row < nb_hosts; row++) {
for(int col = 0; col < nb_hosts; col++) {
communication_matrix.push_back(communication_copy[(row * nb_hosts) + col]);
}
for(int col = nb_hosts; col < nb_cores_to_use* nb_hosts; col++) {
communication_matrix.push_back(0);
}
}

for(int row = nb_hosts; row < nb_cores_to_use * nb_hosts; row++) {
for(int col = 0; col < nb_cores_to_use * nb_hosts; col++) {
communication_matrix.push_back(0);
}
}
}
}

int execute_parallel_task(BatTask * btask,
const SchedulingAllocation* allocation,
double * remaining_time,
Expand All @@ -472,6 +554,7 @@ int execute_parallel_task(BatTask * btask,

std::vector<double> computation_vector;
std::vector<double> communication_matrix;
double utilization;

string task_name = profile_type_to_string(profile->type) + '_' + static_cast<JobPtr>(btask->parent_job)->id.to_string() +
"_" + btask->profile->name;
Expand All @@ -480,6 +563,7 @@ int execute_parallel_task(BatTask * btask,

generate_matrices_from_profile(computation_vector,
communication_matrix,
utilization,
hosts_to_use,
profile,
& allocation->storage_mapping,
Expand All @@ -500,6 +584,7 @@ int execute_parallel_task(BatTask * btask,
std::vector<simgrid::s4u::Host*> io_hosts = allocation->io_hosts;
generate_matrices_from_profile(io_computation_vector,
io_communication_matrix,
utilization,
io_hosts,
io_profile,
nullptr,
Expand Down Expand Up @@ -636,10 +721,14 @@ int execute_parallel_task(BatTask * btask,

// Create the parallel task
XBT_DEBUG("Creating parallel task '%s' on %zu resources", task_name.c_str(), hosts_to_use.size());

replicate_for_cores(computation_vector, communication_matrix, hosts_to_use, utilization);
simgrid::s4u::ExecPtr ptask = simgrid::s4u::this_actor::exec_init(hosts_to_use, computation_vector, communication_matrix);
ptask->set_name(task_name.c_str());

// double flops = ptask->get_host()->get_speed() * utilization;
// XBT_DEBUG("Setting utilization of '%s' on %zu resources to %g", task_name.c_str(), hosts_to_use.size(), flops);
// ptask->set_bound(flops); // Set bound can only be set per task not per host

// Keep track of the task to get information on kill
btask->ptask = ptask;

Expand Down
Loading