-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (53 loc) · 1.36 KB
/
main.cpp
File metadata and controls
70 lines (53 loc) · 1.36 KB
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
64
65
66
67
68
69
70
//
// main
//
// Created by Martin Perdacher on 2013-09-16.
// Copyright (c) 2013 . All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "mpi.h"
#include <primme.h>
#define MASTER 0
#define REPETITIONS 10
int main(int argc, char *argv[]){
int myrank, nprocs,i;
long n;
double times[REPETITIONS];
double time, slowest,h,x,endresult;
primme_params primme;
MPI_Status recv_status;
MPI_Request request;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if ( argc != 2 ){
if ( myrank == MASTER ) {
printf("Usage: mpiexec -n nodecount matVec2aa n\n");
printf("with n is the size of the matrix\n\n");
}
return 1;
}
n = atol(argv[1]);
for ( i = 0 ; i < REPETITIONS ; ++i ){
MPI_Barrier(MPI_COMM_WORLD);
time = MPI_Wtime();
// primme initialization
primme_initialize(&primme);
time = MPI_Wtime() - time;
MPI_Barrier(MPI_COMM_WORLD);
MPI_Reduce(&time, &slowest, 1, MPI_DOUBLE, MPI_MAX, MASTER, MPI_COMM_WORLD);
if (myrank == MASTER) {
times[i]=slowest;
}
}
if ( myrank == MASTER ){
double min = times[0];
for ( i = 1; i < REPETITIONS ; i++) {
min = ( times[i] < min ) ? times[i] : min;
}
printf("%d;%ld;%f\n", nprocs, n, min); // delta to orig solution is missing
}
MPI_Finalize();
}