parallel-concurrent-distributed-java
所属分类:Python编程
开发工具:HTML
文件大小:0KB
下载次数:0
上传日期:2020-11-03 15:11:20
上 传 者:
sh-1993
说明: 我的Java并行、并发和分布式编程解决方案(莱斯大学)
(My solutions for Parallel, Concurrent and Distributed Programming in Java (Rice university))
文件列表:
concurrent-java/ (0, 2018-01-17)
concurrent-java/miniproject_1/ (0, 2018-01-17)
concurrent-java/miniproject_1/hamcrest-core-1.3.jar (45024, 2018-01-17)
concurrent-java/miniproject_1/junit-4.12.jar (314932, 2018-01-17)
concurrent-java/miniproject_1/pcdp-core-0.0.4-SNAPSHOT.jar (30815, 2018-01-17)
concurrent-java/miniproject_1/pom.xml (3806, 2018-01-17)
concurrent-java/miniproject_1/src/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/main/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/main/java/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/main/java/edu/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/main/java/edu/coursera/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/main/java/edu/coursera/concurrent/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/main/java/edu/coursera/concurrent/CoarseLists.java (6442, 2018-01-17)
concurrent-java/miniproject_1/src/main/java/edu/coursera/concurrent/Entry.java (532, 2018-01-17)
concurrent-java/miniproject_1/src/main/java/edu/coursera/concurrent/ListSet.java (1783, 2018-01-17)
concurrent-java/miniproject_1/src/main/java/edu/coursera/concurrent/SyncList.java (1693, 2018-01-17)
concurrent-java/miniproject_1/src/main/java/edu/coursera/concurrent/package-info.java (110, 2018-01-17)
concurrent-java/miniproject_1/src/main/resources/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/main/resources/checkstyle.xml (10928, 2018-01-17)
concurrent-java/miniproject_1/src/test/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/ (0, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/AddTestThread.java (564, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/ContainsTestThread.java (878, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/ListSetTest.java (20436, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/RandomSequenceGenerator.java (850, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/RemoveTestThread.java (870, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/RepeatingSequenceGenerator.java (869, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/ReversedSequenceGenerator.java (1023, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/SequenceGenerator.java (797, 2018-01-17)
concurrent-java/miniproject_1/src/test/java/edu/coursera/concurrent/TestThread.java (604, 2018-01-17)
concurrent-java/miniproject_2/ (0, 2018-01-17)
concurrent-java/miniproject_2/hamcrest-core-1.3.jar (45024, 2018-01-17)
concurrent-java/miniproject_2/junit-4.12.jar (314932, 2018-01-17)
concurrent-java/miniproject_2/pcdp-core-0.0.4-SNAPSHOT.jar (30815, 2018-01-17)
concurrent-java/miniproject_2/pom.xml (4405, 2018-01-17)
... ...
# Parallel, Concurrent and Distributed programming in Java
These are my solutions to these three courses. Below I added short comments to
each week so that I remember better what it's about and that you, the reader,
could have a better idea too.
## Parallel programming in Java
### Week 0
Preparation week. The purpose is to test your environment. No actual task to do.
### Week 1 ForkJoin
In this week we need to calculate reciprocal array sum. We're using Java's
ForkJoin framework to parallelize our calculations. There are different ways to
interact with the ForkJoin framework, and in this week we're extending
`RecursiveAction` and overriding `compute()` method. In `compute()` method we
determine current size of the current range of the that we need to process. If
it's small enough, we are processing it immediately. Otherwise, we divide it
into two parts (left and right) and process them recursively.
The minimal threshold value determines how many ForJoin tasks we will totally
create. Notice that I didn't manage to pass the tests locally and I didn't
submit the solution to the Coursera grader. Many students reported the same
problem on the forums. Still, there was a significant improvement over the
linear execution, just not as big as expected by the creators of the homework.
### Week 2 Streams
This week we're using Java Streams API to build a pipeline that computes some
student analytics. Nothing difficult here, you just need to understand which
data type you have at each pipeline stage and convert data types accordingly if
needed.
### Week 3 PCDP
This week we are learning how to use PCDP library (a library developed to teach
parallel computations) to parallelize matrix multiplications. Again, the task is
trivial as you only need to replace one method name with another.
### Week 4 Fuzzy phasers
In this week we explore the functionality of fuzzy phasers. The idea is that if
we have an array which average sum we need to compute, we can split work into
`N` tasks and do it concurrently. The improvement is that a task `i` only has to
for for tasks `i-1` and `i+1` to complete. To achieve that, we use `N` phasers
and we call their methods `arrive()` and `awaitAdvance(int phase)`. Notice here
since we run multiple iterations over the same array, this `phase` number keeps
growing and it's crucially important to keep track of the current phase.
``` text
1 2 3
\ /
1 2 3
```
This illustrates that task 2 depends on completion of tasks 1 and 3.
## Concurrent programming in Java
### Week 1 Locks
In this week we were introduced to locks, the basic primitive for
synchronization. Java's `synchronized` keyword is pretty much the same lock that
guards the whole method. Lock, however, can be made more granular. In this week
we applied `ReadWrite` lock to benefit from the fact that read only methods can
have concurrent access to the data, while read-and-write methods should be
guarded by a lock.
### Week 2 Isolation
This week we are introduced to the concepts of critical sections, atomic
variables and isolation. Being a more high-level synchronization construct,
isolation allows for simpler semantics providing the same or even better level
of efficiency. To make things faster in the homework, we use PCDP library and
object-level isolation, not global isolation.
### Week 3 Actors
This week we are introduced to the concept of actors. To explain it in my own
words, actors are independent units of computation that you can communicate with
using `send` method. In the miniproject we need to implement the famous Sieve of
Eratosthenes using actors. To do that, we create a chain of actors that
one-by-one check whether a given number is divisible by the range of numbers,
assigned to the given actor. To make it more efficient, a single actor is
assigned a bunch of numbers, e.g. 1000, not just one.
### Week 4
This week we are introduced to concurrent data structures. In the miniproject we
need to implement Boruvka's algorithm that builds Minimum Weighted Spanning Tree
(MST). The implementation should use granular locks (one per node) to secure
access from multiple threads.
## Distributed programming in Java
### Week 1 Distributed Map Reduce
In this week we need to calculate PageRank using Spark tools to split data and
process it by chunks, a more advanced Map-Reduce model.
### Week 2 Client-server programming
In this week we are introduced to the concept of client-server networking,
specifically to sockets. We need to implement a simple file server that serves
file over a socket by HTTP protocol.
### Week 3 Message passing
This week we are using MPI to distribute matrix calculation. We send the whole
two matrices to all available instances and on each instance we calculate only
those rows that correspond to the current instance. When we're done, we send
results back and collect the resulting matrix.
### Week 4 Combining distribution and multi-threading
This week is basically the same as week 2 but now we need to execute each
request in a separate thread.
## Author
2017-2018, Yuri Bochkarev
近期下载者:
相关文件:
收藏者: