-
-Type_Vector::Type_Vector(int size,MPI_Aint lb, MPI_Aint ub, int flags, int count, int block_length, int stride, MPI_Datatype old_type): Datatype(size, lb, ub, flags), block_count_(count), block_length_(block_length),block_stride_(stride), old_type_(old_type){
- old_type_->ref();
-}
-
-Type_Vector::~Type_Vector(){
- Datatype::unref(old_type_);
-}
-
-
-void Type_Vector::serialize( void* noncontiguous_buf, void *contiguous_buf,
- int count){
- char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
- char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf);
-
- for (int i = 0; i < block_count_ * count; i++) {
- if (not(old_type_->flags() & DT_FLAG_DERIVED))
- memcpy(contiguous_buf_char, noncontiguous_buf_char, block_length_ * old_type_->size());
- else
- old_type_->serialize(noncontiguous_buf_char, contiguous_buf_char, block_length_);
-
- contiguous_buf_char += block_length_*old_type_->size();
- if((i+1)%block_count_ ==0)
- noncontiguous_buf_char += block_length_*old_type_->get_extent();
- else
- noncontiguous_buf_char += block_stride_*old_type_->get_extent();
- }
-}
-
-void Type_Vector::unserialize( void* contiguous_buf, void *noncontiguous_buf,
- int count, MPI_Op op){
- char* contiguous_buf_char = static_cast<char*>(contiguous_buf);
- char* noncontiguous_buf_char = static_cast<char*>(noncontiguous_buf);
-
- for (int i = 0; i < block_count_ * count; i++) {
- if (not(old_type_->flags() & DT_FLAG_DERIVED)) {
- if(op != MPI_OP_NULL)
- op->apply(contiguous_buf_char, noncontiguous_buf_char, &block_length_,
- old_type_);
- }else
- old_type_->unserialize(contiguous_buf_char, noncontiguous_buf_char, block_length_, op);
-
- contiguous_buf_char += block_length_*old_type_->size();
- if((i+1)%block_count_ ==0)
- noncontiguous_buf_char += block_length_*old_type_->get_extent();
- else
- noncontiguous_buf_char += block_stride_*old_type_->get_extent();
- }
-}
-