本文介绍了切换数量不是整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编译以下程序,但它给了我很多错误:
Hi,
I am trying to compile the following program but its giving me lots of errors:
#include <iostream>
#include <fstream>
#include <cmath>
#include <mpi.h>
#include <ctime>
#include <vector>
#define MYBUFFERLENGTH 1024
char myinbuffer[MYBUFFERLENGTH];
char myoutbuffer[MYBUFFERLENGTH];
extern "C" {
int mikes_MPI_SIZE (MPI_Datatype datatype) {
/* sizeof doesn't work for MPI_Datatype, thus this function */
/* I probably should do this with a table, but then error
checking is harder */
/* see man MPI_COMM_WORLD */
switch (datatype){
case MPI_CHAR:
case MPI_BYTE:
case MPI_UNSIGNED_CHAR:
return sizeof(char);
case MPI_SHORT:
case MPI_UNSIGNED_SHORT:
return sizeof(short);
case MPI_INT:
case MPI_UNSIGNED:
return sizeof(int);
case MPI_LONG:
case MPI_UNSIGNED_LONG:
return sizeof(long);
case MPI_FLOAT:
return sizeof(float);
case MPI_DOUBLE:
return sizeof(double);
case MPI_FLOAT_INT:
return sizeof(float)+sizeof(int);
case MPI_LONG_INT:
return sizeof(long)+sizeof(int);
case MPI_DOUBLE_INT:
return sizeof(double)+sizeof(int);
case MPI_SHORT_INT:
return sizeof(short)+sizeof(int);
case MPI_2INT:
return 2*sizeof(int);
default:
die("need to insert size for new datatype in mikes_MPI_SIZE()");
}
return -1;
}
int MMPI_Reduce(void * sendbuf, void * recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) {
int bit,processor1,i;
int *iaccum1;
int *iaccum2;
double *daccum1;
double *daccum2;
int * locaccum1;
int * locaccum2;
iaccum1=(int *) myinbuffer;
iaccum2=(int *)(myinbuffer+mikes_MPI_SIZE(datatype));
daccum1=(double *) myinbuffer;
daccum2=(double *)(myinbuffer+mikes_MPI_SIZE(datatype));
locaccum1=(int*)(myinbuffer+mikes_MPI_SIZE(datatype)-sizeof(int));
locaccum2=(int*)(myinbuffer+2*mikes_MPI_SIZE(datatype)-sizeof(int));
*locaccum1=*locaccum2=processor;
return MPI_SUCCESS;
}
我收到了几个错误,但我想删除以下错误:
I am getting several errors but I want to remove the following one:
$ mpic++ mpiBlkProb3.cpp
mpiBlkProb3.cpp: In function ‘int mikes_MPI_SIZE(MPI_Datatype)’:
mpiBlkProb3.cpp:43:21: error: switch quantity not an integer
switch (datatype){
有些人请指导我。
Zulfi。
什么我试过了:
我无法理解这个错误。
Some body please guide me.
Zulfi.
What I have tried:
I can't understand this error.
推荐答案
有些人请指导我。
Zulfi。
我尝试了什么:
我可以不明白这个错误或。
Some body please guide me.
Zulfi.
What I have tried:
I can't understand this error.
这篇关于切换数量不是整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!