main.cpp 1.76 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#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"
17
18

#ifdef WITH_OPENMP
19
#include <omp.h>
20
#endif
21

22
23
24
25
26
27
28
29
#ifdef WITH_MPI
int mpi_rank;
int mpi_size;
#else
const int mpi_rank = 0;
const int mpi_size = 1;
#endif

30
31
32
33
#include "cmodules/timer.h"

int main(int argc, char* argv[])
{
David Rohr's avatar
David Rohr committed
34
35
36
	// **************************************************************************************
	// *********************************  Main BioEM code **********************************
	// ************************************************************************************
37

38
39
40
41
42
43
#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

44
#ifdef _MM_DENORMALS_ZERO_ON
45
	#pragma omp parallel
46
47
48
	{
		_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); //Flush denormals to zero in all OpenMP threads
	}
49
#endif
50
	HighResTimer timer;
51

52
	bioem* bio;
53
#ifdef WITH_CUDA
54
55
	if (getenv("GPU") && atoi(getenv("GPU")))
	{
56
		bio = bioem_cuda_create();
57
58
	}
	else
59
#endif
60
61
	{
		bio = new bioem;
62
63
	}

David Rohr's avatar
David Rohr committed
64
	// ************  Configuration and Pre-calculating necessary objects *****************
65
	printf("Configuring\n");
66
67
	if (bio->configure(argc, argv) == 0)
	{
68

69
70
71
72
73
		// *******************************  Run BioEM routine ******************************
		printf("Running\n");
		timer.Start();
		bio->run();
		timer.Stop();
74

75
76
77
78
		// ************************************ End **********************************
		printf ("The code ran for %f seconds.\n", timer.GetElapsedTime());
		bio->cleanup();
	}
79
	delete bio;
80

81
82
83
84
#ifdef WITH_MPI
	MPI_Finalize();
#endif

85
	return(0);
86
}