Sample Chapel Exercises (SC 13 Ed Program)

Feel free to follow your interests in exploring Chapel, but here are some suggestions:

Suggestions for hands-on session one:

  1. Write a procedure to compute the dot product of two vectors. One possible signature for the method is
         proc getDotProduct(v : [] real, w : [] real) {
    
    For testing, you may find it helpful to create random vectors. You can do this by adding use Random; at the top of file and then using the fillRandom function:
         fillRandom(numbers);
    
    where numbers has already been declared as an array. This also works on 2D (or higher) arrays.
  2. Define a function for matrix-vector products. A possible signature:
         proc matrixVectorProduct(matrix : [] real, vector : [] real) {
    
    If you want to use your dot product routine, you can get the range of row values using matrix.domain.dim(1) and you can extract a single row of the matrix by accessing it with only one coordinate: matrix[index].
  3. Define a node class and use it to make a linked list. (nil is the name of a null reference in Chapel.) Write functions for inserting, removing, printing the list, etc.
  4. Implement binary search.
  5. Use a reduction to sum a Taylor series (e.g. to estimate ex)
  6. Write a custom reduction to identify the 2nd smallest value. What about the kth smallest?


Suggestions for hands-on session two:

(You can also continue with the session one problems...)

  1. Write a function to split a one-dimensional range into two equal pieces. For a range R, you can get the lowest value, the highest value, and the stride (distance between consecutive elements) using R.low, R.high, and R.stride respectively.
  2. Write a function to perform bubble sort. Next, try to do a parallel version: Repeatedly compare each even-indexed element with its successor and then each odd-indexed element with its successor. After n repetitions of this, the array should be sorted.
  3. Implement binary search by changing the domain.
  4. See if you can implement the Game of Life by following the algorithm descriptions.