+/*
+ * Copies noncontiguous data into contiguous memory.
+ * @param contiguous_vector - output vector
+ * @param noncontiguous_vector - input vector
+ * @param type - pointer contening :
+ * - stride - stride of between noncontiguous data
+ * - block_length - the width or height of blocked matrix
+ * - count - the number of rows of matrix
+ */
+void serialize_vector( const void *noncontiguous_vector,
+ void *contiguous_vector,
+ size_t count,
+ void *type)
+{
+ s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)type;
+ int i;
+ for (i = 0; i < type_c->block_count * count; i++) {
+ memcpy(contiguous_vector,
+ noncontiguous_vector, type_c->block_length * type_c->size_oldtype);
+ contiguous_vector += type_c->block_length*type_c->size_oldtype;
+ noncontiguous_vector += type_c->block_stride*type_c->size_oldtype;
+ }
+}
+/*
+ * Copies contiguous data into noncontiguous memory.
+ * @param noncontiguous_vector - output vector
+ * @param contiguous_vector - input vector
+ * @param type - pointer contening :
+ * - stride - stride of between noncontiguous data
+ * - block_length - the width or height of blocked matrix
+ * - count - the number of rows of matrix
+ */
+void unserialize_vector( const void *contiguous_vector,
+ void *noncontiguous_vector,
+ size_t count,
+ void *type)
+{
+ s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)type;
+ int i;
+ for (i = 0; i < type_c->block_count * count; i++) {
+ memcpy(noncontiguous_vector,
+ contiguous_vector, type_c->block_length * type_c->size_oldtype);
+ contiguous_vector += type_c->block_length*type_c->size_oldtype;
+ noncontiguous_vector += type_c->block_stride*type_c->size_oldtype;
+ }
+}
+
+/*
+ * Create a Sub type vector to be able to serialize and unserialize it
+ * the structre s_smpi_mpi_vector_t is derived from s_smpi_subtype which
+ * required the functions unserialize and serialize
+ *
+ */
+s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride,
+ int block_length,
+ int block_count,
+ MPI_Datatype old_type,
+ int size_oldtype){
+ s_smpi_mpi_vector_t *new_t= xbt_new(s_smpi_mpi_vector_t,1);
+ new_t->base.serialize = &serialize_vector;
+ new_t->base.unserialize = &unserialize_vector;
+ new_t->block_stride = block_stride;
+ new_t->block_length = block_length;
+ new_t->block_count = block_count;
+ new_t->old_type = old_type;
+ new_t->size_oldtype = size_oldtype;
+ return new_t;
+}
+
+void smpi_datatype_create(MPI_Datatype* new_type, int size, int has_subtype,
+ void *struct_type, int flags){