Select Git revision
David Rohr authored
main.cpp 1.97 KiB
#include <mpi.h>
#define MPI_CHK(expr) \
if (expr != MPI_SUCCESS) \
{ \
fprintf(stderr, "Error in MPI function %s: %d\n", __FILE__, __LINE__); \
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <fenv.h>
#ifdef _WIN32
#include <Windows.h>
#include <WinBase.h>
#endif
#include <iostream>
#include <algorithm>
#include <iterator>
#include "bioem.h"
#include "bioem_cuda.h"
#ifdef WITH_OPENMP
#include <omp.h>
#endif
#ifdef WITH_MPI
int mpi_rank;
int mpi_size;
#else
const int mpi_rank = 0;
const int mpi_size = 1;
#endif
#include "cmodules/timer.h"
int main(int argc, char* argv[])
{
// **************************************************************************************
// ********************************* Main BioEM code **********************************
// ************************************************************************************
#ifdef WITH_MPI
MPI_CHK(MPI_Init(&argc, &argv));
MPI_CHK(MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank));
MPI_CHK(MPI_Comm_size(MPI_COMM_WORLD, &mpi_size));
#endif
#ifdef _MM_DENORMALS_ZERO_ON
#pragma omp parallel
{
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); //Flush denormals to zero in all OpenMP threads
}
#endif
HighResTimer timer;
bioem* bio;
#ifdef WITH_CUDA
if (getenv("GPU") && atoi(getenv("GPU")))
{
bio = bioem_cuda_create();
}
else
#endif
{
bio = new bioem;
}
// ************ Configuration and Pre-calculating necessary objects *****************
if (mpi_rank == 0) printf("Configuring\n");
if (bio->configure(argc, argv) == 0)
{
// ******************************* Run BioEM routine ******************************
if (mpi_rank == 0) printf("Running\n");
timer.Start();
bio->run();
timer.Stop();
// ************************************ End **********************************
printf ("The code ran for %f seconds (rank %d).\n", timer.GetElapsedTime(), mpi_rank);
bio->cleanup();
}
delete bio;
#ifdef WITH_MPI
MPI_Finalize();
#endif
return(0);
}