-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathrun.cpp
63 lines (52 loc) · 2.04 KB
/
run.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright Lawrence Livermore National Security, LLC and other ExaCA Project Developers.
// See the top-level LICENSE file for details.
//
// SPDX-License-Identifier: MIT
#include "ExaCA.hpp"
#include <Kokkos_Core.hpp>
#include "mpi.h"
#include <stdexcept>
#include <string>
int main(int argc, char *argv[]) {
// Initialize MPI
int id, np;
MPI_Init(&argc, &argv);
// Initialize Kokkos
Kokkos::initialize(argc, argv);
{
using memory_space = Kokkos::DefaultExecutionSpace::memory_space;
// Get number of processes
MPI_Comm_size(MPI_COMM_WORLD, &np);
// Get individual process ID
MPI_Comm_rank(MPI_COMM_WORLD, &id);
if (id == 0) {
std::cout << "ExaCA version: " << version() << " \nExaCA commit: " << gitCommitHash()
<< "\nKokkos version: " << kokkosVersion() << std::endl;
Kokkos::DefaultExecutionSpace().print_configuration(std::cout);
std::cout << "Number of MPI ranks = " << np << std::endl;
}
if (argc < 2) {
throw std::runtime_error("Error: Must provide path to input file on the command line.");
}
else {
// Create timers
Timers timers(id);
timers.startInit();
// Run CA code using reduced temperature data format
std::string input_file = argv[1];
// Read input file
Inputs inputs(id, input_file);
// Setup local and global grids, decomposing domain (needed to construct temperature)
Grid grid(inputs.simulation_type, id, np, inputs.domain.number_of_layers, inputs.domain,
inputs.temperature);
// Temperature fields characterized by data in this structure
Temperature<memory_space> temperature(grid, inputs.temperature, inputs.print.store_solidification_start);
runExaCA(id, np, inputs, timers, grid, temperature);
}
}
// Finalize Kokkos
Kokkos::finalize();
// Finalize MPI
MPI_Finalize();
return 0;
}