Skip to content

Commit

Permalink
Minimizing and correcting MPI calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerenfro committed Feb 13, 2021
1 parent 3ded072 commit cfc27b2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 34 deletions.
Binary file modified fig/finalize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed fig/scatter-2.png
Binary file not shown.
34 changes: 2 additions & 32 deletions files/initialize-scatter-compute-gather.tex
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
\newcommand{\drawarrows}{}
}

% Scatter 1
% Scatter
%\newcommand{\setstate}{
%\newcommand{\countstyle}{}
%\newcommand{\countszero}{0}
Expand Down Expand Up @@ -85,36 +85,6 @@
%}
%}

% Scatter 2
%\newcommand{\setstate}{
%\newcommand{\countstyle}{}
%\newcommand{\countszero}{0}
%\newcommand{\countsone}{0}
%\newcommand{\countstwo}{0}
%\newcommand{\countsthree}{0}
%\newcommand{\showpi}{}
%\newcommand{\pistyle}{}
%\newcommand{\pizero}{\partition}
%\newcommand{\pione}{\partition}
%\newcommand{\pitwo}{\partition}
%\newcommand{\pithree}{\partition}
%\newcommand{\showci}{}
%\newcommand{\cistyle}{new}
%\newcommand{\cizero}{\countszero}
%\newcommand{\cione}{\countsone}
%\newcommand{\citwo}{\countstwo}
%\newcommand{\cithree}{\countsthree}
%\newcommand{\showmypi}{\phantom}
%\newcommand{\mypistyle}{}
%\newcommand{\mypi}{None}
%\newcommand{\drawarrows}{
% \draw[red, line, arrow, out=200, in=180] (counts00) to (countitem0);
% \draw[red, line, arrow, out=0, in=180] (counts01) to (countitem1);
% \draw[red, line, arrow, out=0, in=180] (counts02) to (countitem2);
% \draw[red, line, arrow, out=0, in=180] (counts03) to (countitem3);
%}
%}

% Compute
%\newcommand{\setstate}{
%\newcommand{\countstyle}{}
Expand Down Expand Up @@ -195,7 +165,7 @@
%\newcommand{\mypi}{3.1796875}
%\newcommand{\drawarrows}{
% \draw[red, line, arrow, out=180, in=180] (counts0start) to (mypi);
% \draw[red, line, arrow, out=180, in=180] (nsamples0) to (mypi);
% \draw[red, line, arrow, out=180, in=180] (partitions0start) to (mypi);
%}
%}

Expand Down
3 changes: 1 addition & 2 deletions files/pi-mpi-minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ def inside_circle(total_count):
partitions = None
counts = None
partition_item = comm.scatter(partitions, root=0)
count_item = comm.scatter(counts, root=0)
count_item = inside_circle(partition_item)
counts = comm.gather(count_item, root=0)
if rank == 0:
my_pi = 4.0 * sum(counts) / n_samples
my_pi = 4.0 * sum(counts) / sum(partitions)
print(my_pi)

0 comments on commit cfc27b2

Please sign in to comment.