# Still need sudo for update-alternatives
script:
+ - sudo pip install subprocess32 # needed by tesh
- cmake -Denable_documentation=OFF -Denable_coverage=OFF -Denable_java=ON -Denable_model-checking=OFF -Denable_lua=OFF -Denable_compile_optimizations=OFF -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON .
# run make in the sonar wrapper && run the tests only if the build suceeded
- ./tools/internal/travis-sonarqube.sh make VERBOSE=1 && ctest --output-on-failure --timeout 100
/*********************************** Host *************************************/
XBT_PUBLIC(sg_host_t) SIMIX_host_self();
XBT_PUBLIC(const char*) SIMIX_host_self_get_name();
-XBT_PUBLIC(void) SIMIX_host_on(sg_host_t host);
XBT_PUBLIC(void) SIMIX_host_off(sg_host_t host, smx_actor_t issuer);
XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
XBT_PUBLIC(void*) SIMIX_host_self_get_data();
}
void Host::turnOn() {
- simgrid::simix::kernelImmediate(std::bind(SIMIX_host_on, this));
+ if (isOff()) {
+ simgrid::simix::kernelImmediate([&]{
+ this->extension<simgrid::simix::Host>()->turnOn();
+ this->extension<simgrid::surf::HostImpl>()->turnOn();
+ });
+ }
}
void Host::turnOff() {
- simgrid::simix::kernelImmediate(std::bind(SIMIX_host_off, this, SIMIX_process_self()));
+ if (isOn()) {
+ simgrid::simix::kernelImmediate(std::bind(SIMIX_host_off, this, SIMIX_process_self()));
+ }
}
bool Host::isOn() {
xbt_dynar_free(&boot_processes);
xbt_swag_free(process_list);
}
- }
-}
-
-/** @brief Start the host if it is off */
-void SIMIX_host_on(sg_host_t h)
-{
- smx_host_priv_t host = sg_host_simix(h);
-
- xbt_assert((host != nullptr), "Invalid parameters");
- if (h->isOff()) {
- simgrid::surf::HostImpl* surf_host = h->extension<simgrid::surf::HostImpl>();
- surf_host->turnOn();
-
- unsigned int cpt;
- smx_process_arg_t arg;
- xbt_dynar_foreach(host->boot_processes,cpt,arg) {
- XBT_DEBUG("Booting Process %s(%s) right now",
- arg->name.c_str(), arg->hostname);
- if (simix_global->create_process_function) {
- simix_global->create_process_function(arg->name.c_str(),
- arg->code,
- nullptr,
- arg->hostname,
- arg->kill_time,
- arg->properties,
- arg->auto_restart,
- nullptr);
- } else {
- simcall_process_create(arg->name.c_str(),
- arg->code,
- nullptr,
- arg->hostname,
- arg->kill_time,
- arg->properties,
- arg->auto_restart);
+ /** Re-starts all the actors that are marked as restartable.
+ *
+ * Weird things will happen if you turn on an host that is already on. S4U is fool-proof, not this.
+ */
+ void Host::turnOn()
+ {
+ unsigned int cpt;
+ smx_process_arg_t arg;
+ xbt_dynar_foreach(boot_processes,cpt,arg) {
+ XBT_DEBUG("Booting Process %s(%s) right now", arg->name.c_str(), arg->hostname);
+ // FIXME: factorize this code by registering the simcall as default function
+ if (simix_global->create_process_function) {
+ simix_global->create_process_function(arg->name.c_str(),
+ arg->code,
+ nullptr,
+ arg->hostname,
+ arg->kill_time,
+ arg->properties,
+ arg->auto_restart,
+ nullptr);
+ } else {
+ simcall_process_create(arg->name.c_str(),
+ arg->code,
+ nullptr,
+ arg->hostname,
+ arg->kill_time,
+ arg->properties,
+ arg->auto_restart);
+ }
}
}
- }
-}
+
+}} // namespaces
/** @brief Stop the host if it is on */
void SIMIX_host_off(sg_host_t h, smx_actor_t issuer)
xbt_swag_t process_list;
xbt_dynar_t auto_restart_processes = nullptr;
xbt_dynar_t boot_processes = nullptr;
+
+ void turnOn();
};
}
}
// Iterate over all the sections that were specified and find the right
// value. (fact.factor represents the interval sizes; we want to find the
// section that has fact.factor <= size and no other such fact.factor <= size)
- // Note: parse_factor() (used before) already sorts the dynar we iterate over!
+ // Note: parse_factor() (used before) already sorts the vector we iterate over!
for (auto& fact : smpi_os_values) {
if (size <= fact.factor) { // Values already too large, use the previously
// computed value of current!
double current=smpi_ois_values.empty()?0.0:smpi_ois_values[0].values[0]+smpi_ois_values[0].values[1]*size;
// Iterate over all the sections that were specified and find the right value. (fact.factor represents the interval
// sizes; we want to find the section that has fact.factor <= size and no other such fact.factor <= size)
- // Note: parse_factor() (used before) already sorts the dynar we iterate over!
+ // Note: parse_factor() (used before) already sorts the vector we iterate over!
for (auto& fact : smpi_ois_values) {
if (size <= fact.factor) { // Values already too large, use the previously computed value of current!
XBT_DEBUG("ois : %zu <= %zu return %.10f", size, fact.factor, current);
// Iterate over all the sections that were specified and find the right value. (fact.factor represents the interval
// sizes; we want to find the section that has fact.factor <= size and no other such fact.factor <= size)
- // Note: parse_factor() (used before) already sorts the dynar we iterate over!
+ // Note: parse_factor() (used before) already sorts the vector we iterate over!
for (auto fact : smpi_or_values) {
- if (size <= fact.factor) { // Values already too large, use the previously
- // computed value of current!
+ if (size <= fact.factor) { // Values already too large, use the previously computed value of current!
XBT_DEBUG("or : %zu <= %zu return %.10f", size, fact.factor, current);
return current;
} else {
double smpi_mpi_wtime(){
double time;
- if (smpi_process_initialized() != 0 &&
- smpi_process_finalized() == 0 &&
- smpi_process_get_sampling() == 0) {
+ if (smpi_process_initialized() != 0 && smpi_process_finalized() == 0 && smpi_process_get_sampling() == 0) {
smpi_bench_end();
time = SIMIX_get_clock();
// to avoid deadlocks if used as a break condition, such as
MPI_Status stat;
MPI_Status *pstat = status == MPI_STATUSES_IGNORE ? MPI_STATUS_IGNORE : &stat;
int flag=1;
- int i;
- for(i=0; i<count; i++){
+ for(int i=0; i<count; i++){
if (requests[i] != MPI_REQUEST_NULL && !(requests[i]->flags & PREPARED)) {
if (smpi_mpi_test(&requests[i], pstat)!=1){
flag=0;
void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
{
int system_tag = COLL_TAG_SCATTER;
- int rank, size, dst, index;
- MPI_Aint lb = 0, sendext = 0;
+ int dst;
+ MPI_Aint lb = 0;
+ MPI_Aint sendext = 0;
MPI_Request *requests;
- rank = smpi_comm_rank(comm);
- size = smpi_comm_size(comm);
+ int rank = smpi_comm_rank(comm);
+ int size = smpi_comm_size(comm);
if(rank != root) {
// Recv buffer from root
smpi_mpi_recv(recvbuf, recvcount, recvtype, root, system_tag, comm, MPI_STATUS_IGNORE);
}
// Send buffers to receivers
requests = xbt_new(MPI_Request, size - 1);
- index = 0;
+ int index = 0;
for(dst = 0; dst < size; dst++) {
if(dst != root) {
requests[index] = smpi_isend_init(static_cast<char *>(sendbuf) + dst * sendcount * sendext, sendcount, sendtype, dst,
MPI_Datatype recvtype, int root, MPI_Comm comm)
{
int system_tag = COLL_TAG_SCATTERV;
- int rank, size, dst, index;
- MPI_Aint lb = 0, sendext = 0;
+ int dst;
+ MPI_Aint lb = 0;
+ MPI_Aint sendext = 0;
MPI_Request *requests;
- rank = smpi_comm_rank(comm);
- size = smpi_comm_size(comm);
+ int rank = smpi_comm_rank(comm);
+ int size = smpi_comm_size(comm);
if(rank != root) {
// Recv buffer from root
smpi_mpi_recv(recvbuf, recvcount, recvtype, root, system_tag, comm, MPI_STATUS_IGNORE);
}
// Send buffers to receivers
requests = xbt_new(MPI_Request, size - 1);
- index = 0;
+ int index = 0;
for(dst = 0; dst < size; dst++) {
if(dst != root) {
requests[index] = smpi_isend_init(static_cast<char *>(sendbuf) + displs[dst] * sendext, sendcounts[dst],
MPI_Comm comm)
{
int system_tag = COLL_TAG_REDUCE;
- int rank, size, src, index;
- MPI_Aint lb = 0, dataext = 0;
+ int src, index;
+ MPI_Aint lb = 0;
+ MPI_Aint dataext = 0;
MPI_Request *requests;
void **tmpbufs;
char* sendtmpbuf = static_cast<char *>(sendbuf);
-
- rank = smpi_comm_rank(comm);
- size = smpi_comm_size(comm);
+ int rank = smpi_comm_rank(comm);
+ int size = smpi_comm_size(comm);
//non commutative case, use a working algo from openmpi
if(!smpi_op_is_commute(op)){
smpi_coll_tuned_reduce_ompi_basic_linear(sendtmpbuf, recvbuf, count, datatype, op, root, comm);
void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
int system_tag = -888;
- int rank, size, other, index;
+ int other, index;
MPI_Aint lb = 0, dataext = 0;
MPI_Request *requests;
void **tmpbufs;
- rank = smpi_comm_rank(comm);
- size = smpi_comm_size(comm);
+ int rank = smpi_comm_rank(comm);
+ int size = smpi_comm_size(comm);
smpi_datatype_extent(datatype, &lb, &dataext);
void smpi_mpi_exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
int system_tag = -888;
- int rank, size, other, index;
+ int other, index;
MPI_Aint lb = 0, dataext = 0;
MPI_Request *requests;
void **tmpbufs;
int recvbuf_is_empty=1;
- rank = smpi_comm_rank(comm);
- size = smpi_comm_size(comm);
+ int rank = smpi_comm_rank(comm);
+ int size = smpi_comm_size(comm);
smpi_datatype_extent(datatype, &lb, &dataext);
index = 0;
for(other = 0; other < rank; other++) {
tmpbufs[index] = smpi_get_tmp_sendbuffer(count * dataext);
- requests[index] =
- smpi_irecv_init(tmpbufs[index], count, datatype, other, system_tag, comm);
+ requests[index] = smpi_irecv_init(tmpbufs[index], count, datatype, other, system_tag, comm);
index++;
}
for(other = rank + 1; other < size; other++) {
- requests[index] =
- smpi_isend_init(sendbuf, count, datatype, other, system_tag, comm);
+ requests[index] = smpi_isend_init(sendbuf, count, datatype, other, system_tag, comm);
index++;
}
// Wait for completion of all comms.
if(recvbuf_is_empty){
smpi_datatype_copy(tmpbufs[index], count, datatype, recvbuf, count, datatype);
recvbuf_is_empty=0;
- }else
- // #Request is below rank: it's a irecv
- smpi_op_apply(op, tmpbufs[index], recvbuf, &count, &datatype);
+ } else
+ // #Request is below rank: it's a irecv
+ smpi_op_apply(op, tmpbufs[index], recvbuf, &count, &datatype);
}
}
}else{
if(recvbuf_is_empty){
smpi_datatype_copy(tmpbufs[other], count, datatype, recvbuf, count, datatype);
recvbuf_is_empty=0;
- }else smpi_op_apply(op, tmpbufs[other], recvbuf, &count, &datatype);
+ } else
+ smpi_op_apply(op, tmpbufs[other], recvbuf, &count, &datatype);
}
}
}
if(selector_on){
// collective seems not handled by the active selector, try with default one
- name=const_cast<char*>("default");
for (int i = 0; table[i].name; i++)
- if (!strcmp(name, table[i].name)) {
+ if (!strcmp("default", table[i].name)) {
return i;
}
}
#include <stdio.h>
#include <xbt.h>
#include <xbt/replay.h>
+#include <unordered_map>
+#include <vector>
#define KEY_SIZE (sizeof(int) * 2 + 1)
int communicator_size = 0;
static int active_processes = 0;
-xbt_dict_t reqq = nullptr;
+std::unordered_map<int,std::vector<MPI_Request>*> reqq;
MPI_Datatype MPI_DEFAULT_TYPE;
MPI_Datatype MPI_CURRENT_TYPE;
}
}
-static xbt_dynar_t get_reqq_self()
+static std::vector<MPI_Request>* get_reqq_self()
{
- char * key = bprintf("%d", smpi_process_index());
- xbt_dynar_t dynar_mpi_request = static_cast<xbt_dynar_t>(xbt_dict_get(reqq, key));
- xbt_free(key);
-
- return dynar_mpi_request;
+ return reqq.at(smpi_process_index());
}
-static void set_reqq_self(xbt_dynar_t mpi_request)
+static void set_reqq_self(std::vector<MPI_Request> *mpi_request)
{
- char * key = bprintf("%d", smpi_process_index());
- xbt_dict_set(reqq, key, mpi_request, free);
- xbt_free(key);
+ reqq.insert({smpi_process_index(), mpi_request});
}
//allocate a single buffer for all sends, growing it if needed
/*initialize the number of active processes */
active_processes = smpi_process_count();
- if (reqq==nullptr) {
- reqq = xbt_dict_new();
- }
-
- set_reqq_self(xbt_dynar_new(sizeof(MPI_Request),&xbt_free_ref));
+ set_reqq_self(new std::vector<MPI_Request>);
}
static void action_finalize(const char *const *action)
TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
request->send = 1;
- xbt_dynar_push(get_reqq_self(),&request);
+ get_reqq_self()->push_back(request);
log_timed_action (action, clock);
}
extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr);
TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
- //unknow size from the receiver pov
+ //unknown size from the receiver point of view
if(size<=0.0){
- smpi_mpi_probe(from, 0, MPI_COMM_WORLD, &status);
- size=status.count;
+ smpi_mpi_probe(from, 0, MPI_COMM_WORLD, &status);
+ size=status.count;
}
smpi_mpi_recv(nullptr, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD, &status);
TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
request->recv = 1;
- xbt_dynar_push(get_reqq_self(),&request);
+ get_reqq_self()->push_back(request);
log_timed_action (action, clock);
}
static void action_test(const char *const *action){
CHECK_ACTION_PARAMS(action, 0, 0)
double clock = smpi_process_simulated_elapsed();
- MPI_Request request;
MPI_Status status;
int flag = true;
- request = xbt_dynar_pop_as(get_reqq_self(),MPI_Request);
+ MPI_Request request = get_reqq_self()->back();
+ get_reqq_self()->pop_back();
//if request is null here, this may mean that a previous test has succeeded
//Different times in traced application and replayed version may lead to this
//In this case, ignore the extra calls.
flag = smpi_mpi_test(&request, &status);
XBT_DEBUG("MPI_Test result: %d", flag);
- /* push back request in dynar to be caught by a subsequent wait. if the test did succeed, the request is now nullptr.*/
- xbt_dynar_push_as(get_reqq_self(),MPI_Request, request);
+ /* push back request in vector to be caught by a subsequent wait. if the test did succeed, the request is now nullptr.*/
+ get_reqq_self()->push_back(request);
TRACE_smpi_testing_out(rank);
}
static void action_wait(const char *const *action){
CHECK_ACTION_PARAMS(action, 0, 0)
double clock = smpi_process_simulated_elapsed();
- MPI_Request request;
MPI_Status status;
- xbt_assert(xbt_dynar_length(get_reqq_self()),
- "action wait not preceded by any irecv or isend: %s",
+ xbt_assert(get_reqq_self()->size(), "action wait not preceded by any irecv or isend: %s",
xbt_str_join_array(action," "));
- request = xbt_dynar_pop_as(get_reqq_self(),MPI_Request);
+ MPI_Request request = get_reqq_self()->back();
+ get_reqq_self()->pop_back();
if (request==nullptr){
/* Assume that the trace is well formed, meaning the comm might have been caught by a MPI_test. Then just return.*/
static void action_waitall(const char *const *action){
CHECK_ACTION_PARAMS(action, 0, 0)
double clock = smpi_process_simulated_elapsed();
- int count_requests=0;
- unsigned int i=0;
-
- count_requests=xbt_dynar_length(get_reqq_self());
+ unsigned int count_requests=get_reqq_self()->size();
if (count_requests>0) {
- MPI_Request requests[count_requests];
MPI_Status status[count_requests];
- /* The reqq is an array of dynars. Its index corresponds to the rank.
- Thus each rank saves its own requests to the array request. */
- xbt_dynar_foreach(get_reqq_self(),i,requests[i]);
-
- //save information from requests
- xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), nullptr);
- xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), nullptr);
- xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), nullptr);
- for (i = 0; static_cast<int>(i) < count_requests; i++) {
- if(requests[i]){
- int *asrc = xbt_new(int, 1);
- int *adst = xbt_new(int, 1);
- int *arecv = xbt_new(int, 1);
- *asrc = requests[i]->src;
- *adst = requests[i]->dst;
- *arecv = requests[i]->recv;
- xbt_dynar_insert_at(srcs, i, asrc);
- xbt_dynar_insert_at(dsts, i, adst);
- xbt_dynar_insert_at(recvs, i, arecv);
- xbt_free(asrc);
- xbt_free(adst);
- xbt_free(arecv);
- }else {
- int *t = xbt_new(int, 1);
- xbt_dynar_insert_at(srcs, i, t);
- xbt_dynar_insert_at(dsts, i, t);
- xbt_dynar_insert_at(recvs, i, t);
- xbt_free(t);
- }
- }
int rank_traced = smpi_process_index();
instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
extra->type = TRACING_WAITALL;
extra->send_size=count_requests;
TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra);
- smpi_mpi_waitall(count_requests, requests, status);
+ smpi_mpi_waitall(count_requests, &(*get_reqq_self())[0], status);
- for (i = 0; static_cast<int>(i) < count_requests; i++) {
- int src_traced, dst_traced, is_wait_for_receive;
- xbt_dynar_get_cpy(srcs, i, &src_traced);
- xbt_dynar_get_cpy(dsts, i, &dst_traced);
- xbt_dynar_get_cpy(recvs, i, &is_wait_for_receive);
- if (is_wait_for_receive) {
- TRACE_smpi_recv(rank_traced, src_traced, dst_traced);
- }
+ for (auto req : *(get_reqq_self())){
+ if (req && req->recv)
+ TRACE_smpi_recv(rank_traced, req->src, req->dst);
}
TRACE_smpi_ptp_out(rank_traced, -1, -1, __FUNCTION__);
- //clean-up of dynars
- xbt_dynar_free(&srcs);
- xbt_dynar_free(&dsts);
- xbt_dynar_free(&recvs);
- set_reqq_self(xbt_dynar_new(sizeof(MPI_Request),&xbt_free_ref));
}
log_timed_action (action, clock);
}
int comm_size = smpi_comm_size(MPI_COMM_WORLD);
CHECK_ACTION_PARAMS(action, 2*comm_size+2, 2)
- int send_buf_size=0,recv_buf_size=0,i=0;
int *sendcounts = xbt_new0(int, comm_size);
int *recvcounts = xbt_new0(int, comm_size);
int *senddisps = xbt_new0(int, comm_size);
MPI_Datatype MPI_CURRENT_TYPE2;
- send_buf_size=parse_double(action[2]);
- recv_buf_size=parse_double(action[3+comm_size]);
+ int send_buf_size=parse_double(action[2]);
+ int recv_buf_size=parse_double(action[3+comm_size]);
if(action[4+2*comm_size] && action[5+2*comm_size]) {
MPI_CURRENT_TYPE=decode_datatype(action[4+2*comm_size]);
MPI_CURRENT_TYPE2=decode_datatype(action[5+2*comm_size]);
void *sendbuf = smpi_get_tmp_sendbuffer(send_buf_size* smpi_datatype_size(MPI_CURRENT_TYPE));
void *recvbuf = smpi_get_tmp_recvbuffer(recv_buf_size* smpi_datatype_size(MPI_CURRENT_TYPE2));
- for(i=0;i<comm_size;i++) {
+ for(int i=0;i<comm_size;i++) {
sendcounts[i] = atoi(action[i+3]);
recvcounts[i] = atoi(action[i+4+comm_size]);
}
extra->sendcounts= xbt_new(int, comm_size);
extra->num_processes = comm_size;
- for(i=0; i< comm_size; i++){//copy data to avoid bad free
+ for(int i=0; i< comm_size; i++){//copy data to avoid bad free
extra->send_size += sendcounts[i];
extra->sendcounts[i] = sendcounts[i];
extra->recv_size += recvcounts[i];
/* and now, finalize everything */
double sim_time= 1.;
/* One active process will stop. Decrease the counter*/
- XBT_DEBUG("There are %lu elements in reqq[*]", xbt_dynar_length(get_reqq_self()));
- if (xbt_dynar_is_empty(get_reqq_self())==0){
- int count_requests=xbt_dynar_length(get_reqq_self());
+ XBT_DEBUG("There are %zu elements in reqq[*]", get_reqq_self()->size());
+ if (!get_reqq_self()->empty()){
+ unsigned int count_requests=get_reqq_self()->size();
MPI_Request requests[count_requests];
MPI_Status status[count_requests];
- unsigned int i;
+ unsigned int i=0;
- xbt_dynar_foreach(get_reqq_self(),i,requests[i]);
+ for (auto req: *get_reqq_self()){
+ requests[i] = req;
+ i++;
+ }
smpi_mpi_waitall(count_requests, requests, status);
active_processes--;
} else {
_xbt_replay_action_exit();
xbt_free(sendbuffer);
xbt_free(recvbuffer);
- xbt_dict_free(&reqq); //not need, data have been freed ???
- reqq = nullptr;
}
instr_extra_data extra_fin = xbt_new0(s_instr_extra_data_t,1);
-
/* Copyright (c) 2007-2015. The SimGrid Team.
* All rights reserved. */
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "private.h"
+#include <vector>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_rma, smpi, "Logging specific to SMPI (RMA operations)");
MPI_Comm comm;
MPI_Info info;
int assert;
- xbt_dynar_t requests;
+ std::vector<MPI_Request> *requests;
xbt_bar_t bar;
MPI_Win* connected_wins;
char* name;
win->name = nullptr;
win->opened = 0;
win->group = MPI_GROUP_NULL;
- win->requests = xbt_dynar_new(sizeof(MPI_Request), nullptr);
+ win->requests = new std::vector<MPI_Request>();
win->connected_wins = xbt_new0(MPI_Win, comm_size);
win->connected_wins[rank] = win;
int smpi_mpi_win_free( MPI_Win* win){
//As per the standard, perform a barrier to ensure every async comm is finished
xbt_barrier_wait((*win)->bar);
- xbt_dynar_free(&(*win)->requests);
+ delete (*win)->requests;
xbt_free((*win)->connected_wins);
if ((*win)->name != nullptr){
xbt_free((*win)->name);
if(assert != MPI_MODE_NOPRECEDE){
xbt_barrier_wait(win->bar);
- xbt_dynar_t reqs = win->requests;
- int size = xbt_dynar_length(reqs);
- unsigned int cpt=0;
- MPI_Request req;
+ std::vector<MPI_Request> *reqs = win->requests;
+ int size = static_cast<int>(reqs->size());
// start all requests that have been prepared by another process
- xbt_dynar_foreach(reqs, cpt, req){
- if (req->flags & PREPARED)
+ for(auto req: *reqs){
+ if (req && (req->flags & PREPARED))
smpi_mpi_start(req);
}
- MPI_Request* treqs = static_cast<MPI_Request*>(xbt_dynar_to_array(reqs));
- win->requests=xbt_dynar_new(sizeof(MPI_Request), nullptr);
+ MPI_Request* treqs = &(*reqs)[0];
smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE);
- xbt_free(treqs);
-
}
win->assert = assert;
smpi_group_index(smpi_comm_group(win->comm),target_rank), RMA_TAG+1, recv_win->comm, MPI_OP_NULL);
//push request to receiver's win
- xbt_dynar_push_as(recv_win->requests, MPI_Request, rreq);
+ recv_win->requests->push_back(rreq);
//start send
smpi_mpi_start(sreq);
//push request to sender's win
- xbt_dynar_push_as(win->requests, MPI_Request, sreq);
+ win->requests->push_back(sreq);
}else{
smpi_datatype_copy(origin_addr, origin_count, origin_datatype, recv_addr, target_count, target_datatype);
}
smpi_mpi_start(sreq);
//push request to receiver's win
- xbt_dynar_push_as(send_win->requests, MPI_Request, sreq);
+ send_win->requests->push_back(sreq);
//start recv
smpi_mpi_start(rreq);
//push request to sender's win
- xbt_dynar_push_as(win->requests, MPI_Request, rreq);
+ win->requests->push_back(rreq);
}else{
smpi_datatype_copy(send_addr, target_count, target_datatype, origin_addr, origin_count, origin_datatype);
}
MPI_Request rreq = smpi_rma_recv_init(recv_addr, target_count, target_datatype,
smpi_process_index(), smpi_group_index(smpi_comm_group(win->comm),target_rank), RMA_TAG+3, recv_win->comm, op);
//push request to receiver's win
- xbt_dynar_push_as(recv_win->requests, MPI_Request, rreq);
+ recv_win->requests->push_back(rreq);
//start send
smpi_mpi_start(sreq);
//push request to sender's win
- xbt_dynar_push_as(win->requests, MPI_Request, sreq);
+ win->requests->push_back(sreq);
return MPI_SUCCESS;
}
//now we can finish RMA calls
- xbt_dynar_t reqqs = win->requests;
- size = xbt_dynar_length(reqqs);
+ std::vector<MPI_Request> *reqqs = win->requests;
+ size = static_cast<int>(reqqs->size());
XBT_DEBUG("Win_complete - Finishing %d RMA calls", size);
- unsigned int cpt=0;
- MPI_Request req;
// start all requests that have been prepared by another process
- xbt_dynar_foreach(reqqs, cpt, req){
- if (req->flags & PREPARED)
+ for (auto req: *reqqs){
+ if (req && (req->flags & PREPARED))
smpi_mpi_start(req);
}
- MPI_Request* treqs = static_cast<MPI_Request*>(xbt_dynar_to_array(reqqs));
- win->requests=xbt_dynar_new(sizeof(MPI_Request), nullptr);
+ MPI_Request* treqs = &(*reqqs)[0];
smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE);
- xbt_free(treqs);
+ reqqs->clear();
smpi_group_unuse(win->group);
win->opened--; //we're closed for business !
return MPI_SUCCESS;
}
xbt_free(reqs);
- xbt_dynar_t reqqs = win->requests;
- size = xbt_dynar_length(reqqs);
+ std::vector<MPI_Request> *reqqs = win->requests;
+ size = static_cast<int>(reqqs->size());
XBT_DEBUG("Win_complete - Finishing %d RMA calls", size);
- unsigned int cpt=0;
- MPI_Request req;
// start all requests that have been prepared by another process
- xbt_dynar_foreach(reqqs, cpt, req){
- if (req->flags & PREPARED)
+ for(auto req: *reqqs){
+ if (req && (req->flags & PREPARED))
smpi_mpi_start(req);
}
- MPI_Request* treqs = static_cast<MPI_Request*>(xbt_dynar_to_array(reqqs));
- win->requests=xbt_dynar_new(sizeof(MPI_Request), nullptr);
+ MPI_Request* treqs = &(*reqqs)[0];
smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE);
- xbt_free(treqs);
+ reqqs->clear();
smpi_group_unuse(win->group);
win->opened--; //we're opened for business !
return MPI_SUCCESS;
}
/**
- * Returns total resource load
+ * Returns resource load (in flop per second, or byte per second, or similar)
*
- * \param cnst the lmm_constraint_t associated to the resource
+ * If the resource is shared (the default case), the load is sum of
+ * resource usage made by every variables located on this resource.
*
- * This is dead code, but we may use it later for debug/trace.
+ * If the resource is not shared (ie in FATPIPE mode), then the the
+ * load is the max (not the sum) of all resource usages located on this resource.
+ * .
+ * \param cnst the lmm_constraint_t associated to the resource
*/
double lmm_constraint_get_usage(lmm_constraint_t cnst) {
double usage = 0.0;
xbt_swag_t elem_list = &(cnst->enabled_element_set);
void *_elem;
- lmm_element_t elem = nullptr;
xbt_swag_foreach(_elem, elem_list) {
- elem = (lmm_element_t)_elem;
- if ((elem->value > 0)) {
+ lmm_element_t elem = (lmm_element_t)_elem;
+ if (elem->value > 0) {
if (cnst->sharing_policy)
usage += elem->value * elem->variable->value;
else if (usage < elem->value * elem->variable->value)
- usage = elem->value * elem->variable->value;
+ usage = std::max(usage, elem->value * elem->variable->value);
}
}
return usage;
are at 200 Watts, 170 Watts, and 150 Watts respectively.
To change the pstate of a given CPU, use the following functions:
-#MSG_host_get_nb_pstates(), simgrid#s4u#Host#set_pstate(), #MSG_host_get_power_peak_at().
+#MSG_host_get_nb_pstates(), simgrid#s4u#Host#setPstate(), #MSG_host_get_power_peak_at().
To simulate the energy-related elements, first call the simgrid#energy#sg_energy_plugin_init() before your #MSG_init(),
and then use the following function to retrieve the consumption of a given host: MSG_host_get_consumed_energy().
else
cpu_load = lmm_constraint_get_usage(surf_host->cpu_->getConstraint()) / surf_host->cpu_->speed_.peak;
- if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not mores
+ if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not more
cpu_load = 1;
+ /* The problem with this model is that the load is always 0 or 1, never something less.
+ * Another possibility could be to model the total energy as
+ *
+ * X/(X+Y)*W_idle + Y/(X+Y)*W_burn
+ *
+ * where X is the amount of ideling cores, and Y the amount of computing cores.
+ */
double previous_energy = this->total_energy;
simgrid::trace_mgr::future_evt_set *future_evt_set = nullptr;
xbt_dynar_t surf_path = nullptr;
-std::vector<sg_host_t> host_that_restart;
+std::vector<simgrid::s4u::Host*> host_that_restart;
xbt_dict_t watched_hosts_lib;
namespace simgrid {
* @param host_PM The real machine hosting the VM
*/
s4u::Host *createVM(const char *name, sg_host_t host_PM);
- void adjustWeightOfDummyCpuActions() {};
+ void adjustWeightOfDummyCpuActions() override {};
double next_occuring_event(double now) override;
- void updateActionsState(double /*now*/, double /*delta*/) {};
+ void updateActionsState(double /*now*/, double /*delta*/) override {};
};