/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ < BioEM software for Bayesian inference of Electron Microscopy images> Copyright (C) 2016 Pilar Cossio, David Rohr, Fabio Baruffa, Markus Rampp, Volker Lindenstruth and Gerhard Hummer. Max Planck Institute of Biophysics, Frankfurt, Germany. Frankfurt Institute for Advanced Studies, Goethe University Frankfurt, Germany. Max Planck Computing and Data Facility, Garching, Germany. Released under the GNU Public License, v3. See license statement for terms of distribution. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #ifdef WITH_MPI #include #define MPI_CHK(expr) \ if (expr != MPI_SUCCESS) \ { \ fprintf(stderr, "Error in MPI function %s: %d\n", __FILE__, __LINE__); \ } #endif #include #include #include #include #include #ifdef _WIN32 #include #include #endif #include #include #include #include "bioem.h" #include "bioem_cuda.h" #ifdef WITH_OPENMP #include #endif #ifdef WITH_MPI int mpi_rank; int mpi_size; #else int mpi_rank = 0; int mpi_size = 1; #endif #include "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); }