Coursera Parallel Programming in Javaを受講した

社会人になるまでなんとなく Java を避けていたが、必要に迫られて学びはじめてみると、周辺ツールやライブラリ、学習資料が非常に充実していて驚いた。学生の頃はわからなかったが、いまなら Javaエンタープライズ分野で使われる理由がよくわかる。

4月に Coursera からコースの案内メールが来た。Rice University が提供する、Parallel, Concurrent, and Distributed Programming in Java Specialization というコースが紹介されていた。面白そうなので受講してみることにした。 www.coursera.org

今回修了したのは、その3つのクラスからなるコースの1つ目「Parallel Programming in Java」。4週間のクラスだったので、主に土日に1週分を学習し、4週ですべての課題を提出して修了条件を満たした。

コースの難易度は、同じ Coursera の有名クラス「Machine Learning」などと比べるとかなり簡単で、クラス毎に用意されたフォーラムの書き込みを見ると、2日程度ですべての教材と課題を消化した人もいるようだ。

クラス名に Java と入っているが、Java の並行処理ライブラリの使い方を懇切丁寧に解説するようなクラスではない。はじめに並列コンピューティングの概念を説明して、それを実現する Java の機能をさらっと紹介するという構成になっている。

各週の授業内容を公式ページから引用するとこんな感じだ。

  • 1週目

    We will learn about task creation, task termination, and the “computation graph” theoretical model for understanding various properties of task-parallel programs. These properties include work, span, ideal parallelism, parallel speedup, and Amdahl’s Law. We will also learn popular Java APIs for task parallelism, most notably the Fork/Join framework.

  • 2週目

    We will learn about futures, memoization, and streams, as well as data races, a notorious class of bugs that can be avoided with functional parallelism. We will also learn Java APIs for functional parallelism, including the Fork/Join framework and the Stream API’s.

  • 3週目

    We will start by learning how parallel counted-for loops can be conveniently expressed using forall and stream APIs in Java, and how these APIs can be used to parallelize a simple matrix multiplication program. We will also learn about the barrier construct for parallel loops, and illustrate its use with a simple iterative averaging program example. Finally, we will learn the importance of grouping/chunking parallel iterations to reduce overhead.

  • 4週目

    We will learn how Java’s Phaser API can be used to implement “fuzzy” barriers, and also “point-to-point” synchronizations as an optimization of regular barriers by revisiting the iterative averaging example. Finally, we will also learn how pipeline parallelism and data flow models can be expressed using Java APIs.

これだけ見ると盛り沢山の内容だが、それぞれがサラッと紹介される程度なので、並列コンピューティングの入門にはよい。深く学ぶには別の書籍なりオンラインコースが必要だろう。

修了条件を満たすには、毎週 mini project と呼ばれるプログラミング課題をクリアする必要がある。これも難易度は高くなくて、とくに1週目の project 以外は、ほぼ完成しているソースコードが提供されるため、それを少し改変すればよい。これには少々拍子抜けしたが、数ヶ月前に同クラスが開講された際のフォーラムの書き込みを見ると、そのときはすべて一からコードを書く必要があったようだ。

Mini project がなぜ今のような「お手軽」な形になったのかは不明だが、想像はできる。実は、この mini project は授業内容との乖離や、意図がわかりずらい出題になっている等の「問題」が少々ある。それらに対する問い合わせが殺到した結果、最初からある程度完成されたものを提供するようになったのではないだろうか。

個人的には気軽に楽しく受講できたので満足している。次の Concurrent Programming in Java も楽しみだ。