Skip to content

Commit 6e194e1

Browse files
giordanoikirker
authored andcommitted
[c_hybrid_mpi+openmp] Allow passing number of steps from command line
1 parent 5e00b74 commit 6e194e1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

c_hybrid_mpi+openmp_dir/hybrid_pi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
#include <math.h>
44

55
int main( int argc, char **argv ) {
6-
const long int num_steps = 1000000000;
6+
long int num_steps = 1000000000;
77
double step, x, sum, total_sum, pi, start, stop, min_start, max_stop;
88
int this_proc, num_procs, remainder;
99
long int my_slice[2];
1010
long int i;
1111

12+
if (argc > 1) {
13+
num_steps = atol(argv[1]);
14+
}
15+
1216
MPI_Init(&argc,&argv);
1317
MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
1418
MPI_Comm_rank(MPI_COMM_WORLD,&this_proc);

c_hybrid_mpi+openmp_dir/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
make clean
44
make
5-
mpirun ./hybrid_pi
5+
mpirun ./hybrid_pi "${@}"

0 commit comments

Comments
 (0)