Homework II
Due Wednesday, November 1
Problem 1
In this problem, you will learn about MPI, redoing
Homework I in that framework.
- The signature of the function will be the same as before.
- As before, the TA will call the function from his main(). He
will time it using MPI's timing functions. He will announce the number
of machines to be used as workers.
- The TA will announce the data file to be used.
- Your manager node will read in the file.
- The three fastest groups will receive Extra Credit.
-
Submit your code in a file Problem1.c.
Problem 2 (EXTRA CREDIT)
Recall the R zoo package used at the end of Chapter 1. For long
vectors, say 50000000, it can have a long run time, suggesting the use
of parallel computation. Here you will write the procedure in C/OpenMP,
to be called from R.
- The R call form will be
omp_rollmean(x,k)
with the same meaning is with rollmean() with the default
arguments (though here we restrict x to vectors).
- You will use R's .Call() method for interfacing R to C/C++.
If you wish, the Rcpp package can be used, which provides
convenient wrappers for the basic R macros for interfacing. However,
although these are quite powerful, they can be finicky to use, and I
suggest working with the SEXPs directly.
-
The signature of your C function will be
NumericVector omp_rollmean(NumericVector x, int k)
- The TA will announce the size of x and k that he will
use in his speed tests.
- The three fastest groups will receive Extra Credit.
-
Put your code in a file Problem2.cpp.
Resources:
- My ECS 256 TA's
tutorial on Rcpp.
- My previous ECS 158 TA's
tutorial on Rcpp.
- Code examples etc. in the
Rcpp Gallery, including some
examples with OpenMP.