else if (sendtype->has_subtype == 0)
{
s_smpi_subtype_t *subtype = recvtype->substruct;
- subtype->unserialize( sendbuf, recvbuf,1, subtype);
+ subtype->unserialize( sendbuf, recvbuf,1, subtype, MPI_REPLACE);
}
else if (recvtype->has_subtype == 0)
{
subtype->serialize( sendbuf, buf_tmp,count/smpi_datatype_size(sendtype), subtype);
subtype = recvtype->substruct;
- subtype->unserialize( buf_tmp, recvbuf,count/smpi_datatype_size(recvtype), subtype);
+ subtype->unserialize( buf_tmp, recvbuf,count/smpi_datatype_size(recvtype), subtype, MPI_REPLACE);
free(buf_tmp);
}
*/
void serialize_vector( const void *noncontiguous_vector,
void *contiguous_vector,
- size_t count,
+ int count,
void *type)
{
s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)type;
*/
void unserialize_vector( const void *contiguous_vector,
void *noncontiguous_vector,
- size_t count,
- void *type)
+ int count,
+ void *type,
+ MPI_Op op)
{
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++) {
if (type_c->old_type->has_subtype == 0)
- memcpy(noncontiguous_vector_char,
- contiguous_vector_char, type_c->block_length * type_c->size_oldtype);
+ smpi_op_apply(op, contiguous_vector_char, noncontiguous_vector_char, &type_c->block_length,
+ &type_c->old_type);
+ /* memcpy(noncontiguous_vector_char,
+ contiguous_vector_char, type_c->block_length * type_c->size_oldtype);*/
else
((s_smpi_subtype_t*)type_c->old_type->substruct)->unserialize( contiguous_vector_char,
noncontiguous_vector_char,
type_c->block_length,
- type_c->old_type->substruct);
+ type_c->old_type->substruct,
+ op);
contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
if((i+1)%type_c->block_count ==0)
noncontiguous_vector_char += type_c->block_length*smpi_datatype_get_extent(type_c->old_type);
*/
void serialize_contiguous( const void *noncontiguous_hvector,
void *contiguous_hvector,
- size_t count,
+ int count,
void *type)
{
s_smpi_mpi_contiguous_t* type_c = (s_smpi_mpi_contiguous_t*)type;
*/
void unserialize_contiguous( const void *contiguous_vector,
void *noncontiguous_vector,
- size_t count,
- void *type)
+ int count,
+ void *type,
+ MPI_Op op)
{
s_smpi_mpi_contiguous_t* type_c = (s_smpi_mpi_contiguous_t*)type;
char* contiguous_vector_char = (char*)contiguous_vector;
char* noncontiguous_vector_char = (char*)noncontiguous_vector+type_c->lb;
-
- memcpy(noncontiguous_vector_char,
- contiguous_vector_char, count* type_c->block_count * type_c->size_oldtype);
+ int n= count* type_c->block_count;
+ smpi_op_apply(op, contiguous_vector_char, noncontiguous_vector_char, &n,
+ &type_c->old_type);
+ /*memcpy(noncontiguous_vector_char,
+ contiguous_vector_char, count* type_c->block_count * type_c->size_oldtype);*/
}
void free_contiguous(MPI_Datatype* d){
*/
void serialize_hvector( const void *noncontiguous_hvector,
void *contiguous_hvector,
- size_t count,
+ int count,
void *type)
{
s_smpi_mpi_hvector_t* type_c = (s_smpi_mpi_hvector_t*)type;
*/
void unserialize_hvector( const void *contiguous_vector,
void *noncontiguous_vector,
- size_t count,
- void *type)
+ int count,
+ void *type,
+ MPI_Op op)
{
s_smpi_mpi_hvector_t* type_c = (s_smpi_mpi_hvector_t*)type;
int i;
for (i = 0; i < type_c->block_count * count; i++) {
if (type_c->old_type->has_subtype == 0)
- memcpy(noncontiguous_vector_char,
- contiguous_vector_char, type_c->block_length * type_c->size_oldtype);
+ smpi_op_apply(op, contiguous_vector_char, noncontiguous_vector_char, &type_c->block_length,
+ &type_c->old_type);
+ /*memcpy(noncontiguous_vector_char,
+ contiguous_vector_char, type_c->block_length * type_c->size_oldtype);*/
else
((s_smpi_subtype_t*)type_c->old_type->substruct)->unserialize( contiguous_vector_char,
noncontiguous_vector_char,
type_c->block_length,
- type_c->old_type->substruct);
+ type_c->old_type->substruct,
+ op);
contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
if((i+1)%type_c->block_count ==0)
noncontiguous_vector_char += type_c->block_length*type_c->size_oldtype;
*/
void serialize_indexed( const void *noncontiguous_indexed,
void *contiguous_indexed,
- size_t count,
+ int count,
void *type)
{
s_smpi_mpi_indexed_t* type_c = (s_smpi_mpi_indexed_t*)type;
*/
void unserialize_indexed( const void *contiguous_indexed,
void *noncontiguous_indexed,
- size_t count,
- void *type)
+ int count,
+ void *type,
+ MPI_Op op)
{
s_smpi_mpi_indexed_t* type_c = (s_smpi_mpi_indexed_t*)type;
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->has_subtype == 0)
- memcpy(noncontiguous_indexed_char ,
- contiguous_indexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
+ smpi_op_apply(op, contiguous_indexed_char, noncontiguous_indexed_char, &type_c->block_lengths[i],
+ &type_c->old_type);
+ /*memcpy(noncontiguous_indexed_char ,
+ contiguous_indexed_char, type_c->block_lengths[i] * type_c->size_oldtype);*/
else
((s_smpi_subtype_t*)type_c->old_type->substruct)->unserialize( contiguous_indexed_char,
noncontiguous_indexed_char,
type_c->block_lengths[i],
- type_c->old_type->substruct);
+ type_c->old_type->substruct,
+ op);
contiguous_indexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
if (i<type_c->block_count-1)
*/
void serialize_hindexed( const void *noncontiguous_hindexed,
void *contiguous_hindexed,
- size_t count,
+ int count,
void *type)
{
s_smpi_mpi_hindexed_t* type_c = (s_smpi_mpi_hindexed_t*)type;
*/
void unserialize_hindexed( const void *contiguous_hindexed,
void *noncontiguous_hindexed,
- size_t count,
- void *type)
+ int count,
+ void *type,
+ MPI_Op op)
{
s_smpi_mpi_hindexed_t* type_c = (s_smpi_mpi_hindexed_t*)type;
int i,j;
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
if (type_c->old_type->has_subtype == 0)
- memcpy(noncontiguous_hindexed_char,
- contiguous_hindexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
+ smpi_op_apply(op, contiguous_hindexed_char, noncontiguous_hindexed_char, &type_c->block_lengths[i],
+ &type_c->old_type);
+ /*memcpy(noncontiguous_hindexed_char,
+ contiguous_hindexed_char, type_c->block_lengths[i] * type_c->size_oldtype);*/
else
((s_smpi_subtype_t*)type_c->old_type->substruct)->unserialize( contiguous_hindexed_char,
noncontiguous_hindexed_char,
type_c->block_lengths[i],
- type_c->old_type->substruct);
+ type_c->old_type->substruct,
+ op);
contiguous_hindexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
if (i<type_c->block_count-1)noncontiguous_hindexed_char = (char*)noncontiguous_hindexed + type_c->block_indices[i+1];
*/
void serialize_struct( const void *noncontiguous_struct,
void *contiguous_struct,
- size_t count,
+ int count,
void *type)
{
s_smpi_mpi_struct_t* type_c = (s_smpi_mpi_struct_t*)type;
*/
void unserialize_struct( const void *contiguous_struct,
void *noncontiguous_struct,
- size_t count,
- void *type)
+ int count,
+ void *type,
+ MPI_Op op)
{
s_smpi_mpi_struct_t* type_c = (s_smpi_mpi_struct_t*)type;
int i,j;
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
if (type_c->old_types[i]->has_subtype == 0)
- memcpy(noncontiguous_struct_char,
- contiguous_struct_char, type_c->block_lengths[i] * smpi_datatype_size(type_c->old_types[i]));
+ smpi_op_apply(op, contiguous_struct_char, noncontiguous_struct_char, &type_c->block_lengths[i],
+ & type_c->old_types[i]);
+ /*memcpy(noncontiguous_struct_char,
+ contiguous_struct_char, type_c->block_lengths[i] * smpi_datatype_size(type_c->old_types[i]));*/
else
((s_smpi_subtype_t*)type_c->old_types[i]->substruct)->unserialize( contiguous_struct_char,
noncontiguous_struct_char,
type_c->block_lengths[i],
- type_c->old_types[i]->substruct);
+ type_c->old_types[i]->substruct,
+ op);
contiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_size(type_c->old_types[i]);
if (i<type_c->block_count-1)noncontiguous_struct_char = (char*)noncontiguous_struct + type_c->block_indices[i+1];
#define BXOR_OP(a, b) (b) ^= (a)
#define MAXLOC_OP(a, b) (b) = (a.value) < (b.value) ? (b) : (a)
#define MINLOC_OP(a, b) (b) = (a.value) < (b.value) ? (a) : (b)
-#define REPLACE_OP(a,b) (b) = (a)
#define APPLY_FUNC(a, b, length, type, func) \
{ \
static void replace_func(void *a, void *b, int *length,
MPI_Datatype * datatype)
{
- if (*datatype == MPI_CHAR) {
- APPLY_FUNC(a, b, length, char, REPLACE_OP);
- } else if (*datatype == MPI_SHORT) {
- APPLY_FUNC(a, b, length, short, REPLACE_OP);
- } else if (*datatype == MPI_INT) {
- APPLY_FUNC(a, b, length, int, REPLACE_OP);
- } else if (*datatype == MPI_LONG) {
- APPLY_FUNC(a, b, length, long, REPLACE_OP);
- } else if (*datatype == MPI_UNSIGNED_SHORT) {
- APPLY_FUNC(a, b, length, unsigned short, REPLACE_OP);
- } else if (*datatype == MPI_UNSIGNED) {
- APPLY_FUNC(a, b, length, unsigned int, REPLACE_OP);
- } else if (*datatype == MPI_UNSIGNED_LONG) {
- APPLY_FUNC(a, b, length, unsigned long, REPLACE_OP);
- } else if (*datatype == MPI_BYTE) {
- APPLY_FUNC(a, b, length, uint8_t, REPLACE_OP);
- }
+ memcpy(b, a, *length * smpi_datatype_size(*datatype));
}
#define CREATE_MPI_OP(name, func) \