# source:doc/proposals/concurrency/text/future.tex@9f10d1f2

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationresolv-newwith_gc
Last change on this file since 9f10d1f2 was 9f10d1f2, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Revised up to chapter three

• Property mode set to 100644
File size: 4.3 KB
Line
1% ======================================================================
2% ======================================================================
3\chapter{Future Work}
4% ======================================================================
5% ======================================================================
6
7\section{Flexible Scheduling} \label{futur:sched}
8An 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.
9
10\section{Non-Blocking IO} \label{futur:nbio}
11While most of the parallelism tools
12However, 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
13
14\section{Other concurrency tools} \label{futur:tools}
15While 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.
16
17\section{Implicit threading} \label{futur:implcit}
18Simpler 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.
19
20\begin{figure}
21\begin{center}
22\begin{tabular}[t]{|c|c|c|}
23Sequential & Library Parallel & Language Parallel \\
24\begin{cfacode}[tabsize=3]
25void 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
43int* a[10000];
44int* b[10000];
45int* c[10000];
46//... fill in a & b
47big_sum(a,b,c,10000);
48\end{cfacode} &\begin{cfacode}[tabsize=3]
49void 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
67int* a[10000];
68int* b[10000];
69int* c[10000];
70//... fill in a & b
71big_sum(a,b,c,10000);
72\end{cfacode}&\begin{cfacode}[tabsize=3]
73void 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
91int* a[10000];
92int* b[10000];
93int* c[10000];
94//... fill in a & b
95big_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
103Implicit 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.
104
105
Note: See TracBrowser for help on using the repository browser.