#include "src/kernel/context/ContextSwapped.hpp"
+#include <memory>
+
#ifdef _WIN32
#include <malloc.h>
#include <windows.h>
if (SIMIX_context_is_parallel()) {
// We lazily create the parmap so that all options are actually processed when doing so.
if (parmap_ == nullptr)
- parmap_.reset(
- new simgrid::xbt::Parmap<smx_actor_t>(SIMIX_context_get_nthreads(), SIMIX_context_get_parallel_mode()));
+ parmap_ = std::make_unique<simgrid::xbt::Parmap<smx_actor_t>>(SIMIX_context_get_nthreads(),
+ SIMIX_context_get_parallel_mode());
// Usually, Parmap::apply() executes the provided function on all elements of the array.
// Here, the executed function does not return the control to the parmap before all the array is processed:
#include "xbt/log.h"
#include "xbt/system_error.hpp"
+#include <memory>
+
#include <fcntl.h>
#ifdef __linux__
#include <sys/prctl.h>
xbt_assert(mc_model_checker == nullptr, "Did you manage to start the MC twice in this process?");
auto process = std::make_unique<simgrid::mc::RemoteSimulation>(pid);
- model_checker_.reset(new simgrid::mc::ModelChecker(std::move(process), sockets[1]));
+ model_checker_ = std::make_unique<simgrid::mc::ModelChecker>(std::move(process), sockets[1]);
mc_model_checker = model_checker_.get();
model_checker_->start();
#include <cerrno>
#include <cstdlib>
#include <cstring>
+#include <memory>
#include <sys/ptrace.h>
#include <sys/socket.h>
#include <sys/types.h>
xbt_assert(type == SOCK_SEQPACKET, "Unexpected socket type %i", type);
XBT_DEBUG("Model-checked application found expected socket type");
- instance_.reset(new simgrid::mc::AppSide(fd));
+ instance_ = std::make_unique<simgrid::mc::AppSide>(fd);
// Wait for the model-checker:
errno = 0;
#include <libunwind-ptrace.h>
#include <sys/mman.h> // PROT_*
+#include <memory>
+
using simgrid::mc::remote;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc, "MC process information");
{
// Read/dereference/refresh the std_heap pointer:
if (not this->heap)
- this->heap.reset(new s_xbt_mheap_t());
+ this->heap = std::make_unique<s_xbt_mheap_t>();
this->read_bytes(this->heap.get(), sizeof(mdesc), remote(this->heap_address));
this->cache_flags_ |= RemoteSimulation::cache_heap;
}
void helper_tests::Init()
{
pagesize = (size_t)getpagesize();
- store.reset(new simgrid::mc::PageStore(50));
+ store = std::make_unique<simgrid::mc::PageStore>(50);
data = mmap(nullptr, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
REQUIRE(store->size() == 0);
}
#include "src/mc/sosp/Snapshot.hpp"
#include <cstddef>
+#include <memory>
#include <sys/mman.h>
#include <xbt/random.hpp>
REQUIRE(xbt_pagesize == getpagesize());
REQUIRE(1 << xbt_pagebits == xbt_pagesize);
- process.reset(new simgrid::mc::RemoteSimulation(getpid()));
+ process = std::make_unique<simgrid::mc::RemoteSimulation>(getpid());
process->init();
mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process), -1);
}
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/split.hpp>
#include <fstream>
+#include <memory>
#include <numeric>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_file, s4u, "S4U files");
// assign a file descriptor id to the newly opened File
FileDescriptorHostExt* ext = host->extension<simgrid::s4u::FileDescriptorHostExt>();
if (ext->file_descriptor_table == nullptr) {
- ext->file_descriptor_table.reset(new std::vector<int>(sg_storage_max_file_descriptors));
+ ext->file_descriptor_table = std::make_unique<std::vector<int>>(sg_storage_max_file_descriptors);
std::iota(ext->file_descriptor_table->rbegin(), ext->file_descriptor_table->rend(), 0); // Fill with ..., 1, 0.
}
xbt_assert(not ext->file_descriptor_table->empty(), "Too much files are opened! Some have to be closed.");
#include "src/mc/remote/AppSide.hpp"
#endif
+#include <memory>
XBT_LOG_NEW_CATEGORY(simix, "All SIMIX categories");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_kernel, simix, "Logging specific to SIMIX (kernel)");
if (simix_global == nullptr) {
surf_init(argc, argv); /* Initialize SURF structures */
- simix_global.reset(new simgrid::simix::Global());
+ simix_global = std::make_unique<simgrid::simix::Global>();
simix_global->maestro_ = nullptr;
SIMIX_context_mod_init();
#include "smpi_op.hpp"
#include "src/smpi/include/smpi_actor.hpp"
+#include <memory>
+
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
static const void* smpi_get_in_place_buf(const void* inplacebuf, const void* otherbuf,std::unique_ptr<unsigned char[]>& tmp_sendbuf, int count, MPI_Datatype datatype){
if (inplacebuf == MPI_IN_PLACE) {
- tmp_sendbuf.reset(new unsigned char[count * datatype->get_extent()]);
- simgrid::smpi::Datatype::copy(otherbuf, count, datatype, tmp_sendbuf.get(), count, datatype);
+ tmp_sendbuf = std::make_unique<unsigned char[]>(count * datatype->get_extent());
+ simgrid::smpi::Datatype::copy(otherbuf, count, datatype, tmp_sendbuf.get(), count, datatype);
return tmp_sendbuf.get();
}else{
return inplacebuf;
std::unique_ptr<int[]> tmp_senddispls;
const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, maxsize, MPI_CHAR);
if (sendbuf == MPI_IN_PLACE) {
- tmp_sendcounts.reset(new int[size]);
+ tmp_sendcounts = std::make_unique<int[]>(size);
std::copy(recvcounts, recvcounts + size, tmp_sendcounts.get());
real_sendcounts = tmp_sendcounts.get();
- tmp_senddispls.reset(new int[size]);
+ tmp_senddispls = std::make_unique<int[]>(size);
std::copy(recvdispls, recvdispls + size, tmp_senddispls.get());
real_senddispls = tmp_senddispls.get();
real_sendtype = recvtype;
std::unique_ptr<MPI_Datatype[]> tmp_sendtypes;
const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, maxsize, MPI_CHAR);
if (sendbuf == MPI_IN_PLACE) {
- tmp_sendcounts.reset(new int[size]);
+ tmp_sendcounts = std::make_unique<int[]>(size);
std::copy(recvcounts, recvcounts + size, tmp_sendcounts.get());
real_sendcounts = tmp_sendcounts.get();
- tmp_senddispls.reset(new int[size]);
+ tmp_senddispls = std::make_unique<int[]>(size);
std::copy(recvdispls, recvdispls + size, tmp_senddispls.get());
real_senddispls = tmp_senddispls.get();
- tmp_sendtypes.reset(new MPI_Datatype[size]);
+ tmp_sendtypes = std::make_unique<MPI_Datatype[]>(size);
std::copy(recvtypes, recvtypes + size, tmp_sendtypes.get());
real_sendtypes = tmp_sendtypes.get();
}
#include "colls_private.hpp"
+#include <memory>
+
/* This is the default implementation of allreduce. The algorithm is:
Algorithm: MPI_Allreduce
{
std::unique_ptr<unsigned char[]> tmp_buf;
if(comm->rank()!=root){
- tmp_buf.reset(new unsigned char[rcount * rdtype->get_extent()]);
+ tmp_buf = std::make_unique<unsigned char[]>(rcount * rdtype->get_extent());
sbuf = tmp_buf.get();
scount = rcount;
sdtype = rdtype;
#include "colls_private.hpp"
+#include <memory>
+
namespace simgrid {
namespace smpi {
(block_size < small_block_size)) {
std::unique_ptr<unsigned char[]> tmp_buf;
if (rank != root) {
- tmp_buf.reset(new unsigned char[rcount * rdtype->get_extent()]);
+ tmp_buf = std::make_unique<unsigned char[]>(rcount * rdtype->get_extent());
sbuf = tmp_buf.get();
scount = rcount;
sdtype = rdtype;
#include "surf/surf.hpp"
#include <algorithm>
+#include <memory>
constexpr double EPSILON = 0.000000001;
for (auto const& val : speed_profile->event_list)
total_time += val.date_;
- profile_.reset(new CpuTiProfile(speed_profile));
+ profile_ = std::make_unique<CpuTiProfile>(speed_profile);
last_time_ = total_time;
total_ = profile_->integrate_simple(0, total_time);
#include <xbt/PropertyHolder.hpp>
#include <map>
+#include <memory>
namespace simgrid {
namespace xbt {
void PropertyHolder::set_property(const std::string& key, const std::string& value)
{
if (not properties_)
- properties_.reset(new std::unordered_map<std::string, std::string>);
+ properties_ = std::make_unique<std::unordered_map<std::string, std::string>>();
(*properties_)[key] = value;
}
const std::unordered_map<std::string, std::string>* PropertyHolder::get_properties()
{
if (not properties_)
- properties_.reset(new std::unordered_map<std::string, std::string>);
+ properties_ = std::make_unique<std::unordered_map<std::string, std::string>>();
return properties_.get();
}
template <class Assoc> void PropertyHolder::set_properties(const Assoc& properties)
{
if (not properties_)
- properties_.reset(new std::unordered_map<std::string, std::string>);
+ properties_ = std::make_unique<std::unordered_map<std::string, std::string>>();
std::unordered_map<std::string, std::string> props(properties.cbegin(), properties.cend());
#if __cplusplus >= 201703L
props.merge(properties_);
void set_implem_xbt()
{
- default_random.reset(new XbtRandom);
+ default_random = std::make_unique<XbtRandom>();
}
void set_implem_std()
{
- default_random.reset(new StdRandom);
+ default_random = std::make_unique<StdRandom>();
}
void set_mersenne_seed(int seed)