1

我正在使用 linux 上的 openMPI 4.0.1 版编译以下代码并MPI_Wtime()返回 0。我正在使用 mpicc -o testCode myfile.c 进行编译

#include <stdio.h>
#include <time.h>
#include <mpi.h>

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

    // Initialize MPI
    MPI_Init(&argc, &argv);

    // printf("%d\n",MPI_UNIVERSE_SIZE);

    // Get the clock precision and start the clock.
    double precision = MPI_Wtick();
    double starttime = MPI_Wtime();

    // Get this processor's rank and the size of the world.
    int rank, size;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);

    if (rank ==0)
        printf("start time = %g\n", starttime);

    MPI_Finalize();

    return 0;
}
4

0 回答 0