[d67cdb7] | 1 | % ====================================================================== |
---|
| 2 | % ====================================================================== |
---|
| 3 | \chapter{Future Work} |
---|
| 4 | % ====================================================================== |
---|
| 5 | % ====================================================================== |
---|
| 6 | |
---|
[64b272a] | 7 | \section{Flexible Scheduling} \label{futur:sched} |
---|
[07c1e595] | 8 | An important part of concurrency is scheduling. Different scheduling algorithm can affect performance (both in terms of average and variation). However, no single scheduler is optimal for all workloads and therefore there is value in being able to change the scheduler for given programs. One solution is to offer various tweaking options to users, allowing the scheduler to be adjusted the to requirements of the workload. However, in order to be truly flexible, it would be interesting to allow users to add arbitrary data and arbitrary scheduling algorithms to the scheduler. For example, a web server could attach Type-of-Service information to threads and have a ``ToS aware'' scheduling algorithm tailored to this specific web server. This path of flexible schedulers will be explored for \CFA. |
---|
[64b272a] | 9 | |
---|
| 10 | \section{Non-Blocking IO} \label{futur:nbio} |
---|
| 11 | While most of the parallelism tools |
---|
[9f10d1f2] | 12 | However, many modern workloads are not bound on computation but on IO operations, an common case being web-servers and XaaS (anything as a service). These type of workloads often require significant engineering around amortizing costs of blocking IO operations. While improving throughput of these operations is outside what \CFA can do as a language, it can help users to make better use of the CPU time otherwise spent waiting on IO operations. The current trend is to use asynchronous programming using tools like callbacks and/or futures and promises~\cit. However, while these are valid solutions, they lead to code that is harder to read and maintain because it is much less linear |
---|
[64b272a] | 13 | |
---|
| 14 | \section{Other concurrency tools} \label{futur:tools} |
---|
[9f10d1f2] | 15 | While monitors offer a flexible and powerful concurrent core for \CFA, other concurrency tools are also necessary for a complete multi-paradigm concurrency package. Example of such tools can include simple locks and condition variables, futures and promises~\cite{promises}, and executors. These additional features are useful when monitors offer a level of abstraction which is inadequate for certain tasks. |
---|
[64b272a] | 16 | |
---|
| 17 | \section{Implicit threading} \label{futur:implcit} |
---|
[9f10d1f2] | 18 | Simpler applications can benefit greatly from having implicit parallelism. That is, parallelism that does not rely on the user to write concurrency. This type of parallelism can be achieved both at the language level and at the library level. The canonical example of implicit parallelism is parallel for loops, which are the simplest example of a divide and conquer algorithm~\cite{uC++book}. Listing \ref{lst:parfor} shows three different code examples that accomplish point-wise sums of large arrays. Note that none of these example explicitly declare any concurrency or parallelism objects. |
---|
[64b272a] | 19 | |
---|
| 20 | \begin{figure} |
---|
| 21 | \begin{center} |
---|
| 22 | \begin{tabular}[t]{|c|c|c|} |
---|
| 23 | Sequential & Library Parallel & Language Parallel \\ |
---|
| 24 | \begin{cfacode}[tabsize=3] |
---|
| 25 | void big_sum( |
---|
| 26 | int* a, int* b, |
---|
| 27 | int* o, |
---|
| 28 | size_t len) |
---|
| 29 | { |
---|
| 30 | for( |
---|
| 31 | int i = 0; |
---|
| 32 | i < len; |
---|
| 33 | ++i ) |
---|
| 34 | { |
---|
| 35 | o[i]=a[i]+b[i]; |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | int* a[10000]; |
---|
| 44 | int* b[10000]; |
---|
| 45 | int* c[10000]; |
---|
| 46 | //... fill in a & b |
---|
| 47 | big_sum(a,b,c,10000); |
---|
| 48 | \end{cfacode} &\begin{cfacode}[tabsize=3] |
---|
| 49 | void big_sum( |
---|
| 50 | int* a, int* b, |
---|
| 51 | int* o, |
---|
| 52 | size_t len) |
---|
| 53 | { |
---|
| 54 | range ar(a, a+len); |
---|
| 55 | range br(b, b+len); |
---|
| 56 | range or(o, o+len); |
---|
| 57 | parfor( ai, bi, oi, |
---|
| 58 | []( int* ai, |
---|
| 59 | int* bi, |
---|
| 60 | int* oi) |
---|
| 61 | { |
---|
| 62 | oi=ai+bi; |
---|
| 63 | }); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | int* a[10000]; |
---|
| 68 | int* b[10000]; |
---|
| 69 | int* c[10000]; |
---|
| 70 | //... fill in a & b |
---|
| 71 | big_sum(a,b,c,10000); |
---|
| 72 | \end{cfacode}&\begin{cfacode}[tabsize=3] |
---|
| 73 | void big_sum( |
---|
| 74 | int* a, int* b, |
---|
| 75 | int* o, |
---|
| 76 | size_t len) |
---|
| 77 | { |
---|
| 78 | parfor (ai,bi,oi) |
---|
| 79 | in (a, b, o ) |
---|
| 80 | { |
---|
| 81 | oi = ai + bi; |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | int* a[10000]; |
---|
| 92 | int* b[10000]; |
---|
| 93 | int* c[10000]; |
---|
| 94 | //... fill in a & b |
---|
| 95 | big_sum(a,b,c,10000); |
---|
| 96 | \end{cfacode} |
---|
| 97 | \end{tabular} |
---|
| 98 | \end{center} |
---|
| 99 | \caption{For loop to sum numbers: Sequential, using library parallelism and language parallelism.} |
---|
| 100 | \label{lst:parfor} |
---|
| 101 | \end{figure} |
---|
| 102 | |
---|
[20ffcf3] | 103 | Implicit parallelism is a general solution and therefore has its limitations. However, it is a quick and simple approach to parallelism which may very well be sufficient for smaller applications and reduces the amount of boiler-plate that is needed to start benefiting from parallelism in modern CPUs. |
---|
[64b272a] | 104 | |
---|
| 105 | |
---|