#include <cstdint>
#include <cstdlib>
+#include <array>
#include <stdexcept> // runtime_error
#include <utility>
#include <vector>
*/
class ExpressionStack {
public:
- using value_type = std::uintptr_t;
- static const std::size_t max_size = 64;
+ using value_type = std::uintptr_t;
+ static constexpr std::size_t MAX_SIZE = 64;
private:
// Values of the stack (the top is stack_[size_ - 1]):
- uintptr_t stack_[max_size]{0};
+ std::array<uintptr_t, MAX_SIZE> stack_{{0}};
size_t size_ = 0;
public:
/** Push a value on the top of the stack */
void push(value_type value)
{
- if (size_ == max_size)
+ if (size_ == stack_.size())
throw evaluation_error("DWARF stack overflow");
stack_[size_++] = value;
}
#include "src/include/catch.hpp"
+#include <array>
#include <cstdint>
#include <cstring>
#include <iostream>
static std::size_t pagesize;
static std::unique_ptr<PageStore> store;
static void* data;
- static size_t pageno[4];
+ static std::array<size_t, 4> pageno;
static int value;
// member functions used by the test suite(s)
std::size_t helper_tests::pagesize = 0;
std::unique_ptr<PageStore> helper_tests::store = nullptr;
void* helper_tests::data = nullptr;
-size_t helper_tests::pageno[4] = {0, 0, 0, 0};
+std::array<size_t, 4> helper_tests::pageno = {{0, 0, 0, 0}};
int helper_tests::value = 0;
void helper_tests::Init()
* \ | |
* ----
*/
-#include <map>
+#include <array>
#include <cstring>
+#include <map>
#include "private.hpp"
#include "xbt/config.hpp"
return smpi_shared_malloc_local(size, file, line);
} else if (smpi_cfg_shared_malloc() == SharedMallocType::GLOBAL) {
int nb_shared_blocks = 1;
- size_t shared_block_offsets[2] = {0, size};
- return smpi_shared_malloc_partial(size, shared_block_offsets, nb_shared_blocks);
+ const std::array<size_t, 2> shared_block_offsets = {{0, size}};
+ return smpi_shared_malloc_partial(size, shared_block_offsets.data(), nb_shared_blocks);
}
XBT_DEBUG("Classic allocation of %zu bytes", size);
return ::operator new(size);
int myrank = this->rank();
int size = this->size();
/* Gather all colors and keys on rank 0 */
- int* sendbuf = xbt_new(int, 2);
- sendbuf[0] = color;
- sendbuf[1] = key;
+ const std::array<int, 2> sendbuf = {{color, key}};
if (myrank == 0) {
recvbuf = xbt_new(int, 2 * size);
} else {
recvbuf = nullptr;
}
- gather__default(sendbuf, 2, MPI_INT, recvbuf, 2, MPI_INT, 0, this);
- xbt_free(sendbuf);
+ gather__default(sendbuf.data(), 2, MPI_INT, recvbuf, 2, MPI_INT, 0, this);
/* Do the actual job */
if (myrank == 0) {
MPI_Group* group_snd = xbt_new(MPI_Group, size);
#include "src/smpi/include/smpi_actor.hpp"
#include <algorithm>
+#include <array>
#include <functional>
#include <string>
/* in this situation the data are contiguous thus it's not required to serialize and unserialize it*/
*new_type = new Datatype(count * block_length * old_type->size(), 0, ((count -1) * stride + block_length)*
old_type->size(), DT_FLAG_CONTIGUOUS);
- int ints[3] = {count, block_length, stride};
- (*new_type)->contents_ = new Datatype_contents(MPI_COMBINER_VECTOR, 3, ints, 0, nullptr, 1, &old_type);
+ const std::array<int, 3> ints = {{count, block_length, stride}};
+ (*new_type)->contents_ = new Datatype_contents(MPI_COMBINER_VECTOR, 3, ints.data(), 0, nullptr, 1, &old_type);
retval=MPI_SUCCESS;
}
return retval;
}else{
/* in this situation the data are contiguous thus it's not required to serialize and unserialize it*/
*new_type = new Datatype(count * block_length * old_type->size(), 0, count * block_length * old_type->size(), DT_FLAG_CONTIGUOUS);
- int ints[2] = {count, block_length};
- (*new_type)->contents_ = new Datatype_contents(MPI_COMBINER_HVECTOR, 2, ints, 1, &stride, 1, &old_type);
+ const std::array<int, 2> ints = {{count, block_length}};
+ (*new_type)->contents_ = new Datatype_contents(MPI_COMBINER_HVECTOR, 2, ints.data(), 1, &stride, 1, &old_type);
retval=MPI_SUCCESS;
}
return retval;
tmp = *newtype;
}
- MPI_Aint lbs[1] = {lb * extent};
- int sizes [1]={1};
+ const MPI_Aint lbs = lb * extent;
+ const int sizes = 1;
//handle LB and UB with a resized call
- create_hindexed( 1, sizes, lbs, tmp, newtype);
+ create_hindexed(1, &sizes, &lbs, tmp, newtype);
unref(tmp);
tmp = *newtype;
}
int Datatype::create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
- int blocks[3] = {1, 1, 1};
- MPI_Aint disps[3] = {lb, 0, lb + extent};
- MPI_Datatype types[3] = {MPI_LB, oldtype, MPI_UB};
+ const std::array<int, 3> blocks = {{1, 1, 1}};
+ const std::array<MPI_Aint, 3> disps = {{lb, 0, lb + extent}};
+ const std::array<MPI_Datatype, 3> types = {{MPI_LB, oldtype, MPI_UB}};
- *newtype = new simgrid::smpi::Type_Struct(oldtype->size(), lb, lb + extent, DT_FLAG_DERIVED, 3, blocks, disps, types);
+ *newtype = new simgrid::smpi::Type_Struct(oldtype->size(), lb, lb + extent, DT_FLAG_DERIVED, 3, blocks.data(),
+ disps.data(), types.data());
(*newtype)->addflag(~DT_FLAG_COMMITED);
return MPI_SUCCESS;
#include "smpi_op.hpp"
#include <xbt/log.h>
+#include <array>
#include <cstring>
namespace simgrid{
}
Type_Hvector::Type_Hvector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int block_length, MPI_Aint stride, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_length_(block_length), block_stride_(stride), old_type_(old_type){
- int ints[2] = {count, block_length};
- contents_ = new Datatype_contents(MPI_COMBINER_HVECTOR, 2, ints, 1, &stride, 1, &old_type);
+ const std::array<int, 2> ints = {{count, block_length}};
+ contents_ = new Datatype_contents(MPI_COMBINER_HVECTOR, 2, ints.data(), 1, &stride, 1, &old_type);
old_type->ref();
}
Type_Hvector::~Type_Hvector(){
: Type_Hvector(size, lb, ub, flags, count, block_length, stride * old_type->get_extent(), old_type)
{
delete contents_;
- int ints[3] = {count, block_length, stride};
- contents_ = new Datatype_contents(MPI_COMBINER_VECTOR, 3, ints, 0, nullptr, 1, &old_type);
+ const std::array<int, 3> ints = {{count, block_length, stride}};
+ contents_ = new Datatype_contents(MPI_COMBINER_VECTOR, 3, ints.data(), 0, nullptr, 1, &old_type);
}
int Type_Vector::clone(MPI_Datatype* type)
#include "src/smpi/include/smpi_actor.hpp"
#include <algorithm>
+#include <array>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_request, smpi, "Logging specific to SMPI (request)");
void *recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag,
MPI_Comm comm, MPI_Status * status)
{
- MPI_Request requests[2];
- MPI_Status stats[2];
+ std::array<MPI_Request, 2> requests;
+ std::array<MPI_Status, 2> stats;
int myid = simgrid::s4u::this_actor::get_pid();
if ((comm->group()->actor(dst)->get_pid() == myid) && (comm->group()->actor(src)->get_pid() == myid)) {
Datatype::copy(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype);
}
requests[0] = isend_init(sendbuf, sendcount, sendtype, dst, sendtag, comm);
requests[1] = irecv_init(recvbuf, recvcount, recvtype, src, recvtag, comm);
- startall(2, requests);
- waitall(2, requests, stats);
+ startall(2, requests.data());
+ waitall(2, requests.data(), stats.data());
unref(&requests[0]);
unref(&requests[1]);
if(status != MPI_STATUS_IGNORE) {