Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102737640
poisson.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 23, 16:24
Size
1 KB
Mime Type
text/x-c
Expires
Tue, Feb 25, 16:24 (2 d)
Engine
blob
Format
Raw Data
Handle
24410328
Attached To
R11201 phpc-2021
poisson.cc
View Options
/* -------------------------------------------------------------------------- */
#include "simulation.hh"
/* -------------------------------------------------------------------------- */
#include <chrono>
#include <iostream>
#include <sstream>
#include <tuple>
#include <chrono>
/* -------------------------------------------------------------------------- */
#include <mpi.h>
/* -------------------------------------------------------------------------- */
#define EPSILON 0.005
typedef std::chrono::high_resolution_clock clk;
typedef std::chrono::duration<double> second;
static void usage(const std::string & prog_name) {
std::cerr << prog_name << " <grid_size>" << std::endl;
exit(0);
}
int main(int argc, char * argv[]) {
MPI_Init(&argc, &argv);
int prank, psize;
MPI_Comm_rank(MPI_COMM_WORLD, &prank);
MPI_Comm_size(MPI_COMM_WORLD, &psize);
if (argc != 2) usage(argv[0]);
std::stringstream args(argv[1]);
int N;
args >> N;
if(args.fail()) usage(argv[0]);
// Divide the total size by the number of processes
int m_local = N / psize;
// Add 1 or 2 ghosts depending on the prank
m_local +=
(psize == 1) ? 0 :
(prank == 0 or prank == psize -1) ? 1 : 2;
Simulation simu(m_local, N);
simu.set_initial_conditions();
simu.set_epsilon(EPSILON);
float l2;
int k;
auto start = clk::now();
std::tie(l2, k) = simu.compute();
auto end = clk::now();
second time = end - start;
if(prank == 0)
std::cout << psize << " " << N << " "
<< k << " " << std::scientific << l2 << " "
<< time.count() / k << std::endl;
MPI_Finalize();
return 0;
}
Event Timeline
Log In to Comment