SimGrid (3.27.1) NOT RELEASED YET (v3.28 expected June 21. 2021, 03:32 UTC)
+XBT:
+ - xbt_assert is not disabled anymore, even when built with enable_debug=off.
+
----------------------------------------------------------------------------
SimGrid (3.27) March 29. 2021
template<class T>
T simgrid::kernel::FutureState<T>::get()
{
- if (status_ != FutureStatus::ready)
- xbt_die("Deadlock: this future is not ready");
+ xbt_assert(status_ == FutureStatus::ready, "Deadlock: this future is not ready");
status_ = FutureStatus::done;
if (exception_) {
std::exception_ptr exception = std::move(exception_);
auto kernel_sync(F code) -> decltype(code().get())
{
typedef decltype(code().get()) T;
- if (SIMIX_is_maestro())
- xbt_die("Can't execute blocking call in kernel mode");
+ xbt_assert(not SIMIX_is_maestro(), "Can't execute blocking call in kernel mode");
smx_actor_t self = SIMIX_process_self();
simgrid::xbt::Result<T> result;
.. group-tab:: C++
- .. doxygenfunction:: simgrid::s4u::Disk::io_init(sg_size_t size, s4u::Io::OpType type)
- .. doxygenfunction:: simgrid::s4u::Disk::read(sg_size_t size)
- .. doxygenfunction:: simgrid::s4u::Disk::read_async(sg_size_t size)
- .. doxygenfunction:: simgrid::s4u::Disk::write(sg_size_t size)
- .. doxygenfunction:: simgrid::s4u::Disk::write_async(sg_size_t size)
+ .. doxygenfunction:: simgrid::s4u::Disk::io_init(sg_size_t size, s4u::Io::OpType type) const
+ .. doxygenfunction:: simgrid::s4u::Disk::read(sg_size_t size) const
+ .. doxygenfunction:: simgrid::s4u::Disk::read_async(sg_size_t size) const
+ .. doxygenfunction:: simgrid::s4u::Disk::write(sg_size_t size) const
+ .. doxygenfunction:: simgrid::s4u::Disk::write_async(sg_size_t size) const
Signals
-------
XBT_DEBUG("Set nb_bits to %d", nb_bits);
} else {
length = strlen("-timeout=");
- if (!strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) {
- timeout = (int)xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s");
- XBT_DEBUG("Set timeout to %d", timeout);
- } else {
- xbt_die("Invalid pastry option '%s'", options[0]);
- }
+ xbt_assert(strncmp(options[0], "-timeout=", length) == 0 && strlen(options[0]) > length,
+ "Invalid pastry option '%s'", options[0]);
+ timeout = (int)xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s");
+ XBT_DEBUG("Set timeout to %d", timeout);
}
options++;
}
XBT_DEBUG("Set nb_bits to %d", nb_bits);
} else {
length = strlen("-timeout=");
- if (not strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) {
- timeout = static_cast<int>(xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s"));
- XBT_DEBUG("Set timeout to %d", timeout);
- } else {
- xbt_die("Invalid chord option '%s'", options[0]);
- }
+ xbt_assert(strncmp(options[0], "-timeout=", length) == 0 && strlen(options[0]) > length,
+ "Invalid chord option '%s'", options[0]);
+ timeout = static_cast<int>(xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s"));
+ XBT_DEBUG("Set timeout to %d", timeout);
}
options++;
}
static void test(sg_size_t size)
{
- simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+ const simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
XBT_INFO("Hello! read %llu bytes from %s", size, disk->get_cname());
simgrid::s4u::IoPtr activity = disk->io_init(size, simgrid::s4u::Io::OpType::READ);
static void test_waitfor(sg_size_t size)
{
- simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+ const simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
XBT_INFO("Hello! write %llu bytes from %s", size, disk->get_cname());
simgrid::s4u::IoPtr activity = disk->write_async(size);
static void test_cancel(sg_size_t size)
{
- simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+ const simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
simgrid::s4u::this_actor::sleep_for(0.5);
XBT_INFO("Hello! write %llu bytes from %s", size, disk->get_cname());
static void test_monitor(sg_size_t size)
{
- simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
+ const simgrid::s4u::Disk* disk = simgrid::s4u::Host::current()->get_disks().front();
simgrid::s4u::this_actor::sleep_for(1);
simgrid::s4u::IoPtr activity = disk->write_async(size);
XBT_INFO("Read %llu bytes on '%s'", read, disk->get_cname());
/* - Write 800,000 bytes on Disk3 */
- simgrid::s4u::Disk* disk3 = disk_list.back();
- sg_size_t write_on_disk3 = disk3->write(800000);
+ const simgrid::s4u::Disk* disk3 = disk_list.back();
+ sg_size_t write_on_disk3 = disk3->write(800000);
XBT_INFO("Wrote %llu bytes on '%s'", write_on_disk3, disk3->get_cname());
/* - Attach some user data to disk1 */
simgrid::s4u::Engine e(&argc, argv);
- if (argc != 2) {
- XBT_CRITICAL("Usage: %s platform_file\n", argv[0]);
- xbt_die("example: %s ../platforms/small_platform.xml\n", argv[0]);
- }
+ xbt_assert(argc == 2, "Usage: %s platform_file\n"
+ "example: %s ../platforms/small_platform.xml\n",
+ argv[0], argv[0]);
e.load_platform(argv[1]);
double clock = simgrid::s4u::Engine::get_clock();
ACT_DEBUG("Entering Close: %s (filename: %s)", NAME.c_str(), file_name.c_str());
- XBT_ATTRIB_UNUSED auto count = opened_files.erase(full_name);
- xbt_assert(count == 1, "File not found in opened files: %s", full_name.c_str());
+ xbt_assert(opened_files.erase(full_name) == 1, "File not found in opened files: %s", full_name.c_str());
log_action(action, simgrid::s4u::Engine::get_clock() - clock);
}
/* load the DOT file */
dot = SD_PTG_dotload(argv[2]);
- if(dot == NULL){
- xbt_die("No dot load may be you have a cycle in your graph");
- }
+ xbt_assert(dot != NULL, "No dot load may be you have a cycle in your graph");
/* Display all the tasks */
XBT_INFO("------------------- Display all tasks of the loaded DAG ---------------------------");
<router id="WIFI router"/>
</zone>
-
<!-- NODE1 AS -->
<zone id="Wired zone" routing="Full">
<host id="node1" speed="100.0Mf,50.0Mf,20.0Mf" />
-<?xml version='1.0'?>
+<?xml version = '1.0'?>
<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
-<platform version="4.1">
- <zone id="world" routing="Full">
- <zone id="WIFI zone" routing="Wifi">
- <prop id="access_point" value="router" />
+<platform version = "4.1">
+ <zone id="WIFI zone" routing = "Wifi">
+ <prop id = "access_point" value = "router" />
- <host id="Station 1" speed="100.0Mf,50.0Mf,20.0Mf" />
- <host id="Station 2" speed="100.0Mf,50.0Mf,20.0Mf" />
+ <host id = "Station 1" speed = "100.0Mf,50.0Mf,20.0Mf" />
+ <host id = "Station 2" speed = "100.0Mf,50.0Mf,20.0Mf" />
- <router id="router"/>
+ <router id = "router"/>
- <link id="AP1" sharing_policy="WIFI" bandwidth="54Mbps" latency="0ms">
- <prop id="wifi_watt_values" value="0:1:1:0"/>
- <prop id="control_duration" value="0"/>
- </link>
- </zone>
+ <link id = "AP1" sharing_policy = "WIFI" bandwidth = "54Mbps" latency="0ms">
+ <prop id = "wifi_watt_values" value = "0:1:1:0"/>
+ <prop id = "control_duration" value = "0"/>
+ </link>
</zone>
</platform>
<?xml version='1.0'?><!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
<platform version="4.1">
- <config>
- <prop id = "network/model" value = "ns-3" />
- </config>
- <zone id="world" routing="Floyd">
-
- <zone id="SSID_1" routing="WIFI">
- <prop id="access_point" value="alice"/>
- <prop id="mcs" value="2"/> <!-- Optionnal: default = 3 -->
- <prop id="nss" value="1"/> <!-- Optionnal: default = 1 -->
-
- <host id="alice" speed="1Gf"/>
-
- <host id="STA0-0" speed="1Gf">
- <prop id="wifi_distance" value="37"/> <!-- Optionnal: default = 10 -->
- </host>
- <host id="STA0-1" speed="1Gf"/>
- </zone>
-
- <zone id="SSID_2" routing="WIFI">
- <prop id="access_point" value="bob"/>
-
- <router id="bob"/>
-
- <host id="STA1-0" speed="1Gf"/>
- <host id="STA1-1" speed="1Gf"/>
- <host id="STA1-2" speed="1Gf"/>
- </zone>
-
- <link id="wireline" bandwidth="100Mbps" latency="2ms" sharing_policy="SHARED"/>
-
- <zoneRoute src="SSID_1" dst="SSID_2" gw_src="alice" gw_dst="bob">
- <link_ctn id="wireline"/>
- </zoneRoute>
- </zone>
+ <config>
+ <prop id = "network/model" value = "ns-3" />
+ </config>
+ <zone id="world" routing="Floyd">
+
+ <zone id="SSID_1" routing="WIFI">
+ <prop id="access_point" value="alice"/>
+ <prop id="mcs" value="2"/> <!-- Optionnal: default = 3 -->
+ <prop id="nss" value="1"/> <!-- Optionnal: default = 1 -->
+
+ <host id="alice" speed="1Gf"/>
+ <host id="STA0-0" speed="1Gf">
+ <prop id="wifi_distance" value="37"/> <!-- Optionnal: default = 10 -->
+ </host>
+ <host id="STA0-1" speed="1Gf"/>
+ </zone>
+
+ <zone id="SSID_2" routing="WIFI">
+ <prop id="access_point" value="bob"/>
+
+ <router id="bob"/>
+
+ <host id="STA1-0" speed="1Gf"/>
+ <host id="STA1-1" speed="1Gf"/>
+ <host id="STA1-2" speed="1Gf"/>
+ </zone>
+
+ <link id="wireline" bandwidth="100Mbps" latency="2ms" sharing_policy="SHARED"/>
+
+ <zoneRoute src="SSID_1" dst="SSID_2" gw_src="alice" gw_dst="bob">
+ <link_ctn id="wireline"/>
+ </zoneRoute>
+ </zone>
</platform>
XBT_PUBLIC sg_host_t sg_disk_get_host(const_sg_disk_t disk);
XBT_PUBLIC double sg_disk_read_bandwidth(const_sg_disk_t disk);
XBT_PUBLIC double sg_disk_write_bandwidth(const_sg_disk_t disk);
-XBT_PUBLIC sg_size_t sg_disk_write(sg_disk_t disk, sg_size_t size);
-XBT_PUBLIC sg_size_t sg_disk_read(sg_disk_t disk, sg_size_t size);
+XBT_PUBLIC sg_size_t sg_disk_write(const_sg_disk_t disk, sg_size_t size);
+XBT_PUBLIC sg_size_t sg_disk_read(const_sg_disk_t disk, sg_size_t size);
XBT_PUBLIC void* sg_disk_get_data(const_sg_disk_t disk);
XBT_PUBLIC void sg_disk_set_data(sg_disk_t disk, void* data);
SG_END_DECL
**/
void resolve()
{
- if (status_ != FutureStatus::ready)
- xbt_die("Deadlock: this future is not ready");
+ xbt_assert(status_ == FutureStatus::ready, "Deadlock: this future is not ready");
status_ = FutureStatus::done;
if (exception_) {
std::exception_ptr exception = std::move(exception_);
#include <simgrid/kernel/routing/RoutedZone.hpp>
-
namespace simgrid {
namespace kernel {
namespace routing {
*/
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) override;
void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
+ const std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
};
} // namespace routing
} // namespace kernel
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
+ const std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
};
} // namespace routing
} // namespace kernel
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
+ const std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
private:
std::vector<RouteCreationArgs*> routing_table_;
/** @brief Create a disk with the disk model from this NetZone */
s4u::Disk* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth);
/** @brief Make a link within that NetZone */
- virtual s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy);
+ virtual s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths);
+ virtual s4u::Link* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths);
/** @brief Creates a new route in this NetZone */
virtual void add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
virtual int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
virtual void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
- std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical);
+ const std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical);
/** @brief Set parent of this Netzone */
void set_parent(NetZoneImpl* parent);
/** @brief Set network model for this Netzone */
WifiZone& operator=(const WifiZone) = delete;
void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
- s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy) override;
+ s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths) override;
NetPoint* get_access_point() const { return access_point_; }
};
} // namespace routing
std::string fullpath_;
sg_size_t current_position_ = SEEK_SET;
int desc_id = 0;
- Disk* local_disk_ = nullptr;
+ const Disk* local_disk_ = nullptr;
std::string mount_point_;
- Disk* find_local_disk_on(const Host* host);
+ const Disk* find_local_disk_on(const Host* host);
public:
File(const std::string& fullpath, void* userdata);
Disk* set_host(Host* host);
Host* get_host() const;
- IoPtr io_init(sg_size_t size, s4u::Io::OpType type);
+ IoPtr io_init(sg_size_t size, s4u::Io::OpType type) const;
- IoPtr read_async(sg_size_t size);
- sg_size_t read(sg_size_t size);
+ IoPtr read_async(sg_size_t size) const;
+ sg_size_t read(sg_size_t size) const;
- IoPtr write_async(sg_size_t size);
- sg_size_t write(sg_size_t size);
+ IoPtr write_async(sg_size_t size) const;
+ sg_size_t write(sg_size_t size) const;
void seal();
#ifndef DOXYGEN
std::vector<kernel::routing::NetPoint*> get_all_netpoints() const;
kernel::routing::NetPoint* netpoint_by_name_or_null(const std::string& name) const;
+ /**
+ * @brief Get netpoint by its name
+ *
+ * @param name Netpoint name
+ * @throw std::invalid_argument if netpoint doesn't exist
+ */
+ kernel::routing::NetPoint* netpoint_by_name(const std::string& name) const;
NetZone* get_netzone_root() const;
void set_netzone_root(const NetZone* netzone);
* @param speed_per_state list of powers for this processor (default power is at index 0)
*/
Host* set_pstate_speed(const std::vector<double>& speed_per_state);
- /** @brief Set the CPU's speed (string version) */
+ /**
+ * @brief Set the CPU's speed (string version)
+ *
+ * @throw std::invalid_argument if speed format is incorrect.
+ */
Host* set_pstate_speed(const std::vector<std::string>& speed_per_state);
/** @brief Get the peak computing speed in flops/s at the current pstate, NOT taking the external load into account.
* @param value New latency value (in s)
*/
Link* set_latency(double value);
- /** @brief Set latency (string version) */
+ /**
+ * @brief Set latency (string version)
+ *
+ * @throw std::invalid_argument if latency format is incorrect.
+ */
Link* set_latency(const std::string& value);
/** @brief Describes how the link is shared between flows */
+ Link* set_sharing_policy(SharingPolicy policy);
SharingPolicy get_sharing_policy() const;
/** Setup the profile with states events (ON or OFF). The profile must contain boolean values. */
/* Add content to the netzone, at parsing time. It should be sealed afterward. */
int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
+
+ /**
+ * @brief Add a route between 2 netpoints
+ *
+ * Create a regular route between 2 netpoints. A netpoint can be a host
+ * or a router.
+ *
+ * @param src Source netpoint
+ * @param dst Destination netpoint
+ * @param link_list List of links used in this communication
+ * @param symmetrical Bi-directional communication
+ */
+ void add_regular_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
+ const std::vector<Link*>& link_list, bool symmetrical = true);
+ /**
+ * @brief Add a route between 2 netzones
+ *
+ * Create a route between 2 netzones, connecting 2 gateways.
+ *
+ * @param src Source netzone's netpoint
+ * @param dst Destination netzone' netpoint
+ * @param src_gw Netpoint of the gateway in the source netzone
+ * @param dst_gw Netpoint of the gateway in the destination netzone
+ * @param link_list List of links used in this communication
+ * @param symmetrical Bi-directional communication
+ */
+ void add_netzone_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
+ kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
+ const std::vector<Link*>& link_list, bool symmetrical = true);
+
void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
- kernel::routing::NetPoint* gw_dst, std::vector<kernel::resource::LinkImpl*>& link_list,
+ kernel::routing::NetPoint* gw_dst, const std::vector<kernel::resource::LinkImpl*>& link_list,
bool symmetrical);
void add_bypass_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
* @param speed_per_state Vector of CPU's speeds
*/
s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate);
- /** @brief Create a Host (string version) */
+ /**
+ * @brief Create a Host (string version)
+ *
+ * @throw std::invalid_argument if speed format is incorrect.
+ */
s4u::Host* create_host(const std::string& name, const std::vector<std::string>& speed_per_pstate);
/**
* @param name Link name
* @param bandwidths Link's speed (vector for wifi links)
* @param policy Link sharing policy
+ * @throw std::invalid_argument if bandwidth format is incorrect.
*/
- s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths,
- Link::SharingPolicy policy = Link::SharingPolicy::SHARED);
+ s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths);
/** @brief Create a link (string version) */
- s4u::Link* create_link(const std::string& name, const std::vector<std::string>& bandwidths,
- Link::SharingPolicy policy = Link::SharingPolicy::SHARED);
+ s4u::Link* create_link(const std::string& name, const std::vector<std::string>& bandwidths);
+
+ /** @brief Seal this netzone configuration */
+ void seal();
+
+private:
+ /** @brief Auxiliary function to get list of LinkImpl */
+ static std::vector<kernel::resource::LinkImpl*> get_link_list_impl(const std::vector<Link*> link_list);
};
// External constructors so that the types (and the types of their content) remain hidden
integer MPI_SUCCESS, MPI_ERR_COMM, MPI_ERR_ARG, MPI_ERR_TYPE
integer MPI_ERR_REQUEST, MPI_ERR_INTERN, MPI_ERR_COUNT
- integer MPI_ERR_RANK, MPI_ERR_OTHER, MPI_ERR_UNKNOWN
- integer MPI_ERR_TAG, MPI_ERR_TRUNCATE, MPI_ERR_GROUP, MPI_ERR_OP
+ integer MPI_ERR_RANK, MPI_ERR_TAG, MPI_ERR_TRUNCATE
+ integer MPI_ERR_GROUP, MPI_ERR_OP, MPI_ERR_OTHER
+ integer MPI_ERR_IN_STATUS, MPI_ERR_PENDING, MPI_ERR_BUFFER
+ integer MPI_ERR_NAME, MPI_ERR_DIMS, MPI_ERR_TOPOLOGY
+ integer MPI_ERR_NO_MEM, MPI_ERR_WIN, MPI_ERR_INFO_VALUE
+ integer MPI_ERR_INFO_KEY, MPI_ERR_INFO_NOKEY, MPI_ERR_ROOT
+ integer MPI_ERR_KEYVAL, MPI_ERR_BASE, MPI_ERR_SPAWN
+ integer MPI_ERR_UNKNOWN
+
integer MPI_ERR_LASTCODE
integer MPI_IDENT, MPI_SIMILAR, MPI_UNEQUAL, MPI_CONGRUENT
parameter(MPI_SUCCESS=0)
parameter(MPI_ERR_GROUP=10)
parameter(MPI_ERR_OP=11)
parameter(MPI_ERR_OTHER=12)
- parameter(MPI_ERR_UNKNOWN=13)
+ parameter(MPI_ERR_IN_STATUS=13)
+ parameter(MPI_ERR_PENDING=14)
+ parameter(MPI_ERR_BUFFER=15)
+ parameter(MPI_ERR_NAME=16)
+ parameter(MPI_ERR_DIMS=17)
+ parameter(MPI_ERR_TOPOLOGY=18)
+ parameter(MPI_ERR_NO_MEM=19)
+ parameter(MPI_ERR_WIN=20)
+ parameter(MPI_ERR_INFO_VALUE=21)
+ parameter(MPI_ERR_INFO_KEY=22)
+ parameter(MPI_ERR_INFO_NOKEY=23)
+ parameter(MPI_ERR_ROOT=24)
+ parameter(MPI_ERR_KEYVAL=25)
+ parameter(MPI_ERR_BASE=26)
+ parameter(MPI_ERR_SPAWN=27)
+ parameter(MPI_ERR_UNKNOWN=28)
parameter(MPI_ERR_LASTCODE=74)
parameter(MPI_IDENT=0)
parameter(MPI_SIMILAR=1)
! Attribute keys
integer MPI_IO, MPI_HOST, MPI_WTIME_IS_GLOBAL, MPI_APPNUM
- integer MPI_TAG_UB, MPI_TAG_LB
+ integer MPI_TAG_UB, MPI_TAG_LB, MPI_BSEND_OVERHEAD
integer MPI_UNIVERSE_SIZE, MPI_LASTUSEDCODE
parameter(MPI_IO=-1)
parameter(MPI_HOST=-2)
parameter(MPI_UNIVERSE_SIZE=-7)
parameter(MPI_LASTUSEDCODE=-8)
+ parameter(MPI_BSEND_OVERHEAD=0)
! This should be equal to the number of int fields in MPI_Status
integer MPI_STATUS_SIZE
parameter(MPI_STATUS_SIZE=5)
parameter(MPI_WIN_SIZE=-2)
parameter(MPI_WIN_DISP_UNIT=-3)
+ integer MPI_GRAPH, MPI_CART
+ integer MPI_DIST_GRAPH, MPI_INVALID_TOPO
+ parameter(MPI_GRAPH=0)
+ parameter(MPI_CART=1)
+ parameter(MPI_DIST_GRAPH=2)
+ parameter(MPI_INVALID_TOPO=3)
+
! These IDs have to be unique, consecutive
! and ordered as in smpi_f77.cpp.
parameter(MPI_COMM_WORLD=0)
*
* You can pass them a format message and arguments, just as if it where a printf.
* It is converted to a XBT_CRITICAL logging request.
- * Be careful: the boolean expression that you want to test should not have side effects, because assertions are
- * disabled at compile time if NDEBUG is set.
+ * An execution backtrace is also displayed, unless the option --log=no_loc is given at run-time.
+ *
+ * Unlike the standard assert, xbt_assert is never disabled, even if the macro NDEBUG is defined at compile time. So
+ * it's safe to have a condition with side effects.
*/
-#ifdef NDEBUG
-#define xbt_assert(...) ((void)0)
-#else
/** @brief The condition which failed will be displayed.
@hideinitializer */
#define xbt_assert(...) \
abort(); \
} \
} while (0)
-#endif
/** @} */
SG_END_DECL
// Capacity
size_t size() const { return str.len; }
size_t length() const { return str.len; }
- bool empty() const { return str.len != 0; }
+ bool empty() const { return str.len == 0; }
void shrink_to_fit() { /* Being there, but doing nothing */}
// Element access
char *res = NULL;
if (s) {
res = strdup(s);
- if (!res)
- xbt_die("memory allocation error (strdup returned NULL)");
+ xbt_assert(res, "memory allocation error (strdup returned NULL)");
}
return res;
}
@hideinitializer */
static XBT_ALWAYS_INLINE void *xbt_malloc(size_t n) {
void* res = malloc(n);
- if (!res)
- xbt_die("Memory allocation of %lu bytes failed", (unsigned long)n);
+ xbt_assert(res, "Memory allocation of %lu bytes failed", (unsigned long)n);
return res;
}
@hideinitializer */
static XBT_ALWAYS_INLINE void *xbt_malloc0(size_t n) {
void* res = calloc(n, 1);
- if (!res)
- xbt_die("Memory callocation of %lu bytes failed", (unsigned long)n);
+ xbt_assert(res, "Memory callocation of %lu bytes failed", (unsigned long)n);
return res;
}
if (s) {
if (p) {
res = realloc(p, s);
- if (!res)
- xbt_die("memory (re)allocation of %lu bytes failed", (unsigned long)s);
+ xbt_assert(res, "memory (re)allocation of %lu bytes failed", (unsigned long)s);
} else {
res = xbt_malloc(s);
}
//Attach the thread to the JVM
JNIEnv *env;
- XBT_ATTRIB_UNUSED jint error = __java_vm->AttachCurrentThread((void**)&env, nullptr);
- xbt_assert((error == JNI_OK), "The thread could not be attached to the JVM");
+ xbt_assert(__java_vm->AttachCurrentThread((void**)&env, nullptr) == JNI_OK,
+ "The thread could not be attached to the JVM");
this->jenv_ = env;
}
if (env->ExceptionOccurred()) {
XBT_DEBUG("Something went wrong in this Java actor, forget about it.");
env->ExceptionClear();
- XBT_ATTRIB_UNUSED jint error = __java_vm->DetachCurrentThread();
- xbt_assert(error == JNI_OK, "Cannot detach failing thread");
+ xbt_assert(__java_vm->DetachCurrentThread() == JNI_OK, "Cannot detach failing thread");
simgrid::ForcefulKillException::do_throw();
}
}
}
msg_error_t rv = MSG_task_cancel(ptask);
- if (rv != MSG_OK)
- xbt_die("MSG_task_cancel() unexpectedly failed with error code %d. Please report this bug", rv);
+ xbt_assert(rv == MSG_OK, "MSG_task_cancel() unexpectedly failed with error code %d. Please report this bug", rv);
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_execute(JNIEnv * env, jobject jtask)
const char *father_type, double value, InstrUserVariable what)
{
simgrid::kernel::routing::NetPoint* src_elm = sg_netpoint_by_name_or_null(src);
- if (not src_elm)
- xbt_die("Element '%s' not found!",src);
+ xbt_assert(src_elm, "Element '%s' not found!", src);
simgrid::kernel::routing::NetPoint* dst_elm = sg_netpoint_by_name_or_null(dst);
- if (not dst_elm)
- xbt_die("Element '%s' not found!",dst);
+ xbt_assert(dst_elm, "Element '%s' not found!", dst);
std::vector<simgrid::kernel::resource::LinkImpl*> route;
simgrid::kernel::routing::NetZoneImpl::get_global_route(src_elm, dst_elm, route, nullptr);
// find common father
simgrid::instr::Container* father = lowestCommonAncestor(src, dst);
- if (not father) {
- xbt_die("common father unknown, this is a tracing problem");
- }
+ xbt_assert(father, "common father unknown, this is a tracing problem");
// check if we already register this pair (we only need one direction)
std::string aux1 = src->get_name() + dst->get_name();
double timeout)
{
if (MC_is_active() || MC_record_replay_is_active()) {
- if (timeout > 0.0)
- xbt_die("Timeout not implemented for waitany in the model-checker");
+ xbt_assert(timeout <= 0.0, "Timeout not implemented for waitany in the model-checker");
int idx = simcall->mc_value_;
auto* comm = comms[idx];
comm->simcalls_.push_back(simcall);
XBT_DEBUG("RawImpl::finish(): host '%s' failed", simcall->issuer_->get_host()->get_cname());
simcall->issuer_->context_->set_wannadie();
simcall->issuer_->exception_ = std::make_exception_ptr(HostFailureException(XBT_THROW_POINT, "Host failed"));
- } else if (state_ != State::SRC_TIMEOUT) {
- xbt_die("Internal error in RawImpl::finish() unexpected synchro state %d", static_cast<int>(state_));
+ } else {
+ xbt_assert(state_ == State::SRC_TIMEOUT, "Internal error in RawImpl::finish() unexpected synchro state %d",
+ static_cast<int>(state_));
}
finish_callback_();
reinterpret_cast<unsigned char**>(stack_)[-1] = alloc;
#elif !defined(_WIN32)
void* alloc;
- if (posix_memalign(&alloc, xbt_pagesize, size) != 0)
- xbt_die("Failed to allocate stack.");
+ xbt_assert(posix_memalign(&alloc, xbt_pagesize, size) == 0, "Failed to allocate stack.");
this->stack_ = static_cast<unsigned char*>(alloc);
#else
this->stack_ = static_cast<unsigned char*>(_aligned_malloc(size, xbt_pagesize));
#endif
#ifndef _WIN32
- if (mprotect(this->stack_, smx_context_guard_size, PROT_NONE) == -1) {
- xbt_die(
- "Failed to protect stack: %s.\n"
- "If you are running a lot of actors, you may be exceeding the amount of mappings allowed per process.\n"
- "On Linux systems, change this value with sudo sysctl -w vm.max_map_count=newvalue (default value: 65536)\n"
- "Please see "
- "https://simgrid.org/doc/latest/Configuring_SimGrid.html#configuring-the-user-code-virtualization for more "
- "information.",
- strerror(errno));
- /* This is fatal. We are going to fail at some point when we try reusing this. */
- }
+ /* This is fatal. We are going to fail at some point when we try reusing this. */
+ xbt_assert(
+ mprotect(this->stack_, smx_context_guard_size, PROT_NONE) != -1,
+ "Failed to protect stack: %s.\n"
+ "If you are running a lot of actors, you may be exceeding the amount of mappings allowed per process.\n"
+ "On Linux systems, change this value with sudo sysctl -w vm.max_map_count=newvalue (default value: 65536)\n"
+ "Please see https://simgrid.org/doc/latest/Configuring_SimGrid.html#configuring-the-user-code-virtualization "
+ "for more information.",
+ strerror(errno));
#endif
this->stack_ = this->stack_ + smx_context_guard_size;
} else {
/** @brief Unshare a constraint. */
void unshare() { sharing_policy_ = s4u::Link::SharingPolicy::FATPIPE; }
+ /** @brief Set how a constraint is shared */
+ void set_sharing_policy(s4u::Link::SharingPolicy policy) { sharing_policy_ = policy; }
/** @brief Check how a constraint is shared */
s4u::Link::SharingPolicy get_sharing_policy() const { return sharing_policy_; }
profile->stochastic_event_list.emplace_back(stochevent);
} else {
- XBT_ATTRIB_UNUSED int res = sscanf(val.c_str(), "%lg %lg\n", &event.date_, &event.value_);
- xbt_assert(res == 2, "%s:%d: Syntax error in trace\n%s", name.c_str(), linecount, input.c_str());
+ xbt_assert(sscanf(val.c_str(), "%lg %lg\n", &event.date_, &event.value_) == 2,
+ "%s:%d: Syntax error in trace\n%s", name.c_str(), linecount, input.c_str());
xbt_assert(last_event->date_ <= event.date_,
"%s:%d: Invalid trace: Events must be sorted, but time %g > time %g.\n%s", name.c_str(), linecount,
}
void DijkstraZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
+ const std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
{
add_route_check_params(src, dst, gw_src, gw_dst, link_list, symmetrical);
}
void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
+ const std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
{
/* set the size of table routing */
unsigned int table_size = get_table_size();
}
void FullZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
- std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
+ const std::vector<resource::LinkImpl*>& link_list, bool symmetrical)
{
add_route_check_params(src, dst, gw_src, gw_dst, link_list, symmetrical);
return l->get_iface();
}
-s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy)
+s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
- auto* l = network_model_->create_link(name, bandwidths, policy);
+ return network_model_->create_link(name, bandwidths)->get_iface();
+}
- return l->get_iface();
+s4u::Link* NetZoneImpl::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
+{
+ return network_model_->create_wifi_link(name, bandwidths)->get_iface();
}
s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
}
void NetZoneImpl::add_route(NetPoint* /*src*/, NetPoint* /*dst*/, NetPoint* /*gw_src*/, NetPoint* /*gw_dst*/,
- std::vector<resource::LinkImpl*>& /*link_list*/, bool /*symmetrical*/)
+ const std::vector<resource::LinkImpl*>& /*link_list*/, bool /*symmetrical*/)
{
xbt_die("NetZone '%s' does not accept new routes (wrong class).", get_cname());
}
void NetZoneImpl::seal()
{
+ /* already sealed netzone */
+ if (sealed_)
+ return;
do_seal(); // derived class' specific sealing procedure
+
+ /* seals sub-netzones and hosts */
+ for (auto* host : get_all_hosts()) {
+ host->seal();
+ }
+ for (auto* sub_net : *get_children()) {
+ sub_net->seal();
+ }
sealed_ = true;
}
void NetZoneImpl::set_parent(NetZoneImpl* parent)
{
- xbt_assert(sealed_ == false, "Impossible to set parent to an already sealed NetZone(%s)", this->get_cname());
+ xbt_assert(not sealed_, "Impossible to set parent to an already sealed NetZone(%s)", this->get_cname());
parent_ = parent;
netpoint_->set_englobing_zone(parent_);
}
void NetZoneImpl::set_network_model(std::shared_ptr<resource::NetworkModel> netmodel)
{
- xbt_assert(sealed_ == false, "Impossible to set network model to an already sealed NetZone(%s)", this->get_cname());
+ xbt_assert(not sealed_, "Impossible to set network model to an already sealed NetZone(%s)", this->get_cname());
network_model_ = std::move(netmodel);
}
void NetZoneImpl::set_cpu_vm_model(std::shared_ptr<resource::CpuModel> cpu_model)
{
- xbt_assert(sealed_ == false, "Impossible to set CPU model to an already sealed NetZone(%s)", this->get_cname());
+ xbt_assert(not sealed_, "Impossible to set CPU model to an already sealed NetZone(%s)", this->get_cname());
cpu_model_vm_ = std::move(cpu_model);
}
void NetZoneImpl::set_cpu_pm_model(std::shared_ptr<resource::CpuModel> cpu_model)
{
- xbt_assert(sealed_ == false, "Impossible to set CPU model to an already sealed NetZone(%s)", this->get_cname());
+ xbt_assert(not sealed_, "Impossible to set CPU model to an already sealed NetZone(%s)", this->get_cname());
cpu_model_pm_ = std::move(cpu_model);
}
void NetZoneImpl::set_disk_model(std::shared_ptr<resource::DiskModel> disk_model)
{
- xbt_assert(sealed_ == false, "Impossible to set disk model to an already sealed NetZone(%s)", this->get_cname());
+ xbt_assert(not sealed_, "Impossible to set disk model to an already sealed NetZone(%s)", this->get_cname());
disk_model_ = std::move(disk_model);
}
void NetZoneImpl::set_host_model(std::shared_ptr<surf::HostModel> host_model)
{
- xbt_assert(sealed_ == false, "Impossible to set host model to an already sealed NetZone(%s)", this->get_cname());
+ xbt_assert(not sealed_, "Impossible to set host model to an already sealed NetZone(%s)", this->get_cname());
host_model_ = std::move(host_model);
}
std::string link_up = "link_" + netpoint->get_name() + "_UP";
std::string link_down = "link_" + netpoint->get_name() + "_DOWN";
- resource::LinkImpl* linkUp =
- get_network_model()->create_link(link_up, std::vector<double>(1, bw_out), s4u::Link::SharingPolicy::SHARED);
+ resource::LinkImpl* linkUp = get_network_model()->create_link(link_up, std::vector<double>(1, bw_out));
linkUp->seal();
- resource::LinkImpl* linkDown =
- get_network_model()->create_link(link_down, std::vector<double>(1, bw_in), s4u::Link::SharingPolicy::SHARED);
+ resource::LinkImpl* linkDown = get_network_model()->create_link(link_down, std::vector<double>(1, bw_in));
linkDown->seal();
add_private_link_at(netpoint->id(), {linkUp, linkDown});
}
}
}
-s4u::Link* WifiZone::create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy)
+s4u::Link* WifiZone::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
xbt_assert(wifi_link_ == nullptr,
"WIFI netzone %s contains more than one link. Please only declare one, the wifi link.", get_cname());
- xbt_assert(policy == s4u::Link::SharingPolicy::WIFI, "Link %s in WIFI zone %s must follow the WIFI sharing policy.",
- name.c_str(), get_cname());
- auto s4u_link = NetZoneImpl::create_link(name, bandwidths, policy);
+ auto s4u_link = NetZoneImpl::create_wifi_link(name, bandwidths)->set_sharing_policy(s4u::Link::SharingPolicy::WIFI);
wifi_link_ = s4u_link->get_impl();
return s4u_link;
}
// The model-checked process SIGSTOP itself to signal it's ready:
const pid_t pid = remote_process_->pid();
- pid_t res = waitpid(pid, &status, WAITPID_CHECKED_FLAGS);
- if (res < 0 || not WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
- xbt_die("Could not wait model-checked process");
+ xbt_assert(waitpid(pid, &status, WAITPID_CHECKED_FLAGS) == pid && WIFSTOPPED(status) && WSTOPSIG(status) == SIGSTOP,
+ "Could not wait model-checked process");
if (not _sg_mc_dot_output_file.get().empty())
MC_init_dot_output();
// From PTRACE_O_TRACEEXIT:
#ifdef __linux__
if (status>>8 == (SIGTRAP | (PTRACE_EVENT_EXIT<<8))) {
- long ptrace_res = ptrace(PTRACE_GETEVENTMSG, remote_process_->pid(), 0, &status);
- xbt_assert(ptrace_res != -1, "Could not get exit status");
+ xbt_assert(ptrace(PTRACE_GETEVENTMSG, remote_process_->pid(), 0, &status) != -1, "Could not get exit status");
if (WIFSIGNALED(status)) {
MC_report_crash(status);
this->get_remote_process().terminate();
void ModelChecker::finalize_app(bool terminate_asap)
{
- s_mc_message_int_t m{MessageType::FINALIZE, terminate_asap};
- int res = checker_side_.get_channel().send(m);
- xbt_assert(res == 0, "Could not ask the app to finalize on need");
+ s_mc_message_int_t m;
+ memset(&m, 0, sizeof m);
+ m.type = MessageType::FINALIZE;
+ m.value = terminate_asap;
+ xbt_assert(checker_side_.get_channel().send(m) == 0, "Could not ask the app to finalize on need");
s_mc_message_t answer;
- ssize_t s = checker_side_.get_channel().receive(answer);
- xbt_assert(s != -1, "Could not receive answer to FINALIZE");
+ xbt_assert(checker_side_.get_channel().receive(answer) != -1, "Could not receive answer to FINALIZE");
}
bool ModelChecker::checkDeadlock()
{
- int res = checker_side_.get_channel().send(MessageType::DEADLOCK_CHECK);
- xbt_assert(res == 0, "Could not check deadlock state");
+ xbt_assert(checker_side_.get_channel().send(MessageType::DEADLOCK_CHECK) == 0, "Could not check deadlock state");
s_mc_message_int_t message;
ssize_t s = checker_side_.get_channel().receive(message);
xbt_assert(s != -1, "Could not receive message");
// Make sure we do not outlive our parent
sigset_t mask;
sigemptyset (&mask);
- int sigprocmask_res = sigprocmask(SIG_SETMASK, &mask, nullptr);
- xbt_assert(sigprocmask_res >= 0, "Could not unblock signals");
- int prctl_res = prctl(PR_SET_PDEATHSIG, SIGHUP);
- xbt_assert(prctl_res == 0, "Could not PR_SET_PDEATHSIG");
+ xbt_assert(sigprocmask(SIG_SETMASK, &mask, nullptr) >= 0, "Could not unblock signals");
+ xbt_assert(prctl(PR_SET_PDEATHSIG, SIGHUP) == 0, "Could not PR_SET_PDEATHSIG");
#endif
// Remove CLOEXEC to pass the socket to the application
- int fdflags = fcntl(socket, F_GETFD, 0);
- int fcntl_res = fdflags != -1 ? fcntl(socket, F_SETFD, fdflags & ~FD_CLOEXEC) : -1;
- xbt_assert(fcntl_res != -1, "Could not remove CLOEXEC for socket");
+ int fdflags = fcntl(socket, F_GETFD, 0);
+ xbt_assert(fdflags != -1 && fcntl(socket, F_SETFD, fdflags & ~FD_CLOEXEC) != -1,
+ "Could not remove CLOEXEC for socket");
// Disable lazy relocation in the model-checked process to prevent the application from
// modifying its .got.plt during snapshot.
// between the model-checker process (ourselves) and the model-checked
// process:
int sockets[2];
- int res = socketpair(AF_LOCAL, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sockets);
- xbt_assert(res != -1, "Could not create socketpair");
+ xbt_assert(socketpair(AF_LOCAL, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sockets) != -1, "Could not create socketpair");
pid_t pid = fork();
xbt_assert(pid >= 0, "Could not fork model-checked process");
bool Session::actor_is_enabled(aid_t pid) const
{
- s_mc_message_actor_enabled_t msg{};
+ s_mc_message_actor_enabled_t msg;
+ memset(&msg, 0, sizeof msg);
msg.type = simgrid::mc::MessageType::ACTOR_ENABLED;
msg.aid = pid;
model_checker_->channel().send(msg);
return *info->hostname;
}
-std::string Api::get_actor_name(smx_actor_t actor) const
+xbt::string const& Api::get_actor_name(smx_actor_t actor) const
{
if (mc_model_checker == nullptr)
- return actor->get_cname();
+ return actor->get_name();
simgrid::mc::ActorInformation* info = actor_info_cast(actor);
if (info->name.empty()) {
if (actor) {
res = "(" + std::to_string(actor->get_pid()) + ")";
if (actor->get_host())
- res += std::string(get_actor_host_name(actor)) + " (" + get_actor_name(actor) + ")";
+ res += std::string(get_actor_host_name(actor)) + " (" + std::string(get_actor_name(actor)) + ")";
else
res += get_actor_name(actor);
} else
THROW_IMPOSSIBLE;
}
+ // FIXME: session and checker are never deleted
simgrid::mc::session_singleton = session;
mc_model_checker->setChecker(checker);
return checker;
simgrid::kernel::activity::CommImpl* get_comm_or_nullptr(smx_simcall_t const r) const;
bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2) const;
simgrid::mc::ActorInformation* actor_info_cast(smx_actor_t actor) const;
- std::string get_actor_name(smx_actor_t actor) const;
std::string get_actor_string(smx_actor_t actor) const;
std::string get_actor_dot_label(smx_actor_t actor) const;
unsigned long get_pattern_comm_src_proc(RemotePtr<kernel::activity::CommImpl> const& addr) const;
unsigned long get_pattern_comm_dst_proc(RemotePtr<kernel::activity::CommImpl> const& addr) const;
std::vector<char> get_pattern_comm_data(RemotePtr<kernel::activity::CommImpl> const& addr) const;
+ xbt::string const& get_actor_name(smx_actor_t actor) const;
xbt::string const& get_actor_host_name(smx_actor_t actor) const;
#if HAVE_SMPI
bool check_send_request_detached(smx_simcall_t const& simcall) const;
auto current_comm_pattern =
std::find_if(begin(incomplete_pattern), end(incomplete_pattern),
[&comm_addr](const PatternCommunication* comm) { return (comm->comm_addr == comm_addr); });
- if (current_comm_pattern == std::end(incomplete_pattern))
- xbt_die("Corresponding communication not found!");
+ xbt_assert(current_comm_pattern != std::end(incomplete_pattern), "Corresponding communication not found!");
update_comm_pattern(*current_comm_pattern, comm_addr);
std::unique_ptr<PatternCommunication> comm_pattern(*current_comm_pattern);
// req is now the transition of the process that was selected to be executed
if (req == nullptr) {
- XBT_DEBUG("There are no more processes to interleave. (depth %zu)", stack_.size() + 1);
+ XBT_DEBUG("There remains %zu actors, but no more processes to interleave. (depth %zu)",
+ mc_model_checker->get_remote_process().actors().size(), stack_.size() + 1);
-// mc_model_checker->finalize_app();
+ if (mc_model_checker->get_remote_process().actors().empty())
+ mc_model_checker->finalize_app();
this->backtrack();
continue;
}
stack_.pop_back();
if (reductionMode_ == ReductionMode::dpor) {
auto call = state->executed_req_.call_;
- const kernel::actor::ActorImpl* issuer = api::get().simcall_get_issuer(&state->executed_req_);
+ kernel::actor::ActorImpl* issuer = api::get().simcall_get_issuer(&state->executed_req_);
for (auto i = stack_.rbegin(); i != stack_.rend(); ++i) {
State* prev_state = i->get();
if (state->executed_req_.issuer_ == prev_state->executed_req_.issuer_) {
if (not prev_state->actor_states_[issuer->get_pid()].is_done())
prev_state->mark_todo(issuer);
else
- XBT_DEBUG("Actor %s %ld is in done set", issuer->get_cname(), issuer->get_pid());
+ XBT_DEBUG("Actor %s %ld is in done set", api::get().get_actor_name(issuer).c_str(), issuer->get_pid());
break;
} else {
const kernel::actor::ActorImpl* previous_issuer = api::get().simcall_get_issuer(&prev_state->executed_req_);
int main(int argc, char** argv)
{
- if (argc < 2)
- xbt_die("Missing arguments.\n");
+ xbt_assert(argc >= 2, "Missing arguments");
// Currently, we need this before sg_config_init:
_sg_do_model_check = 1;
unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space)
{
unw_word_t ip = 0;
- if (c && unw_get_reg(c, UNW_REG_IP, &ip))
- xbt_die("Could not resolve IP");
+ if (c)
+ xbt_assert(unw_get_reg(c, UNW_REG_IP, &ip) == 0, "Could not resolve IP");
simgrid::dwarf::DwarfExpression const* expression = find_expression(locations, ip);
- if (not expression)
- xbt_die("Could not resolve location");
+ xbt_assert(expression != nullptr, "Could not resolve location");
return simgrid::dwarf::resolve(*expression, object_info, c, frame_pointer_address, address_space);
}
if (offset == 0)
break;
- else if (offset == -1)
- xbt_die("Error while loading location list");
+ xbt_assert(offset != -1, "Error while loading location list");
auto base_address = reinterpret_cast<std::uint64_t>(info.base_address());
xbt_assert(not dwarf_hasattr(child, DW_AT_data_bit_offset), "Can't groke DW_AT_data_bit_offset.");
if (not dwarf_hasattr_integrate(child, DW_AT_data_member_location)) {
- if (type->type == DW_TAG_union_type)
- return;
- xbt_die("Missing DW_AT_data_member_location field in DW_TAG_member %s of type <%" PRIx64 ">%s",
- member->name.c_str(), (uint64_t)type->id, type->name.c_str());
+ xbt_assert(type->type == DW_TAG_union_type,
+ "Missing DW_AT_data_member_location field in DW_TAG_member %s of type <%" PRIx64 ">%s",
+ member->name.c_str(), (uint64_t)type->id, type->name.c_str());
+ return;
}
Dwarf_Attribute attr;
static void _mc_cfg_cb_check(const char* spec, bool more_check = true)
{
- if (_sg_cfg_init_status && not _sg_do_model_check && more_check)
- xbt_die("You are specifying a %s after the initialization (through MSG_config?), but the program was not run under "
- "the model-checker (with simgrid-mc)). This won't work, sorry.",
- spec);
+ xbt_assert(_sg_cfg_init_status == 0 || _sg_do_model_check || not more_check,
+ "You are specifying a %s after the initialization (through MSG_config?), but the program was not run "
+ "under the model-checker (with simgrid-mc)). This won't work, sorry.",
+ spec);
}
/* Replay (this part is enabled even if MC it disabled) */
// Choose a request:
kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_pid(transition.aid_);
- if (actor == nullptr)
- xbt_die("Unexpected actor (id:%ld).", transition.aid_);
+ xbt_assert(actor != nullptr, "Unexpected actor (id:%ld).", transition.aid_);
const s_smx_simcall* simcall = &(actor->simcall_);
- if (simcall->call_ == simix::Simcall::NONE)
- xbt_die("No simcall for process %ld.", transition.aid_);
- if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(actor))
- xbt_die("Unexpected simcall.");
+ xbt_assert(simcall->call_ != simix::Simcall::NONE, "No simcall for process %ld.", transition.aid_);
+ xbt_assert(simgrid::mc::request_is_visible(simcall) && simgrid::mc::actor_is_enabled(actor), "Unexpected simcall.");
// Execute the request:
simcall->issuer_->simcall_handle(transition.times_considered_);
// Check the socket type/validity:
int type;
socklen_t socklen = sizeof(type);
- if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &socklen) != 0)
- xbt_die("Could not check socket type");
+ xbt_assert(getsockopt(fd, SOL_SOCKET, SO_TYPE, &type, &socklen) == 0, "Could not check socket type");
xbt_assert(type == SOCK_SEQPACKET, "Unexpected socket type %i", type);
XBT_DEBUG("Model-checked application found expected socket type");
#else
#error "no ptrace equivalent coded for this platform"
#endif
- if (errno != 0 || raise(SIGSTOP) != 0)
- xbt_die("Could not wait for the model-checker (errno = %d: %s)", errno, strerror(errno));
+ xbt_assert(errno == 0 && raise(SIGSTOP) == 0, "Could not wait for the model-checker (errno = %d: %s)", errno,
+ strerror(errno));
s_mc_message_initial_addresses_t message{
MessageType::INITIAL_ADDRESSES, mmalloc_preinit(), simgrid::kernel::actor::get_maxpid_addr(),
simgrid::simix::simix_global_get_actors_addr(), simgrid::simix::simix_global_get_dead_actors_addr()};
- int send_res = instance_->channel_.send(message);
- xbt_assert(send_res == 0, "Could not send the initial message with addresses.");
+ xbt_assert(instance_->channel_.send(message) == 0, "Could not send the initial message with addresses.");
instance_->handle_messages();
return instance_.get();
// Send result:
s_mc_message_int_t answer{MessageType::DEADLOCK_CHECK_REPLY, deadlock};
- int send_res = channel_.send(answer);
- xbt_assert(send_res == 0, "Could not send response");
+ xbt_assert(channel_.send(answer) == 0, "Could not send response");
}
void AppSide::handle_simcall_execute(const s_mc_message_simcall_handle_t* message) const
{
kernel::actor::ActorImpl* process = kernel::actor::ActorImpl::by_pid(message->aid_);
xbt_assert(process != nullptr, "Invalid pid %lu", message->aid_);
process->simcall_handle(message->times_considered_);
- if (channel_.send(MessageType::WAITING))
- xbt_die("Could not send MESSAGE_WAITING to model-checker");
+ xbt_assert(channel_.send(MessageType::WAITING) == 0, "Could not send MESSAGE_WAITING to model-checker");
}
void AppSide::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) const
// Send result:
s_mc_message_simcall_is_visible_answer_t answer{MessageType::SIMCALL_IS_VISIBLE_ANSWER, value};
- int send_res = channel_.send(answer);
- xbt_assert(send_res == 0, "Could not send response");
+ xbt_assert(channel_.send(answer) == 0, "Could not send response");
break;
}
// Send result:
s_mc_message_simcall_to_string_answer_t answer{MessageType::SIMCALL_TO_STRING_ANSWER, {0}};
value.copy(answer.value, (sizeof answer.value) - 1); // last byte was set to '\0' by initialization above
- int send_res = channel_.send(answer);
- xbt_assert(send_res == 0, "Could not send response");
+ xbt_assert(channel_.send(answer) == 0, "Could not send response");
break;
}
// Send result:
s_mc_message_simcall_to_string_answer_t answer{MessageType::SIMCALL_TO_STRING_ANSWER, {0}};
value.copy(answer.value, (sizeof answer.value) - 1); // last byte was set to '\0' by initialization above
- int send_res = channel_.send(answer);
- xbt_assert(send_res == 0, "Could not send response");
+ xbt_assert(channel_.send(answer) == 0, "Could not send response");
break;
}
case MessageType::FINALIZE: {
assert_msg_size("FINALIZE", s_mc_message_int_t);
bool terminate_asap = ((s_mc_message_int_t*)message_buffer.data())->value;
-#if HAVE_SMPI
+ XBT_DEBUG("Finalize (terminate = %d)", (int)terminate_asap);
if (not terminate_asap) {
- XBT_INFO("Finalize. Smpi_enabled: %d", (int)smpi_enabled());
- simix_global->display_all_actor_status();
+ if (XBT_LOG_ISENABLED(mc_client, xbt_log_priority_debug))
+ simix_global->display_all_actor_status();
+#if HAVE_SMPI
+ XBT_DEBUG("Smpi_enabled: %d", (int)smpi_enabled());
if (smpi_enabled())
SMPI_finalize();
- }
#endif
+ }
coverage_checkpoint();
- int send_res = channel_.send(MessageType::DEADLOCK_CHECK_REPLY); // really?
- xbt_assert(send_res == 0, "Could not answer to FINALIZE");
+ xbt_assert(channel_.send(MessageType::DEADLOCK_CHECK_REPLY) == 0, // DEADLOCK_CHECK_REPLY, really?
+ "Could not answer to FINALIZE");
if (terminate_asap)
::_Exit(0);
break;
coverage_checkpoint();
while (true) {
simgrid::mc::execute_actors();
- int send_res = channel_.send(MessageType::WAITING);
- xbt_assert(send_res == 0, "Could not send WAITING message to model-checker");
+ xbt_assert(channel_.send(MessageType::WAITING) == 0, "Could not send WAITING message to model-checker");
this->handle_messages();
}
}
void AppSide::report_assertion_failure() const
{
- if (channel_.send(MessageType::ASSERTION_FAILED))
- xbt_die("Could not send assertion to model-checker");
+ xbt_assert(channel_.send(MessageType::ASSERTION_FAILED) == 0, "Could not send assertion to model-checker");
this->handle_messages();
}
message.type = MessageType::IGNORE_MEMORY;
message.addr = (std::uintptr_t)addr;
message.size = size;
- if (channel_.send(message))
- xbt_die("Could not send IGNORE_MEMORY message to model-checker");
+ xbt_assert(channel_.send(message) == 0, "Could not send IGNORE_MEMORY message to model-checker");
}
void AppSide::ignore_heap(void* address, std::size_t size) const
heap->heapinfo[message.block].busy_frag.ignore[message.fragment]++;
}
- if (channel_.send(message))
- xbt_die("Could not send ignored region to MCer");
+ xbt_assert(channel_.send(message) == 0, "Could not send ignored region to MCer");
}
void AppSide::unignore_heap(void* address, std::size_t size) const
message.type = MessageType::UNIGNORE_HEAP;
message.addr = (std::uintptr_t)address;
message.size = size;
- if (channel_.send(message))
- xbt_die("Could not send IGNORE_HEAP message to model-checker");
+ xbt_assert(channel_.send(message) == 0, "Could not send IGNORE_HEAP message to model-checker");
}
void AppSide::declare_symbol(const char* name, int* value) const
{
s_mc_message_register_symbol_t message;
message.type = MessageType::REGISTER_SYMBOL;
- if (strlen(name) + 1 > message.name.size())
- xbt_die("Symbol is too long");
+ xbt_assert(strlen(name) + 1 <= message.name.size(), "Symbol is too long");
strncpy(message.name.data(), name, message.name.size());
message.callback = nullptr;
message.data = value;
- if (channel_.send(message))
- xbt_die("Could send REGISTER_SYMBOL message to model-checker");
+ xbt_assert(channel_.send(message) == 0, "Could send REGISTER_SYMBOL message to model-checker");
}
void AppSide::declare_stack(void* stack, size_t size, ucontext_t* context) const
s_mc_message_stack_region_t message;
message.type = MessageType::STACK_REGION;
message.stack_region = region;
- if (channel_.send(message))
- xbt_die("Could not send STACK_REGION to model-checker");
+ xbt_assert(channel_.send(message) == 0, "Could not send STACK_REGION to model-checker");
}
} // namespace mc
} // namespace simgrid
void* RemoteProcess::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, ReadOptions /*options*/) const
{
- if (pread_whole(this->memory_file, buffer, size, (size_t)address.address()) < 0)
- xbt_die("Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_);
+ xbt_assert(pread_whole(this->memory_file, buffer, size, (size_t)address.address()) != -1,
+ "Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_);
return buffer;
}
*/
void RemoteProcess::write_bytes(const void* buffer, size_t len, RemotePtr<void> address) const
{
- if (pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) < 0)
- xbt_die("Write to process %lli failed", (long long)this->pid_);
+ xbt_assert(pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) != -1,
+ "Write to process %lli failed", (long long)this->pid_);
}
static void zero_buffer_init(const void** zero_buffer, size_t zero_buffer_size)
/** Hostname (owned by `mc_model_checker->hostnames_`) */
const xbt::string* hostname = nullptr;
- std::string name;
+ xbt::string name;
void clear()
{
// Using mmap in order to be able to expand the region by relocating it somewhere else in the virtual memory space:
void* memory =
::mmap(nullptr, size << xbt_pagebits, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
- if (memory == MAP_FAILED)
- xbt_die("Could not mmap initial snapshot pages.");
+ xbt_assert(memory != MAP_FAILED, "Could not mmap initial snapshot pages.");
this->top_index_ = 0;
this->memory_ = memory;
// virtual memory address if necessary:
#if HAVE_MREMAP
new_memory = mremap(this->memory_, old_bytesize, new_bytesize, MREMAP_MAYMOVE);
- if (new_memory == MAP_FAILED)
- xbt_die("Could not mremap snapshot pages.");
+ xbt_assert(new_memory != MAP_FAILED, "Could not mremap snapshot pages.");
#else
if (new_bytesize > old_bytesize) {
// Grow: first try to add new space after current map
new_memory = mmap((char*)this->memory_ + old_bytesize, new_bytesize - old_bytesize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
- if (new_memory == MAP_FAILED)
- xbt_die("Could not mremap snapshot pages.");
+ xbt_assert(new_memory != MAP_FAILED, "Could not mremap snapshot pages.");
// Check if expanding worked
if (new_memory != (char*)this->memory_ + old_bytesize) {
// New memory segment could not be put at the end of this->memory_,
munmap(new_memory, new_bytesize - old_bytesize);
new_memory =
mmap(nullptr, new_bytesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
- if (new_memory == MAP_FAILED)
- xbt_die("Could not mremap snapshot pages.");
+ xbt_assert(new_memory != MAP_FAILED, "Could not mremap snapshot pages.");
memcpy(new_memory, this->memory_, old_bytesize);
munmap(this->memory_, old_bytesize);
}
&(stack_frame->unw_cursor), (void*)stack_frame->frame_base,
&mc_model_checker->get_remote_process());
- if (not location.in_memory())
- xbt_die("Cannot handle non-address variable");
+ xbt_assert(location.in_memory(), "Cannot handle non-address variable");
new_var.address = location.address();
} else
xbt_die("No address");
break;
int ret = unw_step(&c);
- if (ret == 0)
- xbt_die("Unexpected end of stack.");
- else if (ret < 0)
- xbt_die("Error while unwinding stack");
+ xbt_assert(ret >= 0, "Error while unwinding stack");
+ xbt_assert(ret != 0, "Unexpected end of stack.");
}
xbt_assert(not result.empty(), "unw_init_local failed");
simgrid::xbt::Extension<Disk, FileSystemDiskExt> FileSystemDiskExt::EXTENSION_ID;
simgrid::xbt::Extension<Host, FileDescriptorHostExt> FileDescriptorHostExt::EXTENSION_ID;
-Disk* File::find_local_disk_on(const Host* host)
+const Disk* File::find_local_disk_on(const Host* host)
{
- Disk* d = nullptr;
+ const Disk* d = nullptr;
size_t longest_prefix_length = 0;
for (auto const& disk : host->get_disks()) {
std::string current_mount;
longest_prefix_length = current_mount.length();
d = disk;
}
- if (longest_prefix_length > 0) { /* Mount point found, split fullpath_ into mount_name and path+filename*/
- mount_point_ = fullpath_.substr(0, longest_prefix_length);
- if (mount_point_ == std::string("/"))
- path_ = fullpath_;
- else
- path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
- XBT_DEBUG("%s + %s", mount_point_.c_str(), path_.c_str());
- } else
- xbt_die("Can't find mount point for '%s' on '%s'", fullpath_.c_str(), host->get_cname());
+ xbt_assert(longest_prefix_length > 0, "Can't find mount point for '%s' on '%s'", fullpath_.c_str(),
+ host->get_cname());
+ /* Mount point found, split fullpath_ into mount_name and path+filename*/
+ mount_point_ = fullpath_.substr(0, longest_prefix_length);
+ if (mount_point_ == std::string("/"))
+ path_ = fullpath_;
+ else
+ path_ = fullpath_.substr(longest_prefix_length, fullpath_.length());
+ XBT_DEBUG("%s + %s", mount_point_.c_str(), path_.c_str());
}
return d;
}
kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
}
-IoPtr Disk::io_init(sg_size_t size, Io::OpType type)
+IoPtr Disk::io_init(sg_size_t size, Io::OpType type) const
{
return Io::init()->set_disk(this)->set_size(size)->set_op_type(type);
}
-IoPtr Disk::read_async(sg_size_t size)
+IoPtr Disk::read_async(sg_size_t size) const
{
return IoPtr(io_init(size, Io::OpType::READ))->vetoable_start();
}
-sg_size_t Disk::read(sg_size_t size)
+sg_size_t Disk::read(sg_size_t size) const
{
return IoPtr(io_init(size, Io::OpType::READ))->vetoable_start()->wait()->get_performed_ioops();
}
-IoPtr Disk::write_async(sg_size_t size)
+IoPtr Disk::write_async(sg_size_t size) const
{
return IoPtr(io_init(size, Io::OpType::WRITE)->vetoable_start());
}
-sg_size_t Disk::write(sg_size_t size)
+sg_size_t Disk::write(sg_size_t size) const
{
return IoPtr(io_init(size, Io::OpType::WRITE))->vetoable_start()->wait()->get_performed_ioops();
}
return disk->get_write_bandwidth();
}
-sg_size_t sg_disk_read(sg_disk_t disk, sg_size_t size)
+sg_size_t sg_disk_read(const_sg_disk_t disk, sg_size_t size)
{
return disk->read(size);
}
-sg_size_t sg_disk_write(sg_disk_t disk, sg_size_t size)
+sg_size_t sg_disk_write(const_sg_disk_t disk, sg_size_t size)
{
return disk->write(size);
}
return netp == pimpl->netpoints_.end() ? nullptr : netp->second;
}
+kernel::routing::NetPoint* Engine::netpoint_by_name(const std::string& name) const
+{
+ auto netp = netpoint_by_name_or_null(name);
+ if (netp == nullptr) {
+ throw std::invalid_argument(std::string("Netpoint not found: %s") + name);
+ }
+ return netp;
+}
+
std::vector<kernel::routing::NetPoint*> Engine::get_all_netpoints() const
{
std::vector<kernel::routing::NetPoint*> res;
Host* Host::current()
{
kernel::actor::ActorImpl* self = kernel::actor::ActorImpl::self();
- if (self == nullptr)
- xbt_die("Cannot call Host::current() from the maestro context");
+ xbt_assert(self != nullptr, "Cannot call Host::current() from the maestro context");
return self->get_host();
}
double speed = xbt_parse_get_speed("", 0, speed_str.c_str(), nullptr, "");
speed_list.push_back(speed);
} catch (const simgrid::ParseError&) {
- xbt_die("Host: Impossible to set_pstate_speed, invalid speed %s", speed_str.c_str());
+ throw std::invalid_argument(std::string("Invalid speed value: ") + speed_str);
}
}
return speed_list;
void Host::seal()
{
- kernel::actor::simcall([this]() { this->pimpl_cpu->seal(); });
kernel::actor::simcall([this]() { this->pimpl_->seal(); });
}
try {
d_value = xbt_parse_get_time("", 0, value.c_str(), nullptr, "");
} catch (const simgrid::ParseError&) {
- xbt_die("Link: Impossible to latency, invalid value %s", value.c_str());
+ throw std::invalid_argument(std::string("Impossible to set latency for link: ") + get_name() +
+ std::string(". Invalid value: ") + value);
}
return set_latency(d_value);
}
return this;
}
+Link* Link::set_sharing_policy(Link::SharingPolicy policy)
+{
+ kernel::actor::simcall([this, policy] { pimpl_->set_sharing_policy(policy); });
+ return this;
+}
Link::SharingPolicy Link::get_sharing_policy() const
{
return this->pimpl_->get_sharing_policy();
return pimpl_->add_component(elm);
}
+std::vector<kernel::resource::LinkImpl*> NetZone::get_link_list_impl(const std::vector<Link*> link_list)
+{
+ std::vector<kernel::resource::LinkImpl*> links;
+ for (const auto& link : link_list) {
+ links.push_back(link->get_impl());
+ }
+ return links;
+}
+
+void NetZone::add_regular_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
+ const std::vector<Link*>& link_list, bool symmetrical)
+{
+ add_route(src, dst, nullptr, nullptr, NetZone::get_link_list_impl(link_list), symmetrical);
+}
+
+void NetZone::add_netzone_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
+ kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
+ const std::vector<Link*>& link_list, bool symmetrical)
+{
+ add_route(src, dst, gw_src, gw_dst, NetZone::get_link_list_impl(link_list), symmetrical);
+}
+
void NetZone::add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
- std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical)
+ const std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical)
{
pimpl_->add_route(src, dst, gw_src, gw_dst, link_list, symmetrical);
}
pimpl_->get_graph(graph, nodes, edges);
}
+void NetZone::seal()
+{
+ kernel::actor::simcall([this] { pimpl_->seal(); });
+}
+
s4u::Host* NetZone::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
{
return kernel::actor::simcall(
return create_host(name, Host::convert_pstate_speed_vector(speed_per_pstate));
}
-s4u::Link* NetZone::create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy)
+s4u::Link* NetZone::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
- return kernel::actor::simcall(
- [this, &name, &bandwidths, &policy] { return pimpl_->create_link(name, bandwidths, policy); });
+ return kernel::actor::simcall([this, &name, &bandwidths] { return pimpl_->create_link(name, bandwidths); });
}
-s4u::Link* NetZone::create_link(const std::string& name, const std::vector<std::string>& bandwidths,
- s4u::Link::SharingPolicy policy)
+s4u::Link* NetZone::create_link(const std::string& name, const std::vector<std::string>& bandwidths)
{
std::vector<double> bw;
bw.reserve(bandwidths.size());
double speed = xbt_parse_get_bandwidth("", 0, speed_str.c_str(), nullptr, "");
bw.push_back(speed);
} catch (const simgrid::ParseError&) {
- xbt_die("Link: Impossible to create_link, invalid bandwidth %s", speed_str.c_str());
+ throw std::invalid_argument(std::string("Impossible to create link: ") + name +
+ std::string(". Invalid bandwidth: ") + speed_str);
}
}
- return create_link(name, bw, policy);
+ return create_link(name, bw);
}
} // namespace s4u
xbt_dynar_push(result, &root_task);
SD_task_t end_task = SD_task_create_comp_seq("end", nullptr, 0);
- int res = dax_lex();
- if (res != 0)
- xbt_die("Parse error in %s: %s", filename, dax__parse_err_msg());
+ xbt_assert(dax_lex() == 0, "Parse error in %s: %s", filename, dax__parse_err_msg());
dax__delete_buffer(input_buffer);
fclose(in_file);
dax_lex_destroy();
WRAPPED_PMPI_CALL_ERRHANDLER_COMM(int,MPI_Comm_split,(MPI_Comm comm, int color, int key, MPI_Comm* comm_out),(comm, color, key, comm_out))
WRAPPED_PMPI_CALL_ERRHANDLER_COMM(int,MPI_Comm_split_type,(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm),(comm, split_type, key, info, newcomm))
WRAPPED_PMPI_CALL_ERRHANDLER_COMM(int,MPI_Comm_create_group,(MPI_Comm comm, MPI_Group group, int tag, MPI_Comm* comm_out),(comm, group, tag, comm_out))
+WRAPPED_PMPI_CALL_ERRHANDLER_COMM(int,MPI_Comm_test_inter,(MPI_Comm comm, int* flag) ,(comm, flag))
WRAPPED_PMPI_CALL_ERRHANDLER_COMM(int,MPI_Comm_call_errhandler,(MPI_Comm comm,int errorcode),(comm, errorcode))
WRAPPED_PMPI_CALL(int,MPI_Comm_create_errhandler,( MPI_Comm_errhandler_fn *function, MPI_Errhandler *errhandler),( function, errhandler))
WRAPPED_PMPI_CALL_ERRHANDLER_COMM(int,MPI_Comm_get_errhandler,(MPI_Comm comm, MPI_Errhandler* errhandler) ,(comm, errhandler))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_remote_size,(MPI_Comm comm, int* size) ,(comm, size))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn,(const char *command, char **argv, int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes),( command, argv, maxprocs, info, root, comm, intercomm, array_of_errcodes))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn_multiple,(int count, char **array_of_commands, char*** array_of_argv, int* array_of_maxprocs, MPI_Info* array_of_info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes), (count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, root, comm, intercomm, array_of_errcodes))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_test_inter,(MPI_Comm comm, int* flag) ,(comm, flag))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_Dist_graph_create, (MPI_Comm comm_old, int n, const int* sources, const int* degrees, const int* destinations, const int* weights, MPI_Info info, int reorder, MPI_Comm* comm_dist_graph), (comm_old, n, sources, degrees, destinations, weights, info, reorder, comm_dist_graph))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_Dist_graph_create_adjacent, (MPI_Comm comm_old, int indegree, const int* sources, const int* sourceweights, int outdegree, const int* destinations, const int* destweights, MPI_Info info, int reorder, MPI_Comm* comm_dist_graph), (comm_old, indegree, sources, sourceweights, outdegree, destinations, destweights, info, reorder, comm_dist_graph))
UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_Dist_graph_neighbors, (MPI_Comm comm, int maxindegree, int* sources, int* sourceweights, int maxoutdegree, int* destinations, int* destweights), (comm, maxindegree, sources, sourceweights, maxoutdegree, destinations, destweights))
MPI_Aint PMPI_Aint_add(MPI_Aint address, MPI_Aint disp)
{
- if(address > PTRDIFF_MAX - disp)
- xbt_die("overflow in MPI_Aint_add");
+ xbt_assert(address <= PTRDIFF_MAX - disp, "overflow in MPI_Aint_add");
return address + disp;
}
MPI_Aint PMPI_Aint_diff(MPI_Aint address, MPI_Aint disp)
{
- if(address < PTRDIFF_MIN + disp)
- xbt_die("underflow in MPI_Aint_diff");
+ xbt_assert(address >= PTRDIFF_MIN + disp, "underflow in MPI_Aint_diff");
return address - disp;
}
size_t size = datatype->size();
if (size == 0) {
*count = 0;
- return MPI_SUCCESS;
} else if (status->count % size != 0) {
- return MPI_UNDEFINED;
+ *count = MPI_UNDEFINED;
} else {
*count = simgrid::smpi::Status::get_count(status, datatype);
- return MPI_SUCCESS;
}
+ return MPI_SUCCESS;
}
}
return MPI_ERR_BUFFER;
if(size<0)
return MPI_ERR_ARG;
- smpi_process()->set_bsend_buffer(buf, size);
- return MPI_SUCCESS;
+ return smpi_process()->set_bsend_buffer(buf, size);
}
int PMPI_Buffer_detach(void* buffer, int* size){
smpi_process()->bsend_buffer((void**)buffer, size);
- smpi_process()->set_bsend_buffer(nullptr, 0);
- return MPI_SUCCESS;
+ return smpi_process()->set_bsend_buffer(nullptr, 0);
}
CHECK_BUFFER(5, recvbuf, count)
CHECK_TYPE(4, datatype)
CHECK_COUNT(3, count)
- CHECK_OP(5)
+ CHECK_OP(5, op, datatype)
CHECK_ROOT(7)
CHECK_REQUEST(8)
CHECK_BUFFER(2, inoutbuf, count)
CHECK_TYPE(4, datatype)
CHECK_COUNT(3, count)
- CHECK_OP(5)
+ CHECK_OP(5, op, datatype)
smpi_bench_end();
op->apply(inbuf, inoutbuf, &count, datatype);
CHECK_TYPE(4, datatype)
CHECK_COUNT(3, count)
CHECK_REQUEST(7)
- CHECK_OP(5)
+ CHECK_OP(5, op, datatype)
smpi_bench_end();
std::vector<unsigned char> tmp_sendbuf;
CHECK_TYPE(4, datatype)
CHECK_COUNT(3, count)
CHECK_REQUEST(7)
- CHECK_OP(5)
+ CHECK_OP(5, op, datatype)
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
CHECK_TYPE(4, datatype)
CHECK_COUNT(3, count)
CHECK_REQUEST(7)
- CHECK_OP(5)
+ CHECK_OP(5, op, datatype)
smpi_bench_end();
int rank = simgrid::s4u::this_actor::get_pid();
CHECK_TYPE(4, datatype)
CHECK_NULL(3, MPI_ERR_COUNT, recvcounts)
CHECK_REQUEST(7)
- CHECK_OP(5)
+ CHECK_OP(5, op, datatype)
for (int i = 0; i < comm->size(); i++) {
CHECK_COUNT(3, recvcounts[i])
CHECK_BUFFER(1, sendbuf, recvcounts[i])
CHECK_TYPE(4, datatype)
CHECK_COUNT(3, recvcount)
CHECK_REQUEST(7)
- CHECK_OP(5)
+ CHECK_OP(5, op, datatype)
smpi_bench_end();
int count = comm->size();
return PMPI_Keyval_free(keyval);
}
+int PMPI_Comm_test_inter(MPI_Comm comm, int* flag){
+ if(flag == nullptr)
+ return MPI_ERR_ARG;
+ *flag=false;
+ return MPI_SUCCESS;
+}
+
int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
CHECK_COMM(1)
if(keyval == MPI_TAG_UB||keyval == MPI_HOST||keyval == MPI_IO ||keyval == MPI_WTIME_IS_GLOBAL||keyval == MPI_APPNUM
}
int PMPI_Op_commutative(MPI_Op op, int* commute){
- CHECK_OP(1)
+ CHECK_MPI_NULL(1, MPI_OP_NULL, MPI_ERR_OP, op)
CHECK_NULL(1, MPI_ERR_ARG, commute)
*commute = op->is_commutative();
return MPI_SUCCESS;
CHECK_BUFFER(1, buf, count)\
CHECK_COUNT(2, count)\
CHECK_TYPE(3, datatype)\
+ CHECK_COMM(6)\
if(dst!= MPI_PROC_NULL)\
CHECK_RANK(4, dst, comm)\
- CHECK_TAG(5, tag)\
- CHECK_COMM(6)\
+ CHECK_TAG(5, tag)
#define CHECK_ISEND_INPUTS\
CHECK_REQUEST(7)\
CHECK_BUFFER(1, buf, count)\
CHECK_COUNT(2, count)\
CHECK_TYPE(3, datatype)\
+ CHECK_COMM(6)\
if(src!=MPI_ANY_SOURCE && src!=MPI_PROC_NULL)\
CHECK_RANK(4, src, comm)\
- CHECK_TAG(5, tag)\
- CHECK_COMM(6)
+ CHECK_TAG(5, tag)
/* PMPI User level calls */
int PMPI_Send_init(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request * request)
datatype->is_replayable() ? count : count * datatype->size(),
tag, simgrid::smpi::Datatype::encode(datatype)));
- simgrid::smpi::Request::recv(buf, count, datatype, src, tag, comm, status);
- retval = MPI_SUCCESS;
+ retval = simgrid::smpi::Request::recv(buf, count, datatype, src, tag, comm, status);
// the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
int src_traced=0;
simgrid::smpi::Request::send(sendbuf, sendcount, sendtype, dst, sendtag, comm);
retval = MPI_SUCCESS;
} else if (dst == MPI_PROC_NULL){
- simgrid::smpi::Request::recv(recvbuf, recvcount, recvtype, src, recvtag, comm, status);
- retval = MPI_SUCCESS;
+ retval = simgrid::smpi::Request::recv(recvbuf, recvcount, recvtype, src, recvtag, comm, status);
} else if (dst >= comm->group()->size() || dst <0 ||
(src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0))){
retval = MPI_ERR_RANK;
#include "private.hpp"
#include "smpi_datatype_derived.hpp"
+#include "smpi_comm.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
CHECK_NEGATIVE(1, MPI_ERR_COUNT, incount)
CHECK_TYPE(2, datatype)
CHECK_COMM(3)
- *size=incount*datatype->size();
+ *size = incount * std::max<long>(datatype->size(), datatype->get_extent());
return MPI_SUCCESS;
}
int PMPI_Accumulate(const void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Op op, MPI_Win win){
CHECK_RMA
- CHECK_OP(8)
+ CHECK_MPI_NULL(8, MPI_OP_NULL, MPI_ERR_OP, op)
CHECK_WIN(9, win)
CHECK_TARGET_DISP(5)
if(target_rank==MPI_PROC_NULL)
*request = MPI_REQUEST_NULL;
CHECK_RMA
- CHECK_OP(8)
+ CHECK_MPI_NULL(8, MPI_OP_NULL, MPI_ERR_OP, op)
CHECK_WIN(9, win)
CHECK_TARGET_DISP(5)
CHECK_NULL(10, MPI_ERR_ARG, request)
CHECK_NEGATIVE(7, MPI_ERR_RANK, target_rank)
CHECK_COUNT(9, target_count)
CHECK_TYPE(10, target_datatype)
- CHECK_OP(11)
+ CHECK_MPI_NULL(11, MPI_OP_NULL, MPI_ERR_OP, op)
CHECK_WIN(12, win)
CHECK_TARGET_DISP(8)
CHECK_NEGATIVE(7, MPI_ERR_RANK, target_rank)
CHECK_COUNT(9, target_count)
CHECK_TYPE(10, target_datatype)
- CHECK_OP(11)
+ CHECK_MPI_NULL(11, MPI_OP_NULL, MPI_ERR_OP, op)
CHECK_WIN(12, win)
CHECK_TARGET_DISP(8)
CHECK_NULL(10, MPI_ERR_ARG, request)
position = 0;
if (rank == root) {
mpi_errno = datatype->pack(buffer, count, tmp_buf, nbytes, &position, comm);
- if (mpi_errno)
- xbt_die("crash while packing %d", mpi_errno);
+ xbt_assert(mpi_errno == 0, "crash while packing %d", mpi_errno);
}
}
mpi_errno = scatter_for_bcast(root, comm,
nbytes, tmp_buf);
- if (mpi_errno) {
- xbt_die("crash while scattering %d", mpi_errno);
- }
+ xbt_assert(mpi_errno == 0, "crash while scattering %d", mpi_errno);
/* curr_size is the amount of data that this process now has stored in
* buffer at byte offset (relative_rank*scatter_size) */
/* check that we received as much as we expected */
/* recvd_size may not be accurate for packed heterogeneous data */
- if (is_homogeneous && curr_size != nbytes) {
- xbt_die("we didn't receive enough !");
- }
+ xbt_assert(not is_homogeneous || curr_size == nbytes, "we didn't receive enough !");
if (not is_contig || not is_homogeneous) {
if (rank != root) {
position = 0;
mpi_errno = MPI_Unpack(tmp_buf, nbytes, &position, buffer, count, datatype, comm);
- if (mpi_errno)
- xbt_die("error when unpacking %d", mpi_errno);
+ xbt_assert(mpi_errno == 0, "error when unpacking %d", mpi_errno);
}
}
std::vector<s_mpi_coll_description_t>* colls::get_smpi_coll_descriptions(const std::string& name)
{
auto iter = smpi_coll_descriptions.find(name);
- if (iter == smpi_coll_descriptions.end())
- xbt_die("No collective named %s. This is a bug.", name.c_str());
+ xbt_assert(iter != smpi_coll_descriptions.end(), "No collective named %s. This is a bug.", name.c_str());
return &iter->second;
}
static s_mpi_coll_description_t* find_coll_description(const std::string& collective, const std::string& algo)
{
std::vector<s_mpi_coll_description_t>* table = colls::get_smpi_coll_descriptions(collective);
- if (table->empty())
- xbt_die("No registered algorithm for collective '%s'! This is a bug.", collective.c_str());
+ xbt_assert(not table->empty(), "No registered algorithm for collective '%s'! This is a bug.", collective.c_str());
for (auto& desc : *table) {
if (algo == desc.name) {
{ \
auto desc = find_coll_description(_XBT_STRINGIFY(cat), name); \
cat = reinterpret_cast<ret(*) args>(desc->coll); \
- if (cat == nullptr) \
- xbt_die("Collective " _XBT_STRINGIFY(cat) " set to nullptr!"); \
+ xbt_assert(cat != nullptr, "Collective " _XBT_STRINGIFY(cat) " set to nullptr!"); \
}
COLL_APPLY(COLL_SETTER, COLL_GATHER_SIG, "")
COLL_APPLY(COLL_SETTER,COLL_ALLGATHER_SIG,"")
"%s: param %d %s cannot be negative", __func__, (num), _XBT_STRINGIFY(val));
#define CHECK_COMM2(num, comm) \
CHECK_MPI_NULL((num), MPI_COMM_NULL, MPI_ERR_COMM, (comm))
+#define CHECK_DELETED(num, err, obj) \
+ CHECK_ARGS((obj)->deleted(), (err), "%s: param %d %s has already been freed", __func__, (num), _XBT_STRINGIFY(obj));
#define CHECK_COMM(num) \
- CHECK_COMM2((num), comm)
+ CHECK_COMM2((num), comm) \
+ CHECK_DELETED((num), MPI_ERR_COMM, comm)
#define CHECK_REQUEST(num) \
CHECK_ARGS(request == nullptr, MPI_ERR_REQUEST, \
"%s: param %d request cannot be NULL",__func__, (num));
#define CHECK_TYPE(num, datatype) \
CHECK_ARGS(((datatype) == MPI_DATATYPE_NULL|| not (datatype)->is_valid()), MPI_ERR_TYPE, \
"%s: param %d %s cannot be MPI_DATATYPE_NULL or invalid", __func__, (num), _XBT_STRINGIFY(datatype));
-#define CHECK_OP(num) \
- CHECK_MPI_NULL((num), MPI_OP_NULL, MPI_ERR_OP, op)
+#define CHECK_OP(num, op, type) \
+ CHECK_MPI_NULL((num), MPI_OP_NULL, MPI_ERR_OP, (op)) \
+ CHECK_ARGS(((op)->allowed_types() && (((op)->allowed_types() & (type)->flags()) == 0)), MPI_ERR_OP, \
+ "%s: param %d op %s can't be applied to type %s", __func__, (num), _XBT_STRINGIFY(op), type->name());
+
#define CHECK_ROOT(num)\
CHECK_ARGS((root < 0 || root >= comm->size()), MPI_ERR_ROOT, \
"%s: param %d root (=%d) cannot be negative or larger than communicator size (=%d)", __func__, (num), \
root, comm->size());
#define CHECK_PROC(num,proc) \
- CHECK_MPI_NULL((num), MPI_PROC_NULL, MPI_SUCCESS, (proc))
+ CHECK_MPI_NULL((num), MPI_PROC_NULL, MPI_SUCCESS, (proc))
#define CHECK_INFO(num,info) \
- CHECK_MPI_NULL((num), MPI_INFO_NULL, MPI_ERR_INFO, (info))
+ CHECK_MPI_NULL((num), MPI_INFO_NULL, MPI_ERR_INFO, (info))
#define CHECK_TAG(num,tag) \
CHECK_ARGS(((tag) < 0 && (tag) != MPI_ANY_TAG), MPI_ERR_TAG, \
"%s: param %d %s (=%d) cannot be negative", __func__, (num), _XBT_STRINGIFY(tag), (tag));
#define CHECK_FILE(num, fh) \
- CHECK_MPI_NULL((num), MPI_FILE_NULL, MPI_ERR_FILE, (fh))
+ CHECK_MPI_NULL((num), MPI_FILE_NULL, MPI_ERR_FILE, (fh))
#define CHECK_OFFSET(num, offset) \
CHECK_NEGATIVE((num), MPI_ERR_DISP, (offset))
#define CHECK_GROUP(num, group) \
- CHECK_MPI_NULL((num), MPI_GROUP_NULL, MPI_ERR_GROUP, (group))
+ CHECK_MPI_NULL((num), MPI_GROUP_NULL, MPI_ERR_GROUP, (group))
#define CHECK_WIN(num, win) \
- CHECK_MPI_NULL((num), MPI_WIN_NULL, MPI_ERR_WIN, (win))
+ CHECK_MPI_NULL((num), MPI_WIN_NULL, MPI_ERR_WIN, (win))
#define CHECK_RANK(num, rank, comm) \
- CHECK_ARGS(((rank) >= (comm)->group()->size() || (rank) <0), MPI_ERR_RANK, \
+ CHECK_ARGS(((rank) >= (comm)->group()->size() || (rank) <0), MPI_ERR_RANK, \
"%s: param %d %s (=%d) cannot be < 0 or > %d", __func__, (num), _XBT_STRINGIFY(rank), \
(rank), (comm)->group()->size() );
#endif
void set_optind(int optind);
MPI_Info info_env();
void bsend_buffer(void** buf, int* size);
- void set_bsend_buffer(void* buf, int size);
+ int set_bsend_buffer(void* buf, int size);
};
} // namespace smpi
#include <string>
#include <vector>
-constexpr unsigned DT_FLAG_DESTROYED = 0x0001; /**< user destroyed but some other layers still have a reference */
-constexpr unsigned DT_FLAG_COMMITED = 0x0002; /**< ready to be used for a send/recv operation */
-constexpr unsigned DT_FLAG_CONTIGUOUS = 0x0004; /**< contiguous datatype */
-constexpr unsigned DT_FLAG_OVERLAP = 0x0008; /**< datatype is unproper for a recv operation */
-constexpr unsigned DT_FLAG_USER_LB = 0x0010; /**< has a user defined LB */
-constexpr unsigned DT_FLAG_USER_UB = 0x0020; /**< has a user defined UB */
-constexpr unsigned DT_FLAG_PREDEFINED = 0x0040; /**< cannot be removed: initial and predefined datatypes */
-constexpr unsigned DT_FLAG_NO_GAPS = 0x0080; /**< no gaps around the datatype */
-constexpr unsigned DT_FLAG_DATA = 0x0100; /**< data or control structure */
-constexpr unsigned DT_FLAG_ONE_SIDED = 0x0200; /**< datatype can be used for one sided operations */
-constexpr unsigned DT_FLAG_UNAVAILABLE = 0x0400; /**< datatypes unavailable on the build (OS or compiler dependent) */
-constexpr unsigned DT_FLAG_DERIVED = 0x0800; /**< is the datatype derived ? */
+constexpr unsigned DT_FLAG_DESTROYED = 0x00001; /**< user destroyed but some other layers still have a reference */
+constexpr unsigned DT_FLAG_COMMITED = 0x00002; /**< ready to be used for a send/recv operation */
+constexpr unsigned DT_FLAG_CONTIGUOUS = 0x00004; /**< contiguous datatype */
+constexpr unsigned DT_FLAG_OVERLAP = 0x00008; /**< datatype is unproper for a recv operation */
+constexpr unsigned DT_FLAG_USER_LB = 0x00010; /**< has a user defined LB */
+constexpr unsigned DT_FLAG_USER_UB = 0x00020; /**< has a user defined UB */
+constexpr unsigned DT_FLAG_PREDEFINED = 0x00040; /**< cannot be removed: initial and predefined datatypes */
+constexpr unsigned DT_FLAG_NO_GAPS = 0x00080; /**< no gaps around the datatype */
+constexpr unsigned DT_FLAG_DATA = 0x00100; /**< data or control structure */
+constexpr unsigned DT_FLAG_ONE_SIDED = 0x00200; /**< datatype can be used for one sided operations */
+constexpr unsigned DT_FLAG_UNAVAILABLE = 0x00400; /**< datatypes unavailable on the build (OS or compiler dependent) */
+constexpr unsigned DT_FLAG_DERIVED = 0x00800; /**< is the datatype derived ? */
+constexpr unsigned DT_FLAG_C_INTEGER = 0x01000; /**< Family: C ints */
+constexpr unsigned DT_FLAG_F_INTEGER = 0x02000; /**< Family: F ints */
+constexpr unsigned DT_FLAG_FP = 0x04000; /**< Family: Floating point */
+constexpr unsigned DT_FLAG_LOGICAL = 0x08000; /**< Family: Logical */
+constexpr unsigned DT_FLAG_COMPLEX = 0x10000; /**< Family: Complex */
+constexpr unsigned DT_FLAG_BYTE = 0x20000; /**< Family: Poor lonesome byte */
+constexpr unsigned DT_FLAG_MULTILANG = 0x40000; /**< Family: Multi-language */
+constexpr unsigned DT_FLAG_REDUCTION = 0x80000; /**< Family: Dual types for maxloc/minloc */
/*
* We should make the difference here between the predefined contiguous and non contiguous
* datatypes. The DT_FLAG_BASIC is held by all predefined contiguous datatypes.
static int f2c_id_;
static f2c_lookup_type::size_type num_default_handles_;
int my_f2c_id_ = -1;
+ bool deleted_ = false;
protected:
static void allocate_lookup()
}
static int f2c_id() { return f2c_id_; }
static void f2c_id_increment() { f2c_id_++; }
+ void mark_as_deleted() { deleted_ = true; };
public:
+ bool deleted() const { return deleted_; }
static f2c_lookup_type* lookup() { return f2c_lookup_.get(); }
F2C();
virtual ~F2C() = default;
int add_f();
static void free_f(int id) { f2c_lookup_->erase(id); }
int c2f();
- static void print_f2c_lookup();
+
// This method should be overridden in all subclasses to avoid casting the result when calling it.
// For the default one, the MPI_*_NULL returned is assumed to be NULL.
static F2C* f2c(int id);
bool is_fortran_op_ = false;
int refcount_ = 1;
bool is_predefined_;
+ int types_; //bitmask of the allowed datatypes flags
public:
- Op(MPI_User_function* function, bool commutative, bool predefined=false) : func_(function), is_commutative_(commutative), is_predefined_(predefined) {if(not predefined) this->add_f();}
+ Op(MPI_User_function* function, bool commutative, bool predefined=false, int types=0) : func_(function), is_commutative_(commutative), is_predefined_(predefined), types_(types) {if(not predefined) this->add_f();}
bool is_commutative() const { return is_commutative_; }
bool is_predefined() const { return is_predefined_; }
bool is_fortran_op() const { return is_fortran_op_; }
+ int allowed_types() const { return types_; }
// tell that we were created from fortran, so we need to translate the type to fortran when called
void set_fortran_op() { is_fortran_op_ = true; }
void apply(const void* invec, void* inoutvec, const int* len, MPI_Datatype datatype) const;
static MPI_Request issend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
static MPI_Request irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm);
- static void recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status);
+ static int recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status);
static void bsend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
static void send(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
static void ssend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
*size = bsend_buffer_size_;
}
-void ActorExt::set_bsend_buffer(void* buf, int size)
+int ActorExt::set_bsend_buffer(void* buf, int size)
{
+ if(buf!=nullptr && bsend_buffer_!=nullptr)
+ return MPI_ERR_BUFFER;
bsend_buffer_ = buf;
bsend_buffer_size_= size;
+ return MPI_SUCCESS;
}
} // namespace smpi
if (not smpi_cfg_papi_events_file().empty()) {
int event_set = smpi_process()->papi_event_set();
// PAPI_start sets everything to 0! See man(3) PAPI_start
- if (PAPI_LOW_LEVEL_INITED == PAPI_is_initialized() && event_set && PAPI_start(event_set) != PAPI_OK) {
- xbt_die("Could not start PAPI counters (TODO: this needs some proper handling).");
- }
+ if (PAPI_LOW_LEVEL_INITED == PAPI_is_initialized() && event_set)
+ xbt_assert(PAPI_start(event_set) == PAPI_OK,
+ "Could not start PAPI counters (TODO: this needs some proper handling).");
}
#endif
xbt_os_threadtimer_start(smpi_process()->timer());
int event_set = smpi_process()->papi_event_set();
std::vector<long long> event_values(counter_data.size());
- if (event_set && PAPI_stop(event_set, &event_values[0]) != PAPI_OK) // Error
- xbt_die("Could not stop PAPI counters.");
+ if (event_set)
+ xbt_assert(PAPI_stop(event_set, &event_values[0]) == PAPI_OK, "Could not stop PAPI counters.");
for (unsigned int i = 0; i < counter_data.size(); i++)
counter_data[i].second += event_values[i];
}
XBT_DEBUG("sample2 %s %d", loc.c_str(), iter_count);
auto sample = samples.find(loc);
- if (sample == samples.end())
- xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
+ xbt_assert(sample != samples.end(),
+ "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
const LocalData& data = sample->second;
if (data.benching) {
XBT_DEBUG("sample3 %s", loc.c_str());
auto sample = samples.find(loc);
- if (sample == samples.end())
- xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
+ xbt_assert(sample != samples.end(),
+ "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
LocalData& data = sample->second;
if (not data.benching)
XBT_DEBUG("sample exit %s", loc.c_str());
auto sample = samples.find(loc);
- if (sample == samples.end())
- xbt_die("Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
-
+ xbt_assert(sample != samples.end(),
+ "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
+
if (smpi_process()->sampling()){//end of loop, but still sampling needed
const LocalData& data = sample->second;
smpi_process()->set_sampling(0);
{
int fdin = open(src.c_str(), O_RDONLY);
xbt_assert(fdin >= 0, "Cannot read from %s. Please make sure that the file exists and is executable.", src.c_str());
- XBT_ATTRIB_UNUSED int unlink_status = unlink(target.c_str());
- xbt_assert(unlink_status == 0 || errno == ENOENT, "Failed to unlink file %s: %s", target.c_str(), strerror(errno));
+ xbt_assert(unlink(target.c_str()) == 0 || errno == ENOENT, "Failed to unlink file %s: %s", target.c_str(),
+ strerror(errno));
int fdout = open(target.c_str(), O_CREAT | O_RDWR | O_EXCL, S_IRWXU);
xbt_assert(fdout >= 0, "Cannot write into %s: %s", target.c_str(), strerror(errno));
close(fdin);
close(fdout);
return;
- } else if (sent_size != -1 || errno != ENOSYS) {
- xbt_die("Error while copying %s: only %zd bytes copied instead of %" PRIdMAX " (errno: %d -- %s)", target.c_str(),
- sent_size, static_cast<intmax_t>(fdin_size), errno, strerror(errno));
}
+ xbt_assert(sent_size == -1 && errno == ENOSYS,
+ "Error while copying %s: only %zd bytes copied instead of %" PRIdMAX " (errno: %d -- %s)", target.c_str(),
+ sent_size, static_cast<intmax_t>(fdin_size), errno, strerror(errno));
#endif
// If this point is reached, sendfile() actually is not available. Copy file by hand.
std::vector<unsigned char> buf(1024 * 1024 * 4);
for (auto const& libname : privatize_libs) {
// load the library once to add it to the local libs, to get the absolute path
void* libhandle = dlopen(libname.c_str(), RTLD_LAZY);
- xbt_assert(libhandle != nullptr,
- "Cannot dlopen %s - check your settings in smpi/privatize-libs", libname.c_str());
+ xbt_assert(libhandle != nullptr, "Cannot dlopen %s - check your settings in smpi/privatize-libs",
+ libname.c_str());
// get library name from path
std::string fullpath = libname;
#if not defined(__APPLE__) && not defined(__HAIKU__)
- XBT_ATTRIB_UNUSED int dl_iterate_res = dl_iterate_phdr(visit_libs, &fullpath);
- xbt_assert(dl_iterate_res != 0, "Can't find a linked %s - check your settings in smpi/privatize-libs",
- fullpath.c_str());
+ xbt_assert(dl_iterate_phdr(visit_libs, &fullpath) != 0,
+ "Can't find a linked %s - check your settings in smpi/privatize-libs", fullpath.c_str());
XBT_DEBUG("Extra lib to privatize '%s' found", fullpath.c_str());
#else
xbt_die("smpi/privatize-libs is not (yet) compatible with OSX nor with Haiku");
void* smpi_temp_shm_mmap(int fd, size_t size)
{
struct stat st;
- if (fstat(fd, &st) != 0)
- xbt_die("Could not stat fd %d: %s", fd, strerror(errno));
- if (static_cast<off_t>(size) > st.st_size && ftruncate(fd, static_cast<off_t>(size)) != 0)
- xbt_die("Could not truncate fd %d to %zu: %s", fd, size, strerror(errno));
+ xbt_assert(fstat(fd, &st) == 0, "Could not stat fd %d: %s", fd, strerror(errno));
+ xbt_assert(static_cast<off_t>(size) <= st.st_size || ftruncate(fd, static_cast<off_t>(size)) == 0,
+ "Could not truncate fd %d to %zu: %s", fd, size, strerror(errno));
void* mem = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (mem == MAP_FAILED) {
- xbt_die("Failed to map fd %d with size %zu: %s\n"
- "If you are running a lot of ranks, you may be exceeding the amount of mappings allowed per process.\n"
- "On Linux systems, change this value with sudo sysctl -w vm.max_map_count=newvalue (default value: 65536)\n"
- "Please see "
- "https://simgrid.org/doc/latest/Configuring_SimGrid.html#configuring-the-user-code-virtualization for more "
- "information.",
- fd, size, strerror(errno));
- }
+ xbt_assert(
+ mem != MAP_FAILED,
+ "Failed to map fd %d with size %zu: %s\n"
+ "If you are running a lot of ranks, you may be exceeding the amount of mappings allowed per process.\n"
+ "On Linux systems, change this value with sudo sysctl -w vm.max_map_count=newvalue (default value: 65536)\n"
+ "Please see https://simgrid.org/doc/latest/Configuring_SimGrid.html#configuring-the-user-code-virtualization for "
+ "more information.",
+ fd, size, strerror(errno));
return mem;
}
XBT_DEBUG("Switching data frame to the one of process %ld", actor->get_pid());
const simgrid::smpi::ActorExt* process = smpi_process_remote(actor);
int current = process->privatized_region()->file_descriptor;
- const void* tmp = mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_RW, MAP_FIXED | MAP_SHARED, current, 0);
- if (tmp != TOPAGE(smpi_data_exe_start))
- xbt_die("Couldn't map the new region (errno %d): %s", errno, strerror(errno));
+ xbt_assert(mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_RW, MAP_FIXED | MAP_SHARED, current, 0) ==
+ TOPAGE(smpi_data_exe_start),
+ "Couldn't map the new region (errno %d): %s", errno, strerror(errno));
smpi_loaded_page = actor->get_pid();
#endif
}
smpi_shared_malloc_bogusfile = mkstemp(name);
XBT_DEBUG("bogusfile : %s\n", name);
unlink(name);
- int err = ftruncate(smpi_shared_malloc_bogusfile, smpi_shared_malloc_blocksize);
- if (err != 0)
- xbt_die("Could not write bogus file for shared malloc");
+ xbt_assert(ftruncate(smpi_shared_malloc_bogusfile, smpi_shared_malloc_blocksize) == 0,
+ "Could not write bogus file for shared malloc");
}
int mmap_base_flag = MAP_FIXED | MAP_SHARED | MAP_POPULATE;
#include "smpi_f2c.hpp"
#include "src/simix/smx_private.hpp"
+#include <algorithm>
+
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_utils, smpi, "Logging specific to SMPI (utils)");
extern std::string surf_parsed_filename;
XBT_DEBUG("token : %s", token_iter->c_str());
Tokenizer factor_values(*token_iter, factor_separator);
s_smpi_factor_t fact;
- if (factor_values.begin() == factor_values.end()) {
- xbt_die("Malformed radical for smpi factor: '%s'", smpi_coef_string.c_str());
- }
+ xbt_assert(factor_values.begin() != factor_values.end(), "Malformed radical for smpi factor: '%s'",
+ smpi_coef_string.c_str());
unsigned int iteration = 0;
for (Tokenizer::iterator factor_iter = factor_values.begin(); factor_iter != factor_values.end(); ++factor_iter) {
iteration++;
}
}
-void print_memory_analysis(){
- if (simgrid::smpi::F2C::lookup() != nullptr &&
- simgrid::smpi::F2C::lookup()->size() > simgrid::smpi::F2C::get_num_default_handles()) {
+void print_memory_analysis()
+{
+ size_t leak_count = 0;
+ if (simgrid::smpi::F2C::lookup() != nullptr)
+ leak_count =
+ std::count_if(simgrid::smpi::F2C::lookup()->cbegin(), simgrid::smpi::F2C::lookup()->cend(),
+ [](auto const& entry) { return entry.first >= simgrid::smpi::F2C::get_num_default_handles(); });
+ if (leak_count > 0) {
XBT_INFO("Probable memory leaks in your code: SMPI detected %zu unfreed MPI handles : "
"display types and addresses (n max) with --cfg=smpi/list-leaks:n.\n"
"Running smpirun with -wrapper \"valgrind --leak-check=full\" can provide more information",
- simgrid::smpi::F2C::lookup()->size() - simgrid::smpi::F2C::get_num_default_handles());
+ leak_count);
int n = simgrid::config::get_value<int>("smpi/list-leaks");
for (auto const& p : *simgrid::smpi::F2C::lookup()) {
static int printed = 0;
XBT_INFO("%lu bytes were automatically shared between processes, in %u calls\n", total_shared_size, total_shared_calls);
}
}
-
}
}
} // namespace simgrid
Comm::destroy(smpi_process()->comm_world());
return;
}
+ if(comm != MPI_COMM_WORLD && comm != MPI_COMM_SELF)
+ comm->mark_as_deleted();
Comm::unref(comm);
}
if(info_!=MPI_INFO_NULL)
(*newcomm)->info_ = new simgrid::smpi::Info(info_);
//duplicate errhandler
- (*newcomm)->set_errhandler(errhandler_);
+ if (errhandlers_ != nullptr)//MPI_COMM_WORLD, only grab our own
+ (*newcomm)->set_errhandler(errhandlers_[this->rank()]);
+ else
+ (*newcomm)->set_errhandler(errhandler_);
return ret;
}
static std::unordered_map<std::string, simgrid::smpi::Datatype*> id2type_lookup;
-#define CREATE_MPI_DATATYPE(name, id, type) \
+#define CREATE_MPI_DATATYPE(name, id, type, flag) \
simgrid::smpi::Datatype _XBT_CONCAT(smpi_MPI_, name)((char*)"MPI_"#name, (id), sizeof(type), /* size */ \
0, /* lb */ \
sizeof(type), /* ub = lb + size */ \
- DT_FLAG_BASIC /* flags */ \
+ DT_FLAG_BASIC | flag /* flags */ \
);
#define CREATE_MPI_DATATYPE_NULL(name, id) \
// Predefined data types
CREATE_MPI_DATATYPE_NULL(DATATYPE_NULL, -1)
-CREATE_MPI_DATATYPE(DOUBLE, 0, double)
-CREATE_MPI_DATATYPE(INT, 1, int)
-CREATE_MPI_DATATYPE(CHAR, 2, char)
-CREATE_MPI_DATATYPE(SHORT, 3, short)
-CREATE_MPI_DATATYPE(LONG, 4, long)
-CREATE_MPI_DATATYPE(FLOAT, 5, float)
-CREATE_MPI_DATATYPE(BYTE, 6, int8_t)
-CREATE_MPI_DATATYPE(LONG_LONG, 7, long long)
-CREATE_MPI_DATATYPE(SIGNED_CHAR, 8, signed char)
-CREATE_MPI_DATATYPE(UNSIGNED_CHAR, 9, unsigned char)
-CREATE_MPI_DATATYPE(UNSIGNED_SHORT, 10, unsigned short)
-CREATE_MPI_DATATYPE(UNSIGNED, 11, unsigned int)
-CREATE_MPI_DATATYPE(UNSIGNED_LONG, 12, unsigned long)
-CREATE_MPI_DATATYPE(UNSIGNED_LONG_LONG, 13, unsigned long long)
-CREATE_MPI_DATATYPE(LONG_DOUBLE, 14, long double)
-CREATE_MPI_DATATYPE(WCHAR, 15, wchar_t)
-CREATE_MPI_DATATYPE(C_BOOL, 16, bool)
-CREATE_MPI_DATATYPE(INT8_T, 17, int8_t)
-CREATE_MPI_DATATYPE(INT16_T, 18, int16_t)
-CREATE_MPI_DATATYPE(INT32_T, 19, int32_t)
-CREATE_MPI_DATATYPE(INT64_T, 20, int64_t)
-CREATE_MPI_DATATYPE(UINT8_T, 21, uint8_t)
-CREATE_MPI_DATATYPE(UINT16_T, 22, uint16_t)
-CREATE_MPI_DATATYPE(UINT32_T, 23, uint32_t)
-CREATE_MPI_DATATYPE(UINT64_T, 24, uint64_t)
-CREATE_MPI_DATATYPE(C_FLOAT_COMPLEX, 25, float _Complex)
-CREATE_MPI_DATATYPE(C_DOUBLE_COMPLEX, 26, double _Complex)
-CREATE_MPI_DATATYPE(C_LONG_DOUBLE_COMPLEX, 27, long double _Complex)
-CREATE_MPI_DATATYPE(AINT, 28, MPI_Aint)
-CREATE_MPI_DATATYPE(OFFSET, 29, MPI_Offset)
-
-CREATE_MPI_DATATYPE(FLOAT_INT, 30, float_int)
-CREATE_MPI_DATATYPE(LONG_INT, 31, long_int)
-CREATE_MPI_DATATYPE(DOUBLE_INT, 32, double_int)
-CREATE_MPI_DATATYPE(SHORT_INT, 33, short_int)
-CREATE_MPI_DATATYPE(2INT, 34, int_int)
-CREATE_MPI_DATATYPE(2FLOAT, 35, float_float)
-CREATE_MPI_DATATYPE(2DOUBLE, 36, double_double)
-CREATE_MPI_DATATYPE(2LONG, 37, long_long)
-
-CREATE_MPI_DATATYPE(REAL, 38, float)
-CREATE_MPI_DATATYPE(REAL4, 39, float)
-CREATE_MPI_DATATYPE(REAL8, 40, double)
-CREATE_MPI_DATATYPE(REAL16, 41, long double)
-CREATE_MPI_DATATYPE(COMPLEX8, 42, float_float)
-CREATE_MPI_DATATYPE(COMPLEX16, 43, double_double)
-CREATE_MPI_DATATYPE(COMPLEX32, 44, double_double)
-CREATE_MPI_DATATYPE(INTEGER1, 45, int)
-CREATE_MPI_DATATYPE(INTEGER2, 46, int16_t)
-CREATE_MPI_DATATYPE(INTEGER4, 47, int32_t)
-CREATE_MPI_DATATYPE(INTEGER8, 48, int64_t)
-CREATE_MPI_DATATYPE(INTEGER16, 49, integer128_t)
-
-CREATE_MPI_DATATYPE(LONG_DOUBLE_INT, 50, long_double_int)
-CREATE_MPI_DATATYPE(CXX_BOOL, 51, bool)
-CREATE_MPI_DATATYPE(CXX_FLOAT_COMPLEX, 52, std::complex<float>)
-CREATE_MPI_DATATYPE(CXX_DOUBLE_COMPLEX, 53, std::complex<double>)
-CREATE_MPI_DATATYPE(CXX_LONG_DOUBLE_COMPLEX, 54, std::complex<long double>)
+CREATE_MPI_DATATYPE(DOUBLE, 0, double, DT_FLAG_FP)
+CREATE_MPI_DATATYPE(INT, 1, int, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(CHAR, 2, char, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(SHORT, 3, short, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(LONG, 4, long, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(FLOAT, 5, float, DT_FLAG_FP)
+CREATE_MPI_DATATYPE(BYTE, 6, int8_t, DT_FLAG_BYTE)
+CREATE_MPI_DATATYPE(LONG_LONG, 7, long long, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(SIGNED_CHAR, 8, signed char, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(UNSIGNED_CHAR, 9, unsigned char, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(UNSIGNED_SHORT, 10, unsigned short, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(UNSIGNED, 11, unsigned int, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(UNSIGNED_LONG, 12, unsigned long, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(UNSIGNED_LONG_LONG, 13, unsigned long long, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(LONG_DOUBLE, 14, long double, DT_FLAG_FP)
+CREATE_MPI_DATATYPE(WCHAR, 15, wchar_t, DT_FLAG_BASIC)
+CREATE_MPI_DATATYPE(C_BOOL, 16, bool, DT_FLAG_LOGICAL)
+CREATE_MPI_DATATYPE(INT8_T, 17, int8_t, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(INT16_T, 18, int16_t, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(INT32_T, 19, int32_t, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(INT64_T, 20, int64_t, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(UINT8_T, 21, uint8_t, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(UINT16_T, 22, uint16_t, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(UINT32_T, 23, uint32_t, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(UINT64_T, 24, uint64_t, DT_FLAG_C_INTEGER)
+CREATE_MPI_DATATYPE(C_FLOAT_COMPLEX, 25, float _Complex, DT_FLAG_COMPLEX)
+CREATE_MPI_DATATYPE(C_DOUBLE_COMPLEX, 26, double _Complex, DT_FLAG_COMPLEX)
+CREATE_MPI_DATATYPE(C_LONG_DOUBLE_COMPLEX, 27, long double _Complex, DT_FLAG_COMPLEX)
+CREATE_MPI_DATATYPE(AINT, 28, MPI_Aint, DT_FLAG_MULTILANG)
+CREATE_MPI_DATATYPE(OFFSET, 29, MPI_Offset, DT_FLAG_MULTILANG)
+
+CREATE_MPI_DATATYPE(FLOAT_INT, 30, float_int, DT_FLAG_REDUCTION)
+CREATE_MPI_DATATYPE(LONG_INT, 31, long_int, DT_FLAG_REDUCTION)
+CREATE_MPI_DATATYPE(DOUBLE_INT, 32, double_int, DT_FLAG_REDUCTION)
+CREATE_MPI_DATATYPE(SHORT_INT, 33, short_int, DT_FLAG_REDUCTION)
+CREATE_MPI_DATATYPE(2INT, 34, int_int, DT_FLAG_REDUCTION)
+CREATE_MPI_DATATYPE(2FLOAT, 35, float_float, DT_FLAG_REDUCTION)
+CREATE_MPI_DATATYPE(2DOUBLE, 36, double_double, DT_FLAG_REDUCTION)
+CREATE_MPI_DATATYPE(2LONG, 37, long_long, DT_FLAG_REDUCTION)
+
+CREATE_MPI_DATATYPE(REAL, 38, float, DT_FLAG_FP)
+CREATE_MPI_DATATYPE(REAL4, 39, float, DT_FLAG_FP)
+CREATE_MPI_DATATYPE(REAL8, 40, double, DT_FLAG_FP)
+CREATE_MPI_DATATYPE(REAL16, 41, long double, DT_FLAG_FP)
+CREATE_MPI_DATATYPE(COMPLEX8, 42, float_float, DT_FLAG_COMPLEX)
+CREATE_MPI_DATATYPE(COMPLEX16, 43, double_double, DT_FLAG_COMPLEX)
+CREATE_MPI_DATATYPE(COMPLEX32, 44, double_double, DT_FLAG_COMPLEX)
+CREATE_MPI_DATATYPE(INTEGER1, 45, int, DT_FLAG_F_INTEGER)
+CREATE_MPI_DATATYPE(INTEGER2, 46, int16_t, DT_FLAG_F_INTEGER)
+CREATE_MPI_DATATYPE(INTEGER4, 47, int32_t, DT_FLAG_F_INTEGER)
+CREATE_MPI_DATATYPE(INTEGER8, 48, int64_t, DT_FLAG_F_INTEGER)
+CREATE_MPI_DATATYPE(INTEGER16, 49, integer128_t, DT_FLAG_F_INTEGER)
+
+CREATE_MPI_DATATYPE(LONG_DOUBLE_INT, 50, long_double_int, DT_FLAG_REDUCTION)
+CREATE_MPI_DATATYPE(CXX_BOOL, 51, bool, DT_FLAG_LOGICAL)
+CREATE_MPI_DATATYPE(CXX_FLOAT_COMPLEX, 52, std::complex<float>, DT_FLAG_COMPLEX)
+CREATE_MPI_DATATYPE(CXX_DOUBLE_COMPLEX, 53, std::complex<double>, DT_FLAG_COMPLEX)
+CREATE_MPI_DATATYPE(CXX_LONG_DOUBLE_COMPLEX, 54, std::complex<long double>, DT_FLAG_COMPLEX)
CREATE_MPI_DATATYPE_NULL(UB, 55)
CREATE_MPI_DATATYPE_NULL(LB, 56)
-CREATE_MPI_DATATYPE(PACKED, 57, char)
+CREATE_MPI_DATATYPE(PACKED, 57, char, DT_FLAG_PREDEFINED)
// Internal use only
-CREATE_MPI_DATATYPE(PTR, 58, void*)
-CREATE_MPI_DATATYPE(COUNT, 59, long long)
+CREATE_MPI_DATATYPE(PTR, 58, void*, DT_FLAG_PREDEFINED)
+CREATE_MPI_DATATYPE(COUNT, 59, long long, DT_FLAG_MULTILANG)
MPI_Datatype MPI_PTR = &smpi_MPI_PTR;
if (info_ != MPI_INFO_NULL)
info_->ref();
std::string fullname=filename;
- if (simgrid::s4u::Host::current()->get_disks().empty())
- xbt_die("SMPI/IO : Trying to open file on a diskless host ! Add one to your platform file");
+ xbt_assert(not simgrid::s4u::Host::current()->get_disks().empty(),
+ "SMPI/IO : Trying to open file on a diskless host ! Add one to your platform file");
size_t found=fullname.find('/');
//in case no fullpath is provided ... just pick the first mountpoint.
APPLY_OP_LOOP(MPI_UNSIGNED_LONG, unsigned long,op)\
APPLY_OP_LOOP(MPI_UNSIGNED_LONG_LONG, unsigned long long,op)\
APPLY_OP_LOOP(MPI_WCHAR, wchar_t,op)\
-APPLY_OP_LOOP(MPI_BYTE, int8_t,op)\
APPLY_OP_LOOP(MPI_INT8_T, int8_t,op)\
APPLY_OP_LOOP(MPI_INT16_T, int16_t,op)\
APPLY_OP_LOOP(MPI_INT32_T, int32_t,op)\
#define APPLY_BOOL_OP_LOOP(op)\
APPLY_OP_LOOP(MPI_C_BOOL, bool,op)
+#define APPLY_BYTE_OP_LOOP(op)\
+APPLY_OP_LOOP(MPI_BYTE, int8_t,op)
+
#define APPLY_FLOAT_OP_LOOP(op)\
APPLY_OP_LOOP(MPI_FLOAT, float,op)\
APPLY_OP_LOOP(MPI_DOUBLE, double,op)\
{
APPLY_BASIC_OP_LOOP(BAND_OP)
APPLY_BOOL_OP_LOOP(BAND_OP)
+ APPLY_BYTE_OP_LOOP(BAND_OP)
APPLY_END_OP_LOOP(BAND_OP)
}
{
APPLY_BASIC_OP_LOOP(BOR_OP)
APPLY_BOOL_OP_LOOP(BOR_OP)
+ APPLY_BYTE_OP_LOOP(BOR_OP)
APPLY_END_OP_LOOP(BOR_OP)
}
{
APPLY_BASIC_OP_LOOP(BXOR_OP)
APPLY_BOOL_OP_LOOP(BXOR_OP)
+ APPLY_BYTE_OP_LOOP(BXOR_OP)
APPLY_END_OP_LOOP(BXOR_OP)
}
/* obviously a no-op */
}
-#define CREATE_MPI_OP(name, func) \
- SMPI_Op _XBT_CONCAT(smpi_MPI_, name)(&(func) /* func */, true, true); \
-
-CREATE_MPI_OP(MAX, max_func)
-CREATE_MPI_OP(MIN, min_func)
-CREATE_MPI_OP(SUM, sum_func)
-CREATE_MPI_OP(PROD, prod_func)
-CREATE_MPI_OP(LAND, land_func)
-CREATE_MPI_OP(LOR, lor_func)
-CREATE_MPI_OP(LXOR, lxor_func)
-CREATE_MPI_OP(BAND, band_func)
-CREATE_MPI_OP(BOR, bor_func)
-CREATE_MPI_OP(BXOR, bxor_func)
-CREATE_MPI_OP(MAXLOC, maxloc_func)
-CREATE_MPI_OP(MINLOC, minloc_func)
-CREATE_MPI_OP(REPLACE, replace_func)
-CREATE_MPI_OP(NO_OP, no_func)
+
+#define CREATE_MPI_OP(name, func, types) \
+ SMPI_Op _XBT_CONCAT(smpi_MPI_, name)(&(func) /* func */, true, true, types);
+
+#define MAX_TYPES DT_FLAG_C_INTEGER|DT_FLAG_F_INTEGER|DT_FLAG_FP|DT_FLAG_MULTILANG
+#define LAND_TYPES DT_FLAG_C_INTEGER|DT_FLAG_FP|DT_FLAG_LOGICAL|DT_FLAG_MULTILANG
+#define BAND_TYPES DT_FLAG_C_INTEGER|DT_FLAG_FP|DT_FLAG_BYTE|DT_FLAG_MULTILANG
+
+CREATE_MPI_OP(MAX, max_func, MAX_TYPES)
+CREATE_MPI_OP(MIN, min_func, MAX_TYPES)
+CREATE_MPI_OP(SUM, sum_func, MAX_TYPES|DT_FLAG_COMPLEX)
+CREATE_MPI_OP(PROD, prod_func, MAX_TYPES|DT_FLAG_COMPLEX)
+CREATE_MPI_OP(LAND, land_func, LAND_TYPES)
+CREATE_MPI_OP(LOR, lor_func, LAND_TYPES)
+CREATE_MPI_OP(LXOR, lxor_func, LAND_TYPES)
+CREATE_MPI_OP(BAND, band_func, BAND_TYPES)
+CREATE_MPI_OP(BOR, bor_func, BAND_TYPES)
+CREATE_MPI_OP(BXOR, bxor_func, BAND_TYPES)
+CREATE_MPI_OP(MAXLOC, maxloc_func, DT_FLAG_REDUCTION)
+CREATE_MPI_OP(MINLOC, minloc_func, DT_FLAG_REDUCTION)
+CREATE_MPI_OP(REPLACE, replace_func, 0)
+CREATE_MPI_OP(NO_OP, no_func, 0)
namespace simgrid{
namespace smpi{
void Request::unref(MPI_Request* request)
{
- if((*request) != MPI_REQUEST_NULL){
- (*request)->refcount_--;
- if((*request)->refcount_ < 0) {
- (*request)->print_request("wrong refcount");
- xbt_die("Whoops, wrong refcount");
- }
- if((*request)->refcount_==0){
- if ((*request)->flags_ & MPI_REQ_GENERALIZED){
- ((*request)->generalized_funcs)->free_fn(((*request)->generalized_funcs)->extra_state);
- }else{
- Comm::unref((*request)->comm_);
- Datatype::unref((*request)->old_type_);
- }
- if ((*request)->op_!=MPI_REPLACE && (*request)->op_!=MPI_OP_NULL)
- Op::unref(&(*request)->op_);
+ xbt_assert(*request != MPI_REQUEST_NULL, "freeing an already free request");
- (*request)->print_request("Destroying");
- F2C::free_f((*request)->c2f());
- delete *request;
- *request = MPI_REQUEST_NULL;
- }else{
- (*request)->print_request("Decrementing");
+ (*request)->refcount_--;
+ if ((*request)->refcount_ < 0) {
+ (*request)->print_request("wrong refcount");
+ xbt_die("Whoops, wrong refcount");
+ }
+ if ((*request)->refcount_ == 0) {
+ if ((*request)->flags_ & MPI_REQ_GENERALIZED) {
+ ((*request)->generalized_funcs)->free_fn(((*request)->generalized_funcs)->extra_state);
+ } else {
+ Comm::unref((*request)->comm_);
+ Datatype::unref((*request)->old_type_);
}
- }else{
- xbt_die("freeing an already free request");
+ if ((*request)->op_ != MPI_REPLACE && (*request)->op_ != MPI_OP_NULL)
+ Op::unref(&(*request)->op_);
+
+ (*request)->print_request("Destroying");
+ F2C::free_f((*request)->c2f());
+ delete *request;
+ *request = MPI_REQUEST_NULL;
+ } else {
+ (*request)->print_request("Decrementing");
}
}
receiver->real_src_ = sender->src_;
if (receiver->tag_ == MPI_ANY_TAG)
receiver->real_tag_ = sender->tag_;
- if (receiver->real_size_ < sender->real_size_ && ((receiver->flags_ & MPI_REQ_PROBE) == 0 )){
- XBT_DEBUG("Truncating message - should not happen: receiver size : %zu < sender size : %zu", receiver->real_size_, sender->real_size_);
- receiver->truncated_ = true;
+ if ((receiver->flags_ & MPI_REQ_PROBE) == 0 ){
+ if (receiver->real_size_ < sender->real_size_){
+ XBT_DEBUG("Truncating message - should not happen: receiver size : %zu < sender size : %zu", receiver->real_size_, sender->real_size_);
+ receiver->truncated_ = true;
+ } else if (receiver->real_size_ > sender->real_size_){
+ receiver->real_size_=sender->real_size_;
+ }
}
if (sender->detached_)
receiver->detached_sender_ = sender; // tie the sender to the receiver, as it is detached and has to be freed in
return request;
}
-void Request::recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status)
+int Request::recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status)
{
MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */
request = irecv(buf, count, datatype, src, tag, comm);
- wait(&request,status);
+ int retval = wait(&request,status);
request = nullptr;
+ return retval;
}
void Request::bsend(const void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
ret = ((*request)->generalized_funcs)->query_fn(((*request)->generalized_funcs)->extra_state, mystatus);
}
+ if ((*request)->truncated_)
+ ret = MPI_ERR_TRUNCATE;
+
finish_wait(request, status); // may invalidate *request
if (*request != MPI_REQUEST_NULL && (((*request)->flags_ & MPI_REQ_NON_PERSISTENT) != 0))
*request = MPI_REQUEST_NULL;
}
int Win::complete(){
- if(opened_==0)
- xbt_die("Complete called on already opened MPI_Win");
+ xbt_assert(opened_ != 0, "Complete called on already opened MPI_Win");
XBT_DEBUG("Entering MPI_Win_Complete");
int i = 0;
void HostImpl::seal()
{
+ if (sealed_) {
+ return;
+ }
+ // seals host's CPU
+ get_iface()->pimpl_cpu->seal();
sealed_ = true;
}
} // namespace surf
void Cpu::seal()
{
+ if (is_sealed()) {
+ return;
+ }
lmm::System* lmm = get_model()->get_maxmin_system();
if (dynamic_cast<CpuTiModel*>(get_model()) == nullptr)
this->set_constraint(lmm->constraint_new(this, core_count_ * speed_per_pstate_.front()));
*/
double CpuTiTmgr::integrate(double a, double b) const
{
- if ((a < 0.0) || (a > b)) {
- xbt_die("Error, invalid integration interval [%.2f,%.2f]. "
- "You probably have a task executing with negative computation amount. Check your code.",
- a, b);
- }
+ xbt_assert(a >= 0.0 && a <= b,
+ "Error, invalid integration interval [%.2f,%.2f]. You probably have a task executing with negative "
+ "computation amount. Check your code.",
+ a, b);
if (fabs(a - b) < EPSILON)
return 0.0;
NetworkCm02Model::NetworkCm02Model(const std::string& name) : NetworkModel(name)
{
- if (config::get_value<std::string>("network/optim") == "Lazy")
- set_update_algorithm(Model::UpdateAlgo::LAZY);
-
std::string optim = config::get_value<std::string>("network/optim");
bool select = config::get_value<bool>("network/maxmin-selective-update");
if (optim == "Lazy") {
+ set_update_algorithm(Model::UpdateAlgo::LAZY);
xbt_assert(select || config::is_default("network/maxmin-selective-update"),
"You cannot disable network selective update when using the lazy update mechanism");
select = true;
}
set_maxmin_system(new lmm::System(select));
- loopback_ = NetworkCm02Model::create_link("__loopback__",
- std::vector<double>{config::get_value<double>("network/loopback-bw")},
- s4u::Link::SharingPolicy::FATPIPE)
+ loopback_ = create_link("__loopback__", std::vector<double>{config::get_value<double>("network/loopback-bw")})
+ ->set_sharing_policy(s4u::Link::SharingPolicy::FATPIPE)
->set_latency(config::get_value<double>("network/loopback-lat"));
loopback_->seal();
}
-LinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy)
+LinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
- LinkImpl* link;
- if (policy == s4u::Link::SharingPolicy::WIFI) {
- link = new NetworkWifiLink(name, bandwidths, get_maxmin_system());
- } else {
- xbt_assert(bandwidths.size() == 1, "Non-WIFI links must use only 1 bandwidth.");
- link = new NetworkCm02Link(name, bandwidths[0], policy, get_maxmin_system());
- }
+ xbt_assert(bandwidths.size() == 1, "Non-WIFI links must use only 1 bandwidth.");
+ return (new NetworkCm02Link(name, bandwidths[0], get_maxmin_system()))->set_model(this);
+}
- link->set_model(this);
- return link;
+LinkImpl* NetworkCm02Model::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
+{
+ return (new NetworkWifiLink(name, bandwidths, get_maxmin_system()))->set_model(this);
}
void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
/************
* Resource *
************/
-NetworkCm02Link::NetworkCm02Link(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy,
- kernel::lmm::System* system)
+NetworkCm02Link::NetworkCm02Link(const std::string& name, double bandwidth, kernel::lmm::System* system)
: LinkImpl(name)
{
bandwidth_.scale = 1.0;
bandwidth_.peak = bandwidth;
this->set_constraint(system->constraint_new(this, sg_bandwidth_factor * bandwidth));
-
- if (policy == s4u::Link::SharingPolicy::FATPIPE)
- get_constraint()->unshare();
}
void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value)
class NetworkCm02Model : public NetworkModel {
public:
explicit NetworkCm02Model(const std::string& name);
- LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy) override;
+ LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths) override;
+ LinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths) override;
void update_actions_state_lazy(double now, double delta) override;
void update_actions_state_full(double now, double delta) override;
Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
class NetworkCm02Link : public LinkImpl {
public:
- NetworkCm02Link(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy, lmm::System* system);
+ NetworkCm02Link(const std::string& name, double bandwidth, lmm::System* system);
void apply_event(kernel::profile::Event* event, double value) override;
void set_bandwidth(double value) override;
LinkImpl* set_latency(double value) override;
namespace kernel {
namespace resource {
-LinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::vector<double>& /*bandwidth*/,
- s4u::Link::SharingPolicy)
+LinkImpl* NetworkConstantModel::create_link(const std::string& name, const std::vector<double>& /*bandwidth*/)
{
xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
"Please remove any link from your platform (and switch to routing='None')",
return nullptr;
}
+LinkImpl* NetworkConstantModel::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
+{
+ return create_link(name, bandwidths);
+}
+
double NetworkConstantModel::next_occurring_event(double /*now*/)
{
double min = -1.0;
- for (kernel::resource::Action const& action : *get_started_action_set()) {
+ for (Action const& action : *get_started_action_set()) {
const auto& net_action = static_cast<const NetworkConstantAction&>(action);
if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min))
min = net_action.latency_;
action.latency_ = 0.0;
}
}
- action.update_remains(action.get_cost() * delta / action.initial_latency_);
+ action.update_remains(action.get_cost() * delta / sg_latency_factor);
action.update_max_duration(delta);
if ((action.get_remains_no_update() <= 0) ||
}
}
-Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double)
+Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double /*rate*/)
{
- auto* action = new NetworkConstantAction(this, *src, *dst, size, sg_latency_factor);
+ auto* action = new NetworkConstantAction(this, *src, *dst, size);
s4u::Link::on_communicate(*action);
return action;
/**********
* Action *
**********/
-NetworkConstantAction::NetworkConstantAction(NetworkConstantModel* model_, s4u::Host& src, s4u::Host& dst, double size,
- double latency)
- : NetworkAction(model_, src, dst, size, false), initial_latency_(latency)
+NetworkConstantAction::NetworkConstantAction(NetworkConstantModel* model_, s4u::Host& src, s4u::Host& dst, double size)
+ : NetworkAction(model_, src, dst, size, false)
{
- latency_ = latency;
+ latency_ = sg_latency_factor;
if (latency_ <= 0.0)
NetworkConstantAction::set_state(Action::State::FINISHED);
}
-NetworkConstantAction::~NetworkConstantAction() = default;
-
void NetworkConstantAction::update_remains_lazy(double /*now*/)
{
THROW_IMPOSSIBLE;
#ifndef NETWORK_CONSTANT_HPP_
#define NETWORK_CONSTANT_HPP_
-#include <xbt/base.h>
-
#include "network_interface.hpp"
namespace simgrid {
double next_occurring_event(double now) override;
void update_actions_state(double now, double delta) override;
- LinkImpl* create_link(const std::string& name, const std::vector<double>& bws,
- s4u::Link::SharingPolicy policy) override;
+ LinkImpl* create_link(const std::string& name, const std::vector<double>& bws) override;
+ LinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bws) override;
};
class NetworkConstantAction : public NetworkAction {
public:
- NetworkConstantAction(NetworkConstantModel* model_, s4u::Host& src, s4u::Host& dst, double size, double latency);
- ~NetworkConstantAction() override;
- double initial_latency_;
+ NetworkConstantAction(NetworkConstantModel* model_, s4u::Host& src, s4u::Host& dst, double size);
void update_remains_lazy(double now) override;
};
std::pair<IBNode*, IBNode*> pair = ibModel->active_comms[&action];
XBT_DEBUG("IB callback - action %p finished", &action);
- ibModel->updateIBfactors(&action, pair.first, pair.second, 1);
+ ibModel->update_IB_factors(&action, pair.first, pair.second, 1);
ibModel->active_comms.erase(&action);
}
auto* act_dst = &ibModel->active_nodes.at(action.get_dst().get_name());
ibModel->active_comms[&action] = std::make_pair(act_src, act_dst);
- ibModel->updateIBfactors(&action, act_src, act_dst, 0);
+ ibModel->update_IB_factors(&action, act_src, act_dst, 0);
}
/*********
"elements, semi-colon separated. Example: 0.965;0.925;1.35");
try {
- Be = std::stod(radical_elements.front());
+ Be_ = std::stod(radical_elements.front());
} catch (const std::invalid_argument& ia) {
throw std::invalid_argument(std::string("First part of smpi/IB-penalty-factors is not numerical:") + ia.what());
}
try {
- Bs = std::stod(radical_elements.at(1));
+ Bs_ = std::stod(radical_elements.at(1));
} catch (const std::invalid_argument& ia) {
throw std::invalid_argument(std::string("Second part of smpi/IB-penalty-factors is not numerical:") + ia.what());
}
try {
- ys = std::stod(radical_elements.back());
+ ys_ = std::stod(radical_elements.back());
} catch (const std::invalid_argument& ia) {
throw std::invalid_argument(std::string("Third part of smpi/IB-penalty-factors is not numerical:") + ia.what());
}
}
-void NetworkIBModel::computeIBfactors(IBNode* root) const
+void NetworkIBModel::compute_IB_factors(IBNode* root) const
{
- double num_comm_out = root->ActiveCommsUp.size();
+ double num_comm_out = root->active_comms_up_.size();
double max_penalty_out = 0.0;
// first, compute all outbound penalties to get their max
- for (ActiveComm const* comm : root->ActiveCommsUp) {
+ for (ActiveComm const* comm : root->active_comms_up_) {
double my_penalty_out = 1.0;
if (num_comm_out != 1) {
- if (comm->destination->nbActiveCommsDown > 2) // number of comms sent to the receiving node
- my_penalty_out = num_comm_out * Bs * ys;
+ if (comm->destination->nb_active_comms_down_ > 2) // number of comms sent to the receiving node
+ my_penalty_out = num_comm_out * Bs_ * ys_;
else
- my_penalty_out = num_comm_out * Bs;
+ my_penalty_out = num_comm_out * Bs_;
}
max_penalty_out = std::max(max_penalty_out, my_penalty_out);
}
- for (ActiveComm* comm : root->ActiveCommsUp) {
+ for (ActiveComm* comm : root->active_comms_up_) {
// compute inbound penalty
double my_penalty_in = 1.0;
- int nb_comms = comm->destination->nbActiveCommsDown; // total number of incoming comms
+ int nb_comms = comm->destination->nb_active_comms_down_; // total number of incoming comms
if (nb_comms != 1)
- my_penalty_in = (comm->destination->ActiveCommsDown)[root] // number of comm sent to dest by root node
- * Be * comm->destination->ActiveCommsDown.size(); // number of different nodes sending to dest
+ my_penalty_in = (comm->destination->active_comms_down_)[root] // number of comm sent to dest by root node
+ * Be_ * comm->destination->active_comms_down_.size(); // number of different nodes sending to dest
double penalty = std::max(my_penalty_in, max_penalty_out);
double penalized_bw = num_comm_out ? comm->init_rate / penalty : comm->init_rate;
if (not double_equals(penalized_bw, rate_before_update, sg_surf_precision)) {
- XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,
- comm->destination->id, comm->action, penalized_bw, comm->action->get_bound(), comm->init_rate);
+ XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id_,
+ comm->destination->id_, comm->action, penalized_bw, comm->action->get_bound(), comm->init_rate);
get_maxmin_system()->update_variable_bound(comm->action->get_variable(), penalized_bw);
} else {
- XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id, comm->destination->id,
+ XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id_, comm->destination->id_,
comm->action, penalized_bw, comm->init_rate);
}
}
XBT_DEBUG("Finished computing IB penalties");
}
-void NetworkIBModel::updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist) const
+void NetworkIBModel::update_IB_factors_rec(IBNode* root, std::vector<bool>& updatedlist) const
{
- if (not updatedlist[root->id]) {
- XBT_DEBUG("IB - Updating rec %d", root->id);
- computeIBfactors(root);
- updatedlist[root->id] = true;
- for (ActiveComm const* comm : root->ActiveCommsUp) {
- if (not updatedlist[comm->destination->id])
- updateIBfactors_rec(comm->destination, updatedlist);
+ if (not updatedlist[root->id_]) {
+ XBT_DEBUG("IB - Updating rec %d", root->id_);
+ compute_IB_factors(root);
+ updatedlist[root->id_] = true;
+ for (ActiveComm const* comm : root->active_comms_up_) {
+ if (not updatedlist[comm->destination->id_])
+ update_IB_factors_rec(comm->destination, updatedlist);
}
- for (std::map<IBNode*, int>::value_type const& comm : root->ActiveCommsDown) {
- if (not updatedlist[comm.first->id])
- updateIBfactors_rec(comm.first, updatedlist);
+ for (std::map<IBNode*, int>::value_type const& comm : root->active_comms_down_) {
+ if (not updatedlist[comm.first->id_])
+ update_IB_factors_rec(comm.first, updatedlist);
}
}
}
-void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode* to, int remove) const
+void NetworkIBModel::update_IB_factors(NetworkAction* action, IBNode* from, IBNode* to, int remove) const
{
if (from == to) // disregard local comms (should use loopback)
return;
if (remove) {
- if (to->ActiveCommsDown[from] == 1)
- to->ActiveCommsDown.erase(from);
+ if (to->active_comms_down_[from] == 1)
+ to->active_comms_down_.erase(from);
else
- to->ActiveCommsDown[from] -= 1;
+ to->active_comms_down_[from] -= 1;
- to->nbActiveCommsDown--;
- auto it = std::find_if(begin(from->ActiveCommsUp), end(from->ActiveCommsUp),
+ to->nb_active_comms_down_--;
+ auto it = std::find_if(begin(from->active_comms_up_), end(from->active_comms_up_),
[action](const ActiveComm* comm) { return comm->action == action; });
- if (it != std::end(from->ActiveCommsUp)) {
+ if (it != std::end(from->active_comms_up_)) {
delete *it;
- from->ActiveCommsUp.erase(it);
+ from->active_comms_up_.erase(it);
}
action->unref();
} else {
auto* comm = new ActiveComm();
comm->action = action;
comm->destination = to;
- from->ActiveCommsUp.push_back(comm);
+ from->active_comms_up_.push_back(comm);
- to->ActiveCommsDown[from] += 1;
- to->nbActiveCommsDown++;
+ to->active_comms_down_[from] += 1;
+ to->nb_active_comms_down_++;
}
- XBT_DEBUG("IB - Updating %d", from->id);
+ XBT_DEBUG("IB - Updating %d", from->id_);
std::vector<bool> updated(active_nodes.size(), false);
- updateIBfactors_rec(from, updated);
- XBT_DEBUG("IB - Finished updating %d", from->id);
+ update_IB_factors_rec(from, updated);
+ XBT_DEBUG("IB - Finished updating %d", from->id_);
}
} // namespace resource
} // namespace kernel
class IBNode {
public:
- int id;
+ int id_;
// store related links, to ease computation of the penalties
- std::vector<ActiveComm*> ActiveCommsUp;
+ std::vector<ActiveComm*> active_comms_up_;
// store the number of comms received from each node
- std::map<IBNode*, int> ActiveCommsDown;
+ std::map<IBNode*, int> active_comms_down_;
// number of comms the node is receiving
- int nbActiveCommsDown = 0;
- explicit IBNode(int id) : id(id){};
+ int nb_active_comms_down_ = 0;
+ explicit IBNode(int id) : id_(id){};
};
class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
- double Bs;
- double Be;
- double ys;
- void updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist) const;
- void computeIBfactors(IBNode* root) const;
+ double Bs_;
+ double Be_;
+ double ys_;
+ void update_IB_factors_rec(IBNode* root, std::vector<bool>& updatedlist) const;
+ void compute_IB_factors(IBNode* root) const;
public:
explicit NetworkIBModel(const std::string& name);
NetworkIBModel(const NetworkIBModel&) = delete;
NetworkIBModel& operator=(const NetworkIBModel&) = delete;
- void updateIBfactors(NetworkAction* action, IBNode* from, IBNode* to, int remove) const;
+ void update_IB_factors(NetworkAction* action, IBNode* from, IBNode* to, int remove) const;
std::unordered_map<std::string, IBNode> active_nodes;
std::unordered_map<NetworkAction*, std::pair<IBNode*, IBNode*>> active_comms;
return bandwidth_.peak * bandwidth_.scale;
}
+LinkImpl* LinkImpl::set_sharing_policy(s4u::Link::SharingPolicy policy)
+{
+ get_constraint()->set_sharing_policy(policy);
+ return this;
+}
s4u::Link::SharingPolicy LinkImpl::get_sharing_policy() const
{
return get_constraint()->get_sharing_policy();
* @param bandwidth The initial bandwidth of the Link in bytes per second
* @param policy The sharing policy of the Link
*/
- virtual LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy) = 0;
+ virtual LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths) = 0;
+
+ virtual LinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths) = 0;
/**
* @brief Create a communication between two hosts.
virtual LinkImpl* set_latency(double value) = 0;
/** @brief The sharing policy */
+ virtual LinkImpl* set_sharing_policy(s4u::Link::SharingPolicy policy);
virtual s4u::Link::SharingPolicy get_sharing_policy() const;
/** @brief Check if the Link is used */
int mcs_value = mcs ? atoi(mcs) : 3;
int nss_value = nss ? atoi(nss) : 1;
#if NS3_MINOR_VERSION < 30
- if (nss_value != 1 + (mcs_value / 8))
- xbt_die("On NS3 < 3.30, NSS value has to satisfy NSS == 1+(MCS/8) constraint. Bailing out");
+ xbt_assert(nss_value == 1 + (mcs_value / 8),
+ "On NS3 < 3.30, NSS value has to satisfy NSS == 1+(MCS/8) constraint. Bailing out");
#endif
wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "ControlMode", ns3::StringValue("HtMcs0"), "DataMode",
ns3::StringValue("HtMcs" + std::to_string(mcs_value)));
s4u::NetZone::on_seal.connect(&zoneCreation_cb);
}
-LinkImpl* NetworkNS3Model::create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy)
+LinkImpl* NetworkNS3Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
xbt_assert(bandwidths.size() == 1, "ns-3 links must use only 1 bandwidth.");
- auto link = new LinkNS3(name, bandwidths[0], policy);
- link->set_model(this);
- return link;
+ return (new LinkNS3(name, bandwidths[0]))->set_model(this);
+}
+
+LinkImpl* NetworkNS3Model::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
+{
+ return create_link(name, bandwidths)->set_sharing_policy(s4u::Link::SharingPolicy::WIFI);
}
Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
* Resource *
************/
-LinkNS3::LinkNS3(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy)
- : LinkImpl(name), sharing_policy_(policy)
+LinkNS3::LinkNS3(const std::string& name, double bandwidth) : LinkImpl(name)
{
bandwidth_.peak = bandwidth;
}
latency_.peak = latency;
return this;
}
+
+LinkImpl* LinkNS3::set_sharing_policy(s4u::Link::SharingPolicy policy)
+{
+ sharing_policy_ = policy;
+ return this;
+}
/**********
* Action *
**********/
xbt_assert(host_src != nullptr, "Network element %s does not seem to be ns-3-ready", src->get_cname());
xbt_assert(host_dst != nullptr, "Network element %s does not seem to be ns-3-ready", dst->get_cname());
- if (policy == simgrid::s4u::Link::SharingPolicy::WIFI) {
- xbt_die("The wifi sharing policy is not supported for links. You want to use a wifi zone (see documentation).");
- } else {
- ns3::PointToPointHelper pointToPoint;
+ xbt_assert(policy != simgrid::s4u::Link::SharingPolicy::WIFI,
+ "The wifi sharing policy is not supported for links. You want to use a wifi zone (see documentation).");
- XBT_DEBUG("\tAdd PTP from %s to %s bw:'%f Bps' lat:'%fs'", src->get_cname(), dst->get_cname(), bw, lat);
- pointToPoint.SetDeviceAttribute("DataRate",
- ns3::DataRateValue(ns3::DataRate(bw * 8))); // ns-3 takes bps, but we provide Bps
- pointToPoint.SetChannelAttribute("Delay", ns3::TimeValue(ns3::Seconds(lat)));
+ ns3::PointToPointHelper pointToPoint;
- netA.Add(pointToPoint.Install(host_src->ns3_node_, host_dst->ns3_node_));
+ XBT_DEBUG("\tAdd PTP from %s to %s bw:'%f Bps' lat:'%fs'", src->get_cname(), dst->get_cname(), bw, lat);
+ pointToPoint.SetDeviceAttribute("DataRate",
+ ns3::DataRateValue(ns3::DataRate(bw * 8))); // ns-3 takes bps, but we provide Bps
+ pointToPoint.SetChannelAttribute("Delay", ns3::TimeValue(ns3::Seconds(lat)));
- std::string addr = simgrid::xbt::string_printf("%d.%d.0.0", number_of_networks, number_of_links);
- address.SetBase(addr.c_str(), "255.255.0.0");
- XBT_DEBUG("\tInterface stack '%s'", addr.c_str());
+ netA.Add(pointToPoint.Install(host_src->ns3_node_, host_dst->ns3_node_));
+
+ std::string addr = simgrid::xbt::string_printf("%d.%d.0.0", number_of_networks, number_of_links);
+ address.SetBase(addr.c_str(), "255.255.0.0");
+ XBT_DEBUG("\tInterface stack '%s'", addr.c_str());
- auto addresses = address.Assign(netA);
+ auto addresses = address.Assign(netA);
- host_src->ipv4_address_ = transformIpv4Address(addresses.GetAddress(0));
- host_dst->ipv4_address_ = transformIpv4Address(addresses.GetAddress(1));
+ host_src->ipv4_address_ = transformIpv4Address(addresses.GetAddress(0));
+ host_dst->ipv4_address_ = transformIpv4Address(addresses.GetAddress(1));
- if (number_of_links == 255) {
- xbt_assert(number_of_networks < 255, "Number of links and networks exceed 255*255");
- number_of_links = 1;
- number_of_networks++;
- } else {
- number_of_links++;
- }
+ if (number_of_links == 255) {
+ xbt_assert(number_of_networks < 255, "Number of links and networks exceed 255*255");
+ number_of_links = 1;
+ number_of_networks++;
+ } else {
+ number_of_links++;
}
}
class NetworkNS3Model : public NetworkModel {
public:
explicit NetworkNS3Model(const std::string& name);
- LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidth,
- s4u::Link::SharingPolicy policy) override;
+ LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidth) override;
+ LinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidth) override;
Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
double next_occurring_event(double now) override;
bool next_occurring_event_is_idempotent() override { return false; }
************/
class LinkNS3 : public LinkImpl {
public:
- explicit LinkNS3(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy);
+ explicit LinkNS3(const std::string& name, double bandwidth);
~LinkNS3() override;
- s4u::Link::SharingPolicy sharing_policy_;
+ s4u::Link::SharingPolicy sharing_policy_ = s4u::Link::SharingPolicy::SHARED;
void apply_event(profile::Event* event, double value) override;
void set_bandwidth(double) override { THROW_UNIMPLEMENTED; }
LinkImpl* set_latency(double) override;
LinkImpl* set_bandwidth_profile(profile::Profile* profile) override;
LinkImpl* set_latency_profile(profile::Profile* profile) override;
+ LinkImpl* set_sharing_policy(s4u::Link::SharingPolicy policy) override;
s4u::Link::SharingPolicy get_sharing_policy() const override { return sharing_policy_; }
};
{
static std::vector<s_smpi_factor_t> smpi_bw_factor;
if (smpi_bw_factor.empty())
- smpi_bw_factor = simgrid::smpi::utils::parse_factor(config::get_value<std::string>("smpi/bw-factor"));
+ smpi_bw_factor = smpi::utils::parse_factor(config::get_value<std::string>("smpi/bw-factor"));
double current = 1.0;
for (auto const& fact : smpi_bw_factor) {
{
static std::vector<s_smpi_factor_t> smpi_lat_factor;
if (smpi_lat_factor.empty())
- smpi_lat_factor = simgrid::smpi::utils::parse_factor(config::get_value<std::string>("smpi/lat-factor"));
+ smpi_lat_factor = smpi::utils::parse_factor(config::get_value<std::string>("smpi/lat-factor"));
double current = 1.0;
for (auto const& fact : smpi_lat_factor) {
: NetworkModel(name), hostModel_(hmodel)
{
set_maxmin_system(sys);
- loopback_ = NetworkL07Model::create_link(
- "__loopback__", std::vector<double>{simgrid::config::get_value<double>("network/loopback-bw")},
- s4u::Link::SharingPolicy::FATPIPE)
- ->set_latency(simgrid::config::get_value<double>("network/loopback-lat"));
+ loopback_ =
+ create_link("__loopback__", std::vector<double>{simgrid::config::get_value<double>("network/loopback-bw")})
+ ->set_sharing_policy(s4u::Link::SharingPolicy::FATPIPE)
+ ->set_latency(simgrid::config::get_value<double>("network/loopback-lat"));
loopback_->seal();
}
return (new CpuL07(host, speed_per_pstate))->set_model(this);
}
-kernel::resource::LinkImpl* NetworkL07Model::create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy)
+kernel::resource::LinkImpl* NetworkL07Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
xbt_assert(bandwidths.size() == 1, "Non WIFI link must have only 1 bandwidth.");
- auto link = new LinkL07(name, bandwidths[0], policy, get_maxmin_system());
- link->set_model(this);
- return link;
+ return (new LinkL07(name, bandwidths[0], get_maxmin_system()))->set_model(this);
+}
+
+kernel::resource::LinkImpl* NetworkL07Model::create_wifi_link(const std::string& name,
+ const std::vector<double>& bandwidths)
+{
+ THROW_UNIMPLEMENTED;
}
/************
Cpu::on_speed_change();
}
-LinkL07::LinkL07(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy,
- kernel::lmm::System* system)
- : LinkImpl(name)
+LinkL07::LinkL07(const std::string& name, double bandwidth, kernel::lmm::System* system) : LinkImpl(name)
{
this->set_constraint(system->constraint_new(this, bandwidth));
bandwidth_.peak = bandwidth;
-
- if (policy == s4u::Link::SharingPolicy::FATPIPE)
- get_constraint()->unshare();
}
bool LinkL07::is_used() const
NetworkL07Model(const NetworkL07Model&) = delete;
NetworkL07Model& operator=(const NetworkL07Model&) = delete;
~NetworkL07Model() override;
- kernel::resource::LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths,
- s4u::Link::SharingPolicy policy) override;
+ kernel::resource::LinkImpl* create_link(const std::string& name, const std::vector<double>& bandwidths) override;
+ kernel::resource::LinkImpl* create_wifi_link(const std::string& name, const std::vector<double>& bandwidths) override;
kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
void update_actions_state(double /*now*/, double /*delta*/) override{
class LinkL07 : public kernel::resource::LinkImpl {
public:
- LinkL07(const std::string& name, double bandwidth, s4u::Link::SharingPolicy policy, kernel::lmm::System* system);
+ LinkL07(const std::string& name, double bandwidth, kernel::lmm::System* system);
LinkL07(const LinkL07&) = delete;
LinkL07& operator=(const LinkL07&) = delete;
~LinkL07() override;
static void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* args, const std::string& link_name)
{
- simgrid::s4u::Link* link = routing_get_current()->create_link(link_name, args->bandwidths, args->policy);
+ simgrid::s4u::Link* link = routing_get_current()->create_link(link_name, args->bandwidths);
if (args->properties)
link->set_properties(*args->properties);
link->get_impl() // this call to get_impl saves some simcalls but can be removed
+ ->set_sharing_policy(args->policy)
->set_state_profile(args->state_trace)
->set_latency_profile(args->latency_trace)
->set_bandwidth_profile(args->bandwidth_trace)
if (pos != table.end())
return static_cast<int>(std::distance(table.begin(), pos));
- if (table.empty())
- xbt_die("No model is valid! This is a bug.");
+ xbt_assert(not table.empty(), "No model is valid! This is a bug.");
std::string sep;
std::string name_list;
luaL_loadfile(L, cfile); // This loads the file without executing it.
/* Run the script */
- if (lua_pcall(L, 0, 0, 0)) {
- XBT_ERROR("FATAL ERROR:\n %s: %s\n\n", "Lua call failed. Error message:", lua_tostring(L, -1));
- xbt_die("Lua call failed. See Log");
- }
+ xbt_assert(lua_pcall(L, 0, 0, 0) == 0, "FATAL ERROR:\n %s: %s\n\n", "Lua call failed. Error message:",
+ lua_tostring(L, -1));
lua_close(L);
return;
#else
{
parsed_automaton = a;
yyin = fopen(file, "r");
- if (yyin == NULL)
- xbt_die("Failed to open automaton file `%s': %s", file, strerror(errno));
+ xbt_assert(yyin != NULL, "Failed to open automaton file `%s': %s", file, strerror(errno));
yyparse();
fclose(yyin);
}
double res = std::strtod(value, &end);
if (errno == ERANGE)
throw std::range_error("out of range");
- else if (errno)
- xbt_die("Unexpected errno");
+ xbt_assert(errno == 0, "Unexpected errno: %d", errno);
if (end == value || *end != '\0')
throw std::range_error("invalid double");
- else
- return res;
+ return res;
}
long int parse_long(const char* value)
char* end;
errno = 0;
long int res = std::strtol(value, &end, 0);
- if (errno) {
- if (res == LONG_MIN && errno == ERANGE)
- throw std::range_error("underflow");
- else if (res == LONG_MAX && errno == ERANGE)
- throw std::range_error("overflow");
- xbt_die("Unexpected errno");
- }
+ if (errno == ERANGE)
+ throw std::range_error(res == LONG_MIN ? "underflow" : "overflow");
+ xbt_assert(errno == 0, "Unexpected errno: %d", errno);
if (end == value || *end != '\0')
throw std::range_error("invalid integer");
- else
- return res;
+ return res;
}
// ***** ConfigType *****
va_copy(ap2, ap);
int size = std::vsnprintf(nullptr, 0, fmt, ap2);
va_end(ap2);
- if (size < 0)
- xbt_die("string_vprintf error");
+ xbt_assert(size >= 0, "string_vprintf error");
// Allocate the string and format:
std::string res;
res.resize(size);
- if (size != 0 && std::vsnprintf(&res[0], size + 1, fmt, ap) != size)
- xbt_die("string_vprintf error");
+ if (size != 0)
+ xbt_assert(std::vsnprintf(&res[0], size + 1, fmt, ap) == size, "string_vprintf error");
return res;
}
res->do_append = &append_file;
res->free_ = &free_;
res->data = static_cast<void*>(fopen(arg, "w"));
- if (res->data == nullptr)
- xbt_die("Cannot open file: %s: %s", arg, strerror(errno));
+ xbt_assert(res->data != nullptr, "Cannot open file: %s: %s", arg, strerror(errno));
return res;
}
//Roll
if (!data->file) {
data->file= fopen(data->filename, "w");
- if (data->file == nullptr)
- xbt_die("Cannot open file: %s: %s", data->filename, strerror(errno));
+ xbt_assert(data->file != nullptr, "Cannot open file: %s: %s", data->filename, strerror(errno));
} else {
fputs(APPEND2_END_TOKEN_CLEAR,data->file);
fseek(data->file,0,SEEK_SET);
std::string newname = pre + std::to_string(data->count) + post;
data->count++;
data->file = fopen(newname.c_str(), "w");
- if (data->file == nullptr)
- xbt_die("Cannot open file: %s: %s", newname.c_str(), strerror(errno));
+ xbt_assert(data->file != nullptr, "Cannot open file: %s: %s", newname.c_str(), strerror(errno));
xbt_free(pre);
}
}
{
while (1) {
msg_task_t task = NULL;
- XBT_ATTRIB_UNUSED int res = MSG_task_receive(&(task), "worker_mailbox");
- xbt_assert(res == MSG_OK, "MSG_task_get failed");
+ xbt_assert(MSG_task_receive(&(task), "worker_mailbox") == MSG_OK, "MSG_task_receive failed");
XBT_INFO("Handling task \"%s\"", MSG_task_get_name(task));
if (!strcmp(MSG_task_get_name(task), "finalize")) {
static void host()
{
- simgrid::s4u::Disk* disk = simgrid::s4u::this_actor::get_host()->get_disks().front(); // Disk1
- aid_t id = simgrid::s4u::this_actor::get_pid();
+ const simgrid::s4u::Disk* disk = simgrid::s4u::this_actor::get_host()->get_disks().front(); // Disk1
+ aid_t id = simgrid::s4u::this_actor::get_pid();
XBT_INFO("process %ld is writing!", id);
disk->write(4000000);
XBT_INFO("process %ld goes to sleep for %ld seconds", id, id);
sg4::Engine e(&argc, argv);
- if (not parse_cmdline(&timings, &platformFile, argc, argv) || not platformFile)
- xbt_die("Invalid command line arguments: expected [--timings] platformFile");
+ xbt_assert(parse_cmdline(&timings, &platformFile, argc, argv) && platformFile,
+ "Invalid command line arguments: expected [--timings] platformFile");
XBT_DEBUG("%d,%s", timings, platformFile);
> [rank 14] -> Ginette
> [rank 15] -> Ginette
> If this is too much, consider sharing allocations for computation buffers.
-> Largest allocation at once from a single process was 64 bytes, at sysdep.h:61. It was called 32 times during the whole simulation.
+> Largest allocation at once from a single process was 64 bytes, at sysdep.h:59. It was called 32 times during the whole simulation.
> Running smpirun with -wrapper "valgrind --leak-check=full" can provide more information
> This can be done automatically by setting --cfg=smpi/auto-shared-malloc-thresh to the minimum size wanted size (this can alter execution if data content is necessary)
-> [0.023768] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 31 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
+> [0.023768] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 32 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
> [0.023768] [smpi_utils/INFO] Memory Usage: Simulated application allocated 2048 bytes during its lifetime through malloc/calloc calls.
> [rank 1] -> Tremblay
> [rank 2] -> Tremblay
> [rank 3] -> Tremblay
+> [0.000000] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 8 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
+> Running smpirun with -wrapper "valgrind --leak-check=full" can provide more information
+> [0.000000] [smpi_utils/INFO] Memory Usage: Simulated application allocated 128 bytes during its lifetime through malloc/calloc calls.
+> Largest allocation at once from a single process was 16 bytes, at sysdep.h:59. It was called 8 times during the whole simulation.
+> If this is too much, consider sharing allocations for computation buffers.
+> This can be done automatically by setting --cfg=smpi/auto-shared-malloc-thresh to the minimum size wanted size (this can alter execution if data content is necessary)
+>
+> [0.000000] [smpi_utils/INFO] Probable memory leaks in your code: SMPI detected 8 unfreed MPI handles : display types and addresses (n max) with --cfg=smpi/list-leaks:n.
+> Running smpirun with -wrapper "valgrind --leak-check=full" can provide more information
+> [0.000000] [smpi_utils/INFO] Memory Usage: Simulated application allocated 128 bytes during its lifetime through malloc/calloc calls.
+> Largest allocation at once from a single process was 16 bytes, at sysdep.h:59. It was called 8 times during the whole simulation.
+> If this is too much, consider sharing allocations for computation buffers.
+> This can be done automatically by setting --cfg=smpi/auto-shared-malloc-thresh to the minimum size wanted size (this can alter execution if data content is necessary)
+>
> [0.000000] [mc_safety/INFO] Check a safety property. Reduction is: dpor.
> [0.000000] [mc_safety/INFO] Executed transitions = 484
> [0.000000] [mc_safety/INFO] Expanded states = 63
#include <stdio.h>
#include "mpi.h"
#include "mpitest.h"
-
+#define USE_STRICT_MPI
int key = MPI_KEYVAL_INVALID;
char a[100];
-/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
- * (C) 2013 by Argonne National Laboratory.
- * See COPYRIGHT in top-level directory.
+ * Copyright (C) by Argonne National Laboratory
+ * See COPYRIGHT in top-level directory
*/
+
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <mpi.h>
+#include "mpitest.h"
#define MAX_DATA_SIZE (1024)
#define MAX_NUM_ITERATIONS (1024)
static void run_test(int lock_mode, int lock_assert)
{
int nproc, test_iter, target_rank, data_size;
- char *buf, *win_buf;
+ int *buf, *win_buf;
MPI_Win win;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
printf("Synchronization mode: ");
switch (lock_mode) {
- case MPI_LOCK_EXCLUSIVE:
- printf("Exclusive lock");
- break;
- case MPI_LOCK_SHARED:
- printf("Shared lock");
- break;
- default:
- printf("Unknown lock");
- break;
+ case MPI_LOCK_EXCLUSIVE:
+ printf("Exclusive lock");
+ break;
+ case MPI_LOCK_SHARED:
+ printf("Shared lock");
+ break;
+ default:
+ printf("Unknown lock");
+ break;
}
if (lock_assert & MPI_MODE_NOCHECK)
t_acc = MPI_Wtime();
MPI_Win_lock(lock_mode, target_rank, lock_assert, win);
- MPI_Accumulate(buf, data_size, MPI_BYTE, target_rank,
- 0, data_size, MPI_BYTE, MPI_SUM, win);
+ MPI_Accumulate(buf, data_size / sizeof(int), MPI_INT, target_rank,
+ 0, data_size / sizeof(int), MPI_INT, MPI_BXOR, win);
MPI_Win_unlock(target_rank, win);
}
t_acc = (MPI_Wtime() - t_acc) / num_iter;
int main(int argc, char **argv)
{
- MPI_Init(&argc, &argv);
+ MTest_Init(&argc, &argv);
run_test(MPI_LOCK_EXCLUSIVE, 0);
run_test(MPI_LOCK_EXCLUSIVE, MPI_MODE_NOCHECK);
run_test(MPI_LOCK_SHARED, 0);
run_test(MPI_LOCK_SHARED, MPI_MODE_NOCHECK);
- MPI_Finalize();
-
- if (rank == 0)
- printf(" No Errors\n");
+ MTest_Finalize(0);
return 0;
}
static void check_block(const unsigned char* p, unsigned char b, int n)
{
for (int i = 0; i < n; i++)
- if (p[i] != b)
- xbt_die("value mismatch: %p[%d] = %#hhx, expected %#hhx", p, i, p[i], b);
+ xbt_assert(p[i] == b, "value mismatch: %p[%d] = %#hhx, expected %#hhx", p, i, p[i], b);
}
int main(int argc, char**argv)
} catch (const simgrid::Exception&) {
gotit = true;
}
- if (not gotit)
- xbt_die("FAIL: A double-free went undetected (for size:%d)",size_of_block(i));
+ xbt_assert(gotit, "FAIL: A double-free went undetected (for size:%d)", size_of_block(i));
}
XBT_INFO("free again all blocks (to really check that double free are correctly caught)");
} catch (const simgrid::Exception&) {
gotit = true;
}
- if (not gotit)
- xbt_die("FAIL: A double-free went undetected (for size:%d)",size_of_block(i));
+ xbt_assert(gotit, "FAIL: A double-free went undetected (for size:%d)", size_of_block(i));
}
XBT_INFO("Let's try different codepaths for mrealloc");
# - Clone simgrid-template-s4u, as it is needed by the tutorial
# - Add an empty makefile advising to run cmake before make, just in case
-RUN apt install -y pajeng r-base r-cran-ggplot2 r-cran-dplyr r-cran-devtools cmake g++ git libboost-all-dev flex bison libfmt-dev&& \
+RUN apt install -y pajeng r-base r-cran-ggplot2 r-cran-dplyr r-cran-devtools cmake g++ git libboost-dev flex bison libfmt-dev&& \
cd /source && \
git clone --depth=1 https://framagit.org/simgrid/simgrid-template-s4u.git simgrid-template-s4u.git && \
printf "master-workers ping-pong:\n\t@echo \"Please run the following command before make:\";echo \" cmake .\"; exit 1" > Makefile &&\
chown -R user:user /home/user
# - Clone simgrid-template-smpi, as it is needed by the tutorial
-RUN apt install -y python3 pajeng libssl-dev r-base r-cran-ggplot2 r-cran-dplyr r-cran-devtools build-essential g++ gfortran git libboost-all-dev cmake flex bison libfmt-dev && \
+RUN apt install -y python3 pajeng libssl-dev r-base r-cran-ggplot2 r-cran-dplyr r-cran-devtools build-essential g++ gfortran git libboost-dev cmake flex bison libfmt-dev && \
cd /source && \
git clone --depth=1 https://framagit.org/simgrid/simgrid-template-smpi.git simgrid-template-smpi.git && \
chown -R user:user /source && \