/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
+#include "mc/mc.h"
#include "private.h"
+#include "simgrid/modelchecker.h"
#include "smpi_mpi_dt_private.h"
-#include "mc/mc.h"
#include "xbt/replay.h"
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
#include <xbt/ex.hpp>
-#include "simgrid/modelchecker.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi_dt, smpi, "Logging specific to SMPI (datatype)");
if(datatype->attributes !=nullptr){
(*new_t)->attributes = xbt_dict_new_homogeneous(nullptr);
xbt_dict_cursor_t cursor = nullptr;
- int* key;
+ char* key;
int flag;
void* value_in;
void* value_out;
xbt_dict_foreach (datatype->attributes, cursor, key, value_in) {
- smpi_type_key_elem elem = static_cast<smpi_type_key_elem>(
- xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(key), sizeof(int)));
+ smpi_type_key_elem elem =
+ static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, key, sizeof(int)));
if (elem != nullptr && elem->copy_fn != MPI_NULL_COPY_FN) {
- ret = elem->copy_fn(datatype, *key, nullptr, value_in, &value_out, &flag);
+ ret = elem->copy_fn(datatype, atoi(key), nullptr, value_in, &value_out, &flag);
if (ret != MPI_SUCCESS) {
smpi_datatype_unuse(*new_t);
*new_t = MPI_DATATYPE_NULL;
return ret;
}
if (flag)
- xbt_dict_set_ext((*new_t)->attributes, reinterpret_cast<const char*>(key), sizeof(int), value_out, nullptr);
+ xbt_dict_set_ext((*new_t)->attributes, key, sizeof(int), value_out, nullptr);
}
}
}
if((*type)->attributes !=nullptr){
xbt_dict_cursor_t cursor = nullptr;
- int* key;
+ char* key;
void * value;
int flag;
xbt_dict_foreach((*type)->attributes, cursor, key, value){
smpi_type_key_elem elem =
- static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(key), sizeof(int)));
+ static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, key, sizeof(int)));
if(elem!=nullptr && elem->delete_fn!=nullptr)
elem->delete_fn(*type,*key, value, &flag);
}
void serialize_indexed( void* noncontiguous_indexed, void *contiguous_indexed, int count, void *type)
{
s_smpi_mpi_indexed_t* type_c = reinterpret_cast<s_smpi_mpi_indexed_t*>(type);
- int i,j;
char* contiguous_indexed_char = static_cast<char*>(contiguous_indexed);
char* noncontiguous_indexed_char = static_cast<char*>(noncontiguous_indexed)+type_c->block_indices[0] * type_c->size_oldtype;
- for(j=0; j<count;j++){
- for (i = 0; i < type_c->block_count; i++) {
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_indexed_char, noncontiguous_indexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
else
void unserialize_indexed( void* contiguous_indexed, void *noncontiguous_indexed, int count, void *type, MPI_Op op)
{
s_smpi_mpi_indexed_t* type_c = reinterpret_cast<s_smpi_mpi_indexed_t*>(type);
- int i,j;
char* contiguous_indexed_char = static_cast<char*>(contiguous_indexed);
char* noncontiguous_indexed_char =
static_cast<char*>(noncontiguous_indexed)+type_c->block_indices[0]*smpi_datatype_get_extent(type_c->old_type);
- for(j=0; j<count;j++){
- for (i = 0; i < type_c->block_count; i++) {
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_indexed_char, noncontiguous_indexed_char, &type_c->block_lengths[i],
&type_c->old_type);
new_t->base.subtype_use = &use_indexed;
new_t->block_lengths= xbt_new(int, block_count);
new_t->block_indices= xbt_new(int, block_count);
- int i;
- for(i=0;i<block_count;i++){
+ for (int i = 0; i < block_count; i++) {
new_t->block_lengths[i]=block_lengths[i];
new_t->block_indices[i]=block_indices[i];
}
int smpi_datatype_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type)
{
- int i;
- int retval;
int size = 0;
bool contiguous=true;
MPI_Aint lb = 0;
ub=indices[0]*smpi_datatype_get_extent(old_type) + blocklens[0]*smpi_datatype_ub(old_type);
}
- for(i=0; i< count; i++){
- if (blocklens[i]<0)
+ for (int i = 0; i < count; i++) {
+ if (blocklens[i] < 0)
return MPI_ERR_ARG;
size += blocklens[i];
smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), lb, ub, sizeof(s_smpi_mpi_contiguous_t), subtype,
DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
}
- retval=MPI_SUCCESS;
- return retval;
+ return MPI_SUCCESS;
}
/* Hindexed Implementation - Indexed with indices in bytes */
void serialize_hindexed( void* noncontiguous_hindexed, void *contiguous_hindexed, int count, void *type)
{
s_smpi_mpi_hindexed_t* type_c = reinterpret_cast<s_smpi_mpi_hindexed_t*>(type);
- int i,j;
char* contiguous_hindexed_char = static_cast<char*>(contiguous_hindexed);
char* noncontiguous_hindexed_char = static_cast<char*>(noncontiguous_hindexed)+ type_c->block_indices[0];
- for(j=0; j<count;j++){
- for (i = 0; i < type_c->block_count; i++) {
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_hindexed_char, noncontiguous_hindexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
else
MPI_Op op)
{
s_smpi_mpi_hindexed_t* type_c = reinterpret_cast<s_smpi_mpi_hindexed_t*>(type);
- int i,j;
char* contiguous_hindexed_char = static_cast<char*>(contiguous_hindexed);
char* noncontiguous_hindexed_char = static_cast<char*>(noncontiguous_hindexed)+ type_c->block_indices[0];
- for(j=0; j<count;j++){
- for (i = 0; i < type_c->block_count; i++) {
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_hindexed_char, noncontiguous_hindexed_char, &type_c->block_lengths[i],
&type_c->old_type);
int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type)
{
- int i;
- int retval;
int size = 0;
bool contiguous=true;
MPI_Aint lb = 0;
lb=indices[0] + smpi_datatype_lb(old_type);
ub=indices[0] + blocklens[0]*smpi_datatype_ub(old_type);
}
- for(i=0; i< count; i++){
- if (blocklens[i]<0)
+ for (int i = 0; i < count; i++) {
+ if (blocklens[i] < 0)
return MPI_ERR_ARG;
size += blocklens[i];
smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), 0,size * smpi_datatype_size(old_type),
1, subtype, DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
}
- retval=MPI_SUCCESS;
- return retval;
+ return MPI_SUCCESS;
}
/* struct Implementation - Indexed with indices in bytes */
void serialize_struct( void* noncontiguous_struct, void *contiguous_struct, int count, void *type)
{
s_smpi_mpi_struct_t* type_c = reinterpret_cast<s_smpi_mpi_struct_t*>(type);
- int i,j;
char* contiguous_struct_char = static_cast<char*>(contiguous_struct);
char* noncontiguous_struct_char = static_cast<char*>(noncontiguous_struct)+ type_c->block_indices[0];
- for(j=0; j<count;j++){
- for (i = 0; i < type_c->block_count; i++) {
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < type_c->block_count; i++) {
if (type_c->old_types[i]->sizeof_substruct == 0)
memcpy(contiguous_struct_char, noncontiguous_struct_char,
type_c->block_lengths[i] * smpi_datatype_size(type_c->old_types[i]));
void unserialize_struct( void* contiguous_struct, void *noncontiguous_struct, int count, void *type, MPI_Op op)
{
s_smpi_mpi_struct_t* type_c = reinterpret_cast<s_smpi_mpi_struct_t*>(type);
- int i,j;
char* contiguous_struct_char = static_cast<char*>(contiguous_struct);
char* noncontiguous_struct_char = static_cast<char*>(noncontiguous_struct)+ type_c->block_indices[0];
- for(j=0; j<count;j++){
- for (i = 0; i < type_c->block_count; i++) {
+ for (int j = 0; j < count; j++) {
+ for (int i = 0; i < type_c->block_count; i++) {
if (type_c->old_types[i]->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_struct_char, noncontiguous_struct_char, &type_c->block_lengths[i],
& type_c->old_types[i]);
}
void free_struct(MPI_Datatype* type){
- int i=0;
- for (i = 0; i < reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_count; i++)
+ for (int i = 0; i < reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_count; i++)
smpi_datatype_unuse(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->old_types[i]);
if((*type)->in_use==0){
xbt_free(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_lengths);
}
void use_struct(MPI_Datatype* type){
- int i=0;
- for (i = 0; i < reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_count; i++)
+ for (int i = 0; i < reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->block_count; i++)
smpi_datatype_use(reinterpret_cast<s_smpi_mpi_struct_t*>((*type)->substruct)->old_types[i]);
}
new_t->block_lengths= xbt_new(int, block_count);
new_t->block_indices= xbt_new(MPI_Aint, block_count);
new_t->old_types= xbt_new(MPI_Datatype, block_count);
- int i;
- for(i=0;i<block_count;i++){
+ for (int i = 0; i < block_count; i++) {
new_t->block_lengths[i]=block_lengths[i];
new_t->block_indices[i]=block_indices[i];
new_t->old_types[i]=old_types[i];
int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type)
{
- int i;
size_t size = 0;
bool contiguous=true;
size = 0;
}
bool forced_lb=false;
bool forced_ub=false;
- for(i=0; i< count; i++){
+ for (int i = 0; i < count; i++) {
if (blocklens[i]<0)
return MPI_ERR_ARG;
if (old_types[i]->sizeof_substruct != 0)
MPI_Op smpi_op_new(MPI_User_function * function, bool commute)
{
- MPI_Op op;
- op = xbt_new(s_smpi_mpi_op_t, 1);
+ MPI_Op op = xbt_new(s_smpi_mpi_op_t, 1);
op->func = function;
op-> is_commute = commute;
op-> is_fortran_op = false;