繁体   English   中英

mpi编译警告隐式声明

[英]mpi compiling warning implicit declaration

今天,我在带有自酿mpicc的mi mac 10.9上安装了simlpe hello world程序的mpi,但是如果尝试这样的操作

#include <mpi.h>
#include <string.h>
#include <stdio.h>
#define max 1000

int main(int argv, char *argc[]){


    int myrank,nProc,tag,j;
    char buff [max];
    MPI_Status status;
    tag=0;
    MPI_Init(&argv,&argc);
    MPI_Comm_Rank(MPI_COMM_WORLD,&myrank);
    MPI_Comm_Size(MPI_COMM_WORLD,&nProc);

    if(myrank==0){
    for(j =1 ; j<nProc;j++){
    MPI_Recv(&buff,max,MPI_CHAR,j,tag,MPI_COMM_WORLD,&status);
    printf("Il processo %d dice di chiamarsi %s\n",j,buff);
    }

                }
                else{
                switch (myrank){
                case 1 :
                 MPI_Send("Franco",max,MPI_CHAR,j,tag,MPI_COMM_WORLD);
                 break;
                 case 2 :
                 MPI_Send("Mena",max,MPI_CHAR,j,tag,MPI_COMM_WORLD);
                 break;
                 case 3 :
                 MPI_Send("Nino",max,MPI_CHAR,j,tag,MPI_COMM_WORLD);
                 break;
                                }
                    }
    printf("Ciao da %d \n",myrank);
    MPI_Finalize();
    return(0);
                               }

我尝试在下面的行中对其进行编译:

mpicc -o filename filename.c

它给我这个警告而不是建立。

nucciampi.c:15:3: warning: implicit declaration of function 'MPI_Comm_Rank' is
      invalid in C99 [-Wimplicit-function-declaration]
                MPI_Comm_Rank(MPI_COMM_WORLD,&myrank);
                ^
nucciampi.c:16:3: warning: implicit declaration of function 'MPI_Comm_Size' is
      invalid in C99 [-Wimplicit-function-declaration]
                MPI_Comm_Size(MPI_COMM_WORLD,&nProc);
                ^
2 warnings generated.
Undefined symbols for architecture x86_64:
  "_MPI_Comm_Rank", referenced from:
      _main in nucciampi-zsehoq.o
  "_MPI_Comm_Size", referenced from:
      _main in nucciampi-zsehoq.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

请帮我解决这个问题!!!

MPI_Comm_Rank > MPI_Comm_rank

MPI_Comm_Size > MPI_Comm_size

MPI中所有例程和常量都有一个定义明确的命名约定,它在MPI规范的第2.2节中进行了描述:

在C语言中,与特定类型的MPI对象关联的所有例程的格式应为MPI_Class_action_subset ,如果不存在子集,则其格式应为MPI_Class_action 在Fortran中,与特定类型的MPI对象关联的所有例程的格式应为MPI_CLASS_ACTION_SUBSET或者,如果不存在子集,则格式应为MPI_CLASS_ACTION 对于C和Fortran,我们使用C ++术语定义Class 在C ++中,该例程是Class上的方法,名称为MPI::Class::Action_subset 如果例程与某个类相关联,但作为对象方法没有意义,则该例程是该类的静态成员函数。

请注意,与Fortran不同,C中的符号名称区分大小写。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM