return success;
}
- void handleMessage(Task task) {
+ private void handleMessage(Task task) {
MessageTask message = (MessageTask)task;
Connection remotePeer = peers.get(message.peerId);
switch (message.type) {
beginReceiveTime = Msg.getClock();
}
- void waitForPieces() {
+ private void waitForPieces() {
boolean finished = false;
while (Msg.getClock() < deadline && !finished) {
if (commReceived == null) {
* If the peer has more than pieces, he downloads the pieces that are the less
* replicated
*/
- void updateCurrentPiece() {
+ private void updateCurrentPiece() {
if (currentPieces.size() >= (Common.FILE_PIECES - pieces)) {
return;
}
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
import org.simgrid.msg.MsgException;
public class Coordinator extends Process {
- LinkedList<RequestTask> waitingQueue=new LinkedList<>();
- int csToServe;
-
public Coordinator(Host host, String name, String[]args) {
super(host,name,args);
}
public void main(String[] args) throws MsgException {
- csToServe = Integer.parseInt(args[0]);
- Task task;
+ int csToServe = Integer.parseInt(args[0]);
+ LinkedList<RequestTask> waitingQueue=new LinkedList<>();
+
while (csToServe >0) {
- task = Task.receive("coordinator");
+ Task task = Task.receive("coordinator");
if (task instanceof RequestTask) {
RequestTask t = (RequestTask) task;
if (waitingQueue.isEmpty()) {
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
import org.simgrid.msg.Task;
public class RequestTask extends Task {
- String from;
+ protected String from;
public RequestTask(String name) {
super();
from=name;
public class Daemon extends Process {
private Task currentTask;
- public Daemon(VM vm, int load) {
+ public Daemon(VM vm) {
super((Host)vm,"Daemon");
currentTask = new Task(this.getHost().getName()+"-daemon-0", this.getHost().getSpeed()*100, 0);
}
this.currentLoad = 0;
this.dpIntensity = dpIntensity ;
this.ramsize= ramsize;
- this.daemon = new Daemon(this, 100);
+ this.daemon = new Daemon(this);
}
public void setLoad(int load){
-/* Copyright (c) 2006-2014. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-/* Copyright (c) 2006-2014. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
protected Comm commReceive;
///Last time I changed a finger or my predecessor
protected double lastChangeDate;
- int[] fingers;
+ private int[] fingers;
public Node(Host host, String name, String[] args) {
super(host,name,args);
}
}
- void handleTask(Task task) {
+ private void handleTask(Task task) {
if (task instanceof FindSuccessorTask) {
FindSuccessorTask fTask = (FindSuccessorTask)task;
Msg.debug("Receiving a 'Find Successor' request from " + fTask.getIssuerHostName() + " for id " +
}
}
- void leave() {
+ private void leave() {
Msg.debug("Well Guys! I Think it's time for me to quit ;)");
quitNotify(1); //Notify my successor
quitNotify(-1); //Notify my predecessor.
* @brief Notifies the successor or the predecessor of the current node of the departure
* @param to 1 to notify the successor, -1 to notify the predecessor
*/
- static void quitNotify( int to) {
+ static private void quitNotify( int to) {
//TODO
}
- /**
- * @brief Initializes the current node as the first one of the system.
- */
- void create() {
+ /** @brief Initializes the current node as the first one of the system */
+ private void create() {
Msg.debug("Create a new Chord ring...");
setPredecessor(-1);
}
// Makes the current node join the ring, knowing the id of a node already in the ring
- boolean join(int knownId) {
+ private boolean join(int knownId) {
Msg.info("Joining the ring with id " + this.id + " knowing node " + knownId);
setPredecessor(-1);
int successorId = remoteFindSuccessor(knownId, this.id);
return successorId != -1;
}
- void setPredecessor(int predecessorId) {
+ private void setPredecessor(int predecessorId) {
if (predecessorId != predId) {
predId = predecessorId;
if (predecessorId != -1) {
* @param askTo the node to ask to
* @return the id of its predecessor node, or -1 if the request failed(or if the node does not know its predecessor)
*/
- int remoteGetPredecessor(int askTo) {
+ private int remoteGetPredecessor(int askTo) {
int predecessorId = -1;
boolean stop = false;
Msg.debug("Sending a 'Get Predecessor' request to " + askTo);
* @param id the id to find
* @return the id of the successor node, or -1 if the request failed
*/
- int findSuccessor(int id) {
+ private int findSuccessor(int id) {
if (isInInterval(id, this.id + 1, fingers[0])) {
return fingers[0];
}
}
// Asks another node the successor node of an id.
- int remoteFindSuccessor(int askTo, int id) {
+ private int remoteFindSuccessor(int askTo, int id) {
int successor = -1;
boolean stop = false;
String askToMailbox = Integer.toString(askTo);
}
// This function is called periodically. It checks the immediate successor of the current node.
- void stabilize() {
+ private void stabilize() {
Msg.debug("Stabilizing node");
int candidateId;
int successorId = fingers[0];
* @brief Notifies the current node that its predecessor may have changed.
* @param candidate_id the possible new predecessor
*/
- void notify(int predecessorCandidateId) {
+ private void notify(int predecessorCandidateId) {
if (predId == -1 || isInInterval(predecessorCandidateId, predId + 1, this.id - 1 )) {
setPredecessor(predecessorCandidateId);
}
* @param notify_id id of the node to notify
* @param candidate_id the possible new predecessor
*/
- void remoteNotify(int notifyId, int predecessorCandidateId) {
+ private void remoteNotify(int notifyId, int predecessorCandidateId) {
Msg.debug("Sending a 'Notify' request to " + notifyId);
Task sentTask = new NotifyTask(getHost().getName(), this.mailbox, predecessorCandidateId);
sentTask.dsend(Integer.toString(notifyId));
// This function is called periodically.
// It refreshes the finger table of the current node.
- void fixFingers() {
+ private void fixFingers() {
Msg.debug("Fixing fingers");
int i = this.nextFingerToFix;
int successorId = this.findSuccessor(this.id + (int)Math.pow(2,i)); //FIXME: SLOW
// This function is called periodically.
// It checks whether the predecessor has failed
- void checkPredecessor() {
+ private void checkPredecessor() {
//TODO
}
// Performs a find successor request to a random id.
- void randomLookup() {
+ private void randomLookup() {
int id = 1337;
//Msg.info("Making a lookup request for id " + id);
findSuccessor(id);
* @param id the id to find
* @return the closest preceding finger of that id
*/
- int closestPrecedingNode(int id) {
+ private int closestPrecedingNode(int id) {
for (int i = Common.NB_BITS - 1; i >= 0; i--) {
if (isInInterval(fingers[i], this.id + 1, id - 1)) {
return fingers[i];
* @param end upper bound
* @return a non-zero value if id in in [start, end]
*/
- static boolean isInInterval(int id, int start, int end) {
+ static private boolean isInInterval(int id, int start, int end) {
int normId = normalize(id);
int normStart = normalize(start);
int normEnd = normalize(end);
* @param id an id
* @return the corresponding normalized id
*/
- static int normalize(int id) {
+ static private int normalize(int id) {
return id & (Common.NB_KEYS - 1);
}
* @param finger_index index of the finger to set (0 to nb_bits - 1)
* @param id the id to set for this finger
*/
- void setFinger(int fingerIndex, int id) {
+ private void setFinger(int fingerIndex, int id) {
if (id != fingers[fingerIndex]) {
fingers[fingerIndex] = id;
lastChangeDate = Msg.getClock();
nodes = new ArrayList<>();
}
- int getDestinationId() {
+ protected int getDestinationId() {
return destinationId;
}
- ArrayList<Contact> getNodes() {
+ protected ArrayList<Contact> getNodes() {
return nodes;
}
- int size() {
+ protected int size() {
return nodes.size();
}
-/* Copyright (c) 2012-2014. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/** Emitter function */
int broadcaster(int argc, char *argv[])
{
- broadcaster_t bc = NULL;
- xbt_dynar_t host_list = NULL;
- int status;
unsigned int piece_count = PIECE_COUNT;
XBT_DEBUG("broadcaster");
/* Add every mailbox given by the hostcount in argv[1] to a dynamic array */
- host_list = build_hostlist_from_hostcount(xbt_str_parse_int(argv[1], "Invalid number of peers: %s"));
+ xbt_dynar_t host_list = build_hostlist_from_hostcount(xbt_str_parse_int(argv[1], "Invalid number of peers: %s"));
/* argv[2] is the number of pieces */
if (argc > 2) {
} else {
XBT_DEBUG("No piece_count specified, defaulting to %d", piece_count);
}
- bc = broadcaster_init(host_list, piece_count);
+ broadcaster_t bc = broadcaster_init(host_list, piece_count);
/* TODO: Error checking */
- status = broadcaster_send_file(bc);
+ int status = broadcaster_send_file(bc);
broadcaster_destroy(bc);
-/* Copyright (c) 2007-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
XBT_INFO("# Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.");
for (i = 0; i < nb_workers; i++) {
char mbox[MAXMBOXLEN];
- snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02d", i);
+ snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02u", i);
msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
MSG_task_send(finalize, mbox);
}
exit
fi
-EXTOPT=""
-WRAPPER=""
HOSTFILE=""
while true; do
"-platform")
PLATFORM="$2"
if [ ! -f "${PLATFORM}" ]; then
- echo "[`basename $0`] ** error: the file '${PLATFORM}' does not exist. Aborting."
+ echo "["$(basename $0)"] ** error: the file \'${PLATFORM}\' does not exist. Aborting."
exit 1
fi
shift 2
"-hostfile")
HOSTFILE="$2"
if [ ! -f "${HOSTFILE}" ]; then
- echo "[`basename $0`] ** error: the file '${HOSTFILE}' does not exist. Aborting."
+ echo "["$(basename $0)"] ** error: the file \'${HOSTFILE}\' does not exist. Aborting."
exit 1
fi
shift 2
"-machinefile")
HOSTFILE="$2"
if [ ! -f "${HOSTFILE}" ]; then
- echo "[`basename $0`] ** error: the file '${HOSTFILE}' does not exist. Aborting."
+ echo "["$(basename $0)"] ** error: the file \'${HOSTFILE}\' does not exist. Aborting."
exit 1
fi
shift 2
UNROLLEDHOSTFILETMP=0
#parse if our lines are terminated by :num_process
-multiple_processes=`grep -c ":" $HOSTFILE`
+multiple_processes=$(grep -c ":" $HOSTFILE)
if [ "${multiple_processes}" -gt 0 ] ; then
UNROLLEDHOSTFILETMP=1
UNROLLEDHOSTFILE="$(mktemp tmphostXXXXXX)"
fi
# Don't use wc -l to compute it to avoid issues with trailing \n at EOF
-hostfile_procs=`grep -c "[a-zA-Z0-9]" $HOSTFILE`
+hostfile_procs=$(grep -c "[a-zA-Z0-9]" $HOSTFILE)
if [ ${hostfile_procs} = 0 ] ; then
- echo "[`basename $0`] ** error: the hostfile '${HOSTFILE}' is empty. Aborting." >&2
+ echo "["$(basename $0)"] ** error: the hostfile \'${HOSTFILE}\' is empty. Aborting." >&2
exit 1
fi
##---- cache hostnames of hostfile---------------
if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then
- hostnames=$(cat ${HOSTFILE} | tr '\n\r' ' ')
- NUMHOSTS=$(cat ${HOSTFILE} | wc -l)
+ hostnames=$(tr '\n\r' ' ' < ${HOSTFILE})
+ NUMHOSTS=$(wc -l < ${HOSTFILE})
fi
DESCRIPTIONFILE=$(echo $PROC_ARGS|cut -d' ' -f1)
if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
- NUMINSTANCES=$(cat ${DESCRIPTIONFILE} | wc -l)
- replayinstances=$(cat ${DESCRIPTIONFILE})
IFS_OLD=$IFS
IFS=$'\n'
set -f
fi
sleeptime=$(echo "$line"|cut -d' ' -f4)
- HAVE_SEQ="`which seq 2>/dev/null`"
+ HAVE_SEQ=$(which seq 2>/dev/null)
if [ -n "${HAVE_SEQ}" ]; then
- SEQ1=`${HAVE_SEQ} 0 $((${NUMPROCSMINE}-1))`
+ SEQ1=$( ${HAVE_SEQ} 0 $((${NUMPROCSMINE}-1)) )
else
cnt=0
while (( $cnt < ${NUMPROCSMINE} )) ; do
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef _XBT_AUTOMATON_HPP
-#define _XBT_AUTOMATON_HPP
+#ifndef XBT_AUTOMATON_HPP
+#define XBT_AUTOMATON_HPP
#include <utility>
-/* Copyright (c) 2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
template<class X>
bool operator!=(X const& that) const
{
- return !((*this) == that);
+ return not (*this == that);
}
// Compare:
-/* Copyright (c) 2014-2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2014-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
*/
public final class NativeLib {
private static boolean isNativeInited = false;
- static Path tempDir = null; // where the embeeded libraries are unpacked before loading them
+ private static Path tempDir = null; // where the embeeded libraries are unpacked before loading them
/** A static-only "class" don't need no constructor */
private NativeLib() {
/** Time at which the process should be created */
protected double startTime = 0;
- /** Time at which the process should be killed.
- *
- * Set at creation, and used internally by SimGrid
- */
- private double killTime = -1;
+ /** Time at which the process should be killed */
+ private double killTime = -1; // Used from the C world
private String name = null;
public Process(Host host, String name, String[]args)
{
if (host == null)
- throw new NullPointerException("Cannot create a process on the null host");
+ throw new IllegalArgumentException("Cannot create a process on the null host");
if (name == null)
- throw new NullPointerException("Process name cannot be null");
+ throw new IllegalArgumentException("Process name cannot be null");
this.host = host;
this.name = name;
* a native storage. Even if this attribute is public you must never
* access to it.
*/
- private long bind;
+ private long bind = 0;
/** Storage name */
protected String name;
- /** User data. */
- private Object data;
- protected Storage() {
- this.bind = 0;
- this.data = null;
- }
-
@Override
public String toString (){
return this.name;
*/
public Task(String name, Host[]hosts, double[]flopsAmount, double[]bytesAmount) {
if (flopsAmount == null)
- throw new NullPointerException("Parallel task flops amounts is null");
+ throw new IllegalArgumentException("Parallel task flops amounts is null");
if (bytesAmount == null)
- throw new NullPointerException("Parallel task bytes amounts is null");
+ throw new IllegalArgumentException("Parallel task bytes amounts is null");
if (hosts == null)
- throw new NullPointerException("Host list is null");
+ throw new IllegalArgumentException("Host list is null");
if (name == null)
- throw new NullPointerException("Parallel task name is null");
+ throw new IllegalArgumentException("Parallel task name is null");
parallelCreate(name, hosts, flopsAmount, bytesAmount);
this.name = name;
if (e1->timestamp <= tbi->timestamp)
break;
}
- buffer.insert(i.base(), tbi);
if (i == buffer.rend())
XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
else if (i == buffer.rbegin())
else
XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__,
std::distance(buffer.rbegin(),i));
+ buffer.insert(i.base(), tbi);
buffer_debug(&buffer);
}
namespace routing {
void DijkstraZone::seal()
{
- xbt_node_t node = nullptr;
- unsigned int cursor2;
unsigned int cursor;
+ xbt_node_t node = nullptr;
/* Create the topology graph */
if (not routeGraph_)
/* Add the loopback if needed */
if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
xbt_dynar_foreach (xbt_graph_get_nodes(routeGraph_), cursor, node) {
- xbt_edge_t edge = nullptr;
bool found = false;
+ xbt_edge_t edge = nullptr;
+ unsigned int cursor2;
xbt_dynar_foreach (xbt_graph_node_get_outedges(node), cursor2, edge) {
if (xbt_graph_edge_get_target(edge) == node) {
found = true;
/* compose route path with links */
NetPoint* gw_src = nullptr;
NetPoint* gw_dst;
- NetPoint* prev_gw_src;
NetPoint* first_gw = nullptr;
- NetPoint* gw_dst_net_elm = nullptr;
- NetPoint* prev_gw_src_net_elm = nullptr;
for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
if (edge == nullptr)
THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name().c_str(), dst->name().c_str());
- prev_gw_src = gw_src;
-
sg_platf_route_cbarg_t e_route = (sg_platf_route_cbarg_t)xbt_graph_edge_get_data(edge);
+
+ NetPoint* prev_gw_src = gw_src;
gw_src = e_route->gw_src;
gw_dst = e_route->gw_dst;
strcmp(gw_dst->name().c_str(), prev_gw_src->name().c_str())) {
std::vector<surf::LinkImpl*> e_route_as_to_as;
+ NetPoint* gw_dst_net_elm = nullptr;
+ NetPoint* prev_gw_src_net_elm = nullptr;
getGlobalRoute(gw_dst_net_elm, prev_gw_src_net_elm, &e_route_as_to_as, nullptr);
auto pos = route->link_list->begin();
for (auto link : e_route_as_to_as) {
}
}
-}
\ No newline at end of file
+}
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#define _FILE_OFFSET_BITS 64
-
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
return std::unique_ptr<simgrid::mc::Checker>(
simgrid::mc::createCommunicationDeterminismChecker(session));
- else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0')
+ else if (_sg_mc_property_file == nullptr || _sg_mc_property_file[0] == '\0')
return std::unique_ptr<simgrid::mc::Checker>(
simgrid::mc::createSafetyChecker(session));
else
if (addr_pointed1 > process->heap_address
&& addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)) {
- if (!
- (addr_pointed2 > process->heap_address
- && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)))
+ if (not(addr_pointed2 > process->heap_address && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)))
return 1;
// The pointers are both in the heap:
return simgrid::mc::compare_heap_area(state,
// Called from both MCer and MCed:
bool request_is_enabled(smx_simcall_t req)
{
- unsigned int index = 0;
// TODO, add support for the subtypes?
switch (req->call) {
comms = simcall_comm_waitany__get__comms(req);
#endif
- for (index = 0; index < comms->used; ++index) {
+ for (unsigned int index = 0; index < comms->used; ++index) {
#if SIMGRID_HAVE_MC
// Fetch act from MCed memory:
// HACK, type puning
void _mc_cfg_cb_reduce(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a reduction strategy after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
void _mc_cfg_cb_checkpoint(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
}
void _mc_cfg_cb_sparse_checkpoint(const char *name) {
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
_sg_mc_sparse_checkpoint = xbt_cfg_get_boolean(name);
void _mc_cfg_cb_ksm(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die("You are specifying a KSM value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
_sg_mc_ksm = xbt_cfg_get_boolean(name);
void _mc_cfg_cb_property(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a property after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
void _mc_cfg_cb_hash(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a value to enable/disable the use of global hash to speedup state comparaison, but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
void _mc_cfg_cb_snapshot_fds(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a value to enable/disable the use of FD snapshotting, but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
void _mc_cfg_cb_max_depth(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a max depth value after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
void _mc_cfg_cb_visited(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a number of stored visited states after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
void _mc_cfg_cb_dot_output(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a file name for a dot output of graph state after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
void _mc_cfg_cb_comms_determinism(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a value to enable/disable the detection of determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
void _mc_cfg_cb_send_determinism(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a value to enable/disable the detection of send-determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
void _mc_cfg_cb_termination(const char *name)
{
- if (_sg_cfg_init_status && !_sg_do_model_check)
+ if (_sg_cfg_init_status && not _sg_do_model_check)
xbt_die
("You are specifying a value to enable/disable the detection of non progressive cycles after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry.");
#include <string>
#include <memory>
-#include "src/xbt/mmalloc/mmprivate.h"
-//#include "xbt/asserts.h"
-#include "xbt/base.h"
-
#include "src/mc/ModelChecker.hpp"
#include "src/mc/RegionSnapshot.hpp"
#include "src/mc/mc_forward.hpp"
} else if (comm->type == SIMIX_COMM_RECEIVE) {
other_user_data = comm->dst_data;
}
- if (comm->type == type && (!match_fun || match_fun(this_user_data, other_user_data, synchro)) &&
+ if (comm->type == type && (match_fun == nullptr || match_fun(this_user_data, other_user_data, synchro)) &&
(not comm->match_fun || comm->match_fun(other_user_data, this_user_data, my_synchro))) {
XBT_DEBUG("Found a matching communication synchro %p", comm);
if (remove_matching)
xbt_dict_set(dict_, key, xbt_strdup(value), nullptr);
}
-
-
int Info::get(char *key, int valuelen, char *value, int *flag){
*flag=false;
char* tmpvalue=static_cast<char*>(xbt_dict_get_or_null(dict_, key));
return filename_length == that.filename_length && line == that.line &&
std::memcmp(filename, that.filename, filename_length) == 0;
}
- bool operator!=(smpi_source_location const& that) const { return !(*this == that); }
+ bool operator!=(smpi_source_location const& that) const { return not(*this == that); }
};
}
int size = static_cast<int>(reqqs->size());
if (size > 0) {
size = 0;
- std::vector<MPI_Request>* myreqqs = new std::vector<MPI_Request>();
+ std::vector<MPI_Request> myreqqs;
std::vector<MPI_Request>::iterator iter = reqqs->begin();
while (iter != reqqs->end()){
if(((*iter)!=MPI_REQUEST_NULL) && (((*iter)->src() == rank) || ((*iter)->dst() == rank))){
- myreqqs->push_back(*iter);
- iter = reqqs->erase(iter);
- size++;
+ myreqqs.push_back(*iter);
+ iter = reqqs->erase(iter);
+ size++;
} else {
++iter;
}
}
if(size >0){
- MPI_Request* treqs = &(*myreqqs)[0];
+ MPI_Request* treqs = &myreqqs[0];
Request::waitall(size, treqs, MPI_STATUSES_IGNORE);
- myreqqs->clear();
- delete myreqqs;
+ myreqqs.clear();
}
}
xbt_mutex_release(mut_);
}
XBT_DEBUG("-------------- Check feasability ----------");
- if (!__check_feasible(cnst_list, var_list, 0))
+ if (not __check_feasible(cnst_list, var_list, 0))
overall_modification = 1.0;
XBT_DEBUG("Iteration %d: overall_modification : %f", iteration, overall_modification);
/* if(not dual_updated) { */
-/* Copyright (c) 2004-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/mallocator.h"
#include "xbt/sysdep.h"
#include <cxxabi.h>
+#include <limits>
#include <math.h>
#include <stdio.h> /* sprintf */
#include <stdlib.h>
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf, "Logging specific to SURF (maxmin)");
typedef struct s_dyn_light {
static inline void lmm_variable_remove(lmm_system_t sys, lmm_variable_t var)
{
int i;
- int nelements;
lmm_element_t elem = nullptr;
xbt_swag_remove(elem, &(elem->constraint->enabled_element_set));
xbt_swag_remove(elem, &(elem->constraint->disabled_element_set));
xbt_swag_remove(elem, &(elem->constraint->active_element_set));
- nelements=xbt_swag_size(&(elem->constraint->enabled_element_set)) +
- xbt_swag_size(&(elem->constraint->disabled_element_set));
- if (not nelements)
+ int nelements = xbt_swag_size(&(elem->constraint->enabled_element_set)) +
+ xbt_swag_size(&(elem->constraint->disabled_element_set));
+ if (nelements == 0)
make_constraint_inactive(sys, elem->constraint);
else
lmm_on_disabled_var(sys,elem->constraint);
void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value)
{
lmm_element_t elem = nullptr;
- double weight;
int i,current_share;
sys->modified = 1;
//Check if we need to disable the variable
if(var->weight>0 && var->concurrency_share-current_share>lmm_concurrency_slack(cnst)) {
- weight=var->weight;
+ double weight = var->weight;
lmm_disable_var(sys,var);
for (i = 0; i < var->cnsts_number; i++)
lmm_on_disabled_var(sys,var->cnsts[i].constraint);
void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value)
{
- int i,j;
+ int i;
double weight;
sys->modified = 1;
if(lmm_concurrency_slack(cnst)<lmm_element_concurrency(&var->cnsts[i])){
weight=var->weight;
lmm_disable_var(sys,var);
- for (j = 0; j < var->cnsts_number; j++)
+ for (int j = 0; j < var->cnsts_number; j++)
lmm_on_disabled_var(sys,var->cnsts[j].constraint);
var->staged_weight=weight;
xbt_assert(not var->weight);
xbt_swag_t var_list = nullptr;
xbt_swag_t elem_list = nullptr;
std::string buf = std::string("MAX-MIN ( ");
- double sum = 0.0;
/* Printing Objective */
var_list = &(sys->variable_set);
/* Printing Constraints */
cnst_list = &(sys->active_constraint_set);
xbt_swag_foreach(_cnst, cnst_list) {
- cnst = (lmm_constraint_t)_cnst;
- sum = 0.0;
+ cnst = (lmm_constraint_t)_cnst;
+ double sum = 0.0;
//Show the enabled variables
elem_list = &(cnst->enabled_element_set);
buf += "\t";
/** \brief Measure the minimum concurrency slack across all constraints where the given var is involved */
int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var){
- int i;
- //FIXME MARTIN: Replace by infinite value std::numeric_limits<int>::(max)(), or something better within Simgrid?
- int slack,minslack=666;
- for (i = 0; i < var->cnsts_number; i++) {
- slack=lmm_concurrency_slack(var->cnsts[i].constraint);
+ int minslack = std::numeric_limits<int>::max();
+ for (int i = 0; i < var->cnsts_number; i++) {
+ int slack = lmm_concurrency_slack(var->cnsts[i].constraint);
//This is only an optimization, to avoid looking at more constraints when slack is already zero
//Disable it when debugging to let lmm_concurrency_slack catch nasty things
}
void lmm_check_concurrency(lmm_system_t sys){
- void* _cnst;
- void* _elem;
- void* _var;
- lmm_element_t elem;
- lmm_constraint_t cnst;
- lmm_variable_t var;
- int concurrency;
- int i,belong_to_enabled,belong_to_disabled,belong_to_active;
-
//These checks are very expensive, so do them only if we want to debug SURF LMM
if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
- xbt_swag_foreach(_cnst, &(sys->constraint_set)) {
- cnst = (lmm_constraint_t) _cnst;
- concurrency=0;
- xbt_swag_foreach(_elem, &(cnst->enabled_element_set)) {
- elem = (lmm_element_t)_elem;
+ void* cnstIt;
+ xbt_swag_foreach(cnstIt, &(sys->constraint_set))
+ {
+ lmm_constraint_t cnst = (lmm_constraint_t)cnstIt;
+ int concurrency = 0;
+ void* elemIt;
+ xbt_swag_foreach(elemIt, &(cnst->enabled_element_set))
+ {
+ lmm_element_t elem = (lmm_element_t)elemIt;
xbt_assert(elem->variable->weight > 0);
concurrency+=lmm_element_concurrency(elem);
}
- xbt_swag_foreach(_elem, &(cnst->disabled_element_set)) {
- elem = (lmm_element_t)_elem;
+ xbt_swag_foreach(elemIt, &(cnst->disabled_element_set))
+ {
+ lmm_element_t elem = (lmm_element_t)elemIt;
//We should have staged variables only if concurrency is reached in some constraint
xbt_assert(cnst->concurrency_limit<0 || elem->variable->staged_weight==0 ||
lmm_cnstrs_min_concurrency_slack(elem->variable) < elem->variable->concurrency_share,
}
//Check that for each variable, all corresponding elements are in the same state (i.e. same element sets)
- xbt_swag_foreach(_var, &(sys->variable_set)) {
- var= (lmm_variable_t) _var;
+ void* varIt;
+ xbt_swag_foreach(varIt, &(sys->variable_set))
+ {
+ lmm_variable_t var = (lmm_variable_t)varIt;
if (not var->cnsts_number)
continue;
- elem = &var->cnsts[0];
- belong_to_enabled=xbt_swag_belongs(elem,&(elem->constraint->enabled_element_set));
- belong_to_disabled=xbt_swag_belongs(elem,&(elem->constraint->disabled_element_set));
- belong_to_active=xbt_swag_belongs(elem,&(elem->constraint->active_element_set));
+ lmm_element_t elem = &var->cnsts[0];
+ int belong_to_enabled = xbt_swag_belongs(elem, &(elem->constraint->enabled_element_set));
+ int belong_to_disabled = xbt_swag_belongs(elem, &(elem->constraint->disabled_element_set));
+ int belong_to_active = xbt_swag_belongs(elem, &(elem->constraint->active_element_set));
- for (i = 1; i < var->cnsts_number; i++) {
+ for (int i = 1; i < var->cnsts_number; i++) {
elem = &var->cnsts[i];
xbt_assert(belong_to_enabled==xbt_swag_belongs(elem,&(elem->constraint->enabled_element_set)),
"Variable inconsistency (1): enabled_element_set");
}
FILE *surf_fopen(const char *name, const char *mode)
{
- char *buff;
FILE *file = nullptr;
xbt_assert(name);
/* search relative files in the path */
for (auto path_elm : surf_path) {
- buff = bprintf("%s" FILE_DELIM "%s", path_elm.c_str(), name);
+ char* buff = bprintf("%s" FILE_DELIM "%s", path_elm.c_str(), name);
file = fopen(buff, mode);
free(buff);
xbt_test_suite_t suite = xbt_new0(struct s_xbt_test_suite, 1);
va_list ap;
- if (!_xbt_test_suites)
+ if (_xbt_test_suites == nullptr)
_xbt_test_suites = xbt_dynar_new(sizeof(xbt_test_suite_t), xbt_test_suite_free);
va_start(ap, fmt);
memreg.prot |= PROT_EXEC;
/* Private (copy-on-write) or shared? */
+ memregs.flags = 0;
if (info.shared)
memreg.flags |= MAP_SHARED;
else
static void xbt_postexit()
{
- if (!_sg_do_clean_atexit)
+ if (not _sg_do_clean_atexit)
return;
xbt_initialized--;
xbt_dict_postexit();
while (not done) {
char *to_push;
- int v = 0;
// get the start of the first occurrence of the substring
q = strstr(p, sep);
//if substring was not found add the entire string
if (nullptr == q) {
- v = strlen(p);
+ int v = strlen(p);
to_push = (char*) xbt_malloc(v + 1);
memcpy(to_push, p, v);
to_push[v] = '\0';
import org.simgrid.msg.Process;
class SemCreator extends Process {
- Semaphore sem;
-
SemCreator(Host h, String n){
super(h, n);
}
int j;
Msg.info("Creating 50 new Semaphores, yielding and triggering a GC after each");
for(j = 1; j <= 50; j++) {
- sem = new Semaphore(0);
+ new Semaphore(0);
waitFor(10);
System.gc();
}
static void display_storage_properties(simgrid::s4u::Storage* storage)
{
- xbt_dict_cursor_t cursor = NULL;
- char* key;
- char* data;
xbt_dict_t props = storage->properties();
if (xbt_dict_length(props) > 0) {
XBT_INFO("\tProperties of mounted storage: %s", storage->name());
+
+ xbt_dict_cursor_t cursor = NULL;
+ char* key;
+ char* data;
xbt_dict_foreach (props, cursor, key, data)
XBT_INFO("\t\t'%s' -> '%s'", key, data);
} else {
#!/bin/bash
-# Copyright (c) 2010, 2014. The SimGrid Team.
-# All rights reserved.
+# Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
TRACE=$1
echo "input: $TRACE"
-OUTPUT=`echo $TRACE | cut -d\. -f1`.fix.trace
+OUTPUT=$( echo $TRACE | cut -d\. -f1 ).fix.trace
-cat $TRACE | grep ^% > header
-DEFEVENTS=`cat header | grep Define | awk '{ print $3 }'`
+grep ^% < $TRACE > header
+DEFEVENTS=$(grep Define < header | awk '{ print $3 }')
GREP=""
GREP2=""
done
GREP="/^%\ /d; /^% /d; /^%E/d; $GREP"
-cat $TRACE | eval grep $GREP2 > types
+grep $GREP2 < $TRACE > types
/bin/sed -e "$GREP" $TRACE > events
-cat events | sort -n -k 2 -s > events.sorted
+sort -n -k 2 -s < events > events.sorted
cat header types events.sorted > $OUTPUT
rm types events events.sorted header
unset JAVA_TOOL_OPTIONS
if [ -f Testing/TAG ] ; then
- files=`find . -name "jacoco.exec"`
+ files=$( find . -name "jacoco.exec" )
i=0
for file in $files
do
- sourcepath=`dirname $file`
+ sourcepath=$( dirname $file )
#convert jacoco reports in xml ones
ant -f $WORKSPACE/tools/jenkins/jacoco.xml -Dexamplesrcdir=$WORKSPACE -Dbuilddir=$BUILDFOLDER/${sourcepath} -Djarfile=$BUILDFOLDER/simgrid.jar -Djacocodir=${JACOCO_PATH}/lib
#convert jacoco xml reports in cobertura xml reports
#convert all gcov reports to xml cobertura reports
gcovr -r .. --xml-pretty -e teshsuite.* -u -o $WORKSPACE/xml_coverage.xml
- xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults_memcheck.xml
+ xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/$( head -n 1 < Testing/TAG )/Test.xml > CTestResults_memcheck.xml
mv CTestResults_memcheck.xml $WORKSPACE
fi
<tr class=\"matrix-row\">
<td class=\"matrix-cell\">
<a href=\"https://ci.inria.fr/simgrid/job/SimGrid-DynamicAnalysis-Valgrind/label=simgrid-debian8-64-dynamic-analysis/valgrindResult/\">
- <img src=\"https://ci.inria.fr/simgrid/job/SimGrid-DynamicAnalysis/lastCompletedBuild/label=simgrid-debian8-64-dynamic-analysis/artifact/valgrind_graph.png\" title="$VALGRIND_RES">
+ <img src=\"https://ci.inria.fr/simgrid/job/SimGrid-DynamicAnalysis/lastCompletedBuild/label=simgrid-debian8-64-dynamic-analysis/artifact/valgrind_graph.png\" title=\"$VALGRIND_RES\">
</a>
</td>
<td class=\"matrix-cell\">
if test "$(uname -o)" != "Msys"; then
echo "XX"
echo "XX Build the archive out of the tree"
- echo "XX pwd: `pwd`"
+ echo "XX pwd: "$(pwd)
echo "XX"
cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
echo "XX"
echo "XX Open the resulting archive"
echo "XX"
- gunzip `cat VERSION`.tar.gz
- tar xf `cat VERSION`.tar
- cd `cat VERSION`
+ gunzip $(cat VERSION).tar.gz
+ tar xf $(cat VERSION).tar
+ cd $(cat VERSION)
mkdir build
cd build
SRCFOLDER=".."
echo "XX"
echo "XX Configure and build SimGrid"
-echo "XX pwd: `pwd`"
+echo "XX pwd: "$(pwd)
echo "XX"
cmake -G"$GENERATOR"\
-Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
if test "$(uname -o)" != "Msys"; then
cd $WORKSPACE/build
- cd `cat VERSION`/build
+ cd $(cat VERSION)/build
fi
-TRES=0
-
echo "XX"
echo "XX Run the tests"
-echo "XX pwd: `pwd`"
+echo "XX pwd: "$(pwd)
echo "XX"
ctest -T test --output-on-failure --no-compress-output || true
if [ -f Testing/TAG ] ; then
- xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults.xml
+ xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/$( head -n 1 < Testing/TAG )/Test.xml > CTestResults.xml
mv CTestResults.xml $WORKSPACE
fi
try:
proc = subprocess.Popen(args, bufsize=1, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
- except OSError as e:
- if e.errno == 8:
- e.strerror += "\nOSError: [Errno 8] Executed scripts should start with shebang line (like #!/bin/sh)"
- raise e
except FileNotFoundError:
print("["+FileReader().filename+":"+str(self.linenumber)+"] Cannot start '"+args[0]+"': File not found")
exit(3)
+ except OSError as osE:
+ if osE.errno == 8:
+ osE.strerror += "\nOSError: [Errno 8] Executed scripts should start with shebang line (like #!/bin/sh)"
+ raise osE
cmdName = FileReader().filename+":"+str(self.linenumber)
try: